LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexAlphabeticalSourceContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 48 84 57.1 %
Date: 2012-08-25 Functions: 6 11 54.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 57 181 31.5 %

           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 "XMLIndexAlphabeticalSourceContext.hxx"
      31                 :            : 
      32                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      33                 :            : #include <com/sun/star/container/XIndexReplace.hpp>
      34                 :            : 
      35                 :            : #include <sax/tools/converter.hxx>
      36                 :            : 
      37                 :            : #include "XMLIndexTemplateContext.hxx"
      38                 :            : #include "XMLIndexTitleTemplateContext.hxx"
      39                 :            : #include "XMLIndexTOCStylesContext.hxx"
      40                 :            : #include <xmloff/xmlictxt.hxx>
      41                 :            : #include <xmloff/xmlimp.hxx>
      42                 :            : #include <xmloff/txtimp.hxx>
      43                 :            : #include "xmloff/xmlnmspe.hxx"
      44                 :            : #include <xmloff/nmspmap.hxx>
      45                 :            : #include <xmloff/xmltoken.hxx>
      46                 :            : #include <xmloff/xmluconv.hxx>
      47                 :            : #include <rtl/ustring.hxx>
      48                 :            : 
      49                 :            : 
      50                 :            : 
      51                 :            : 
      52                 :            : using ::rtl::OUString;
      53                 :            : using ::com::sun::star::beans::XPropertySet;
      54                 :            : using ::com::sun::star::uno::Reference;
      55                 :            : using ::com::sun::star::uno::Any;
      56                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      57                 :            : using ::xmloff::token::IsXMLToken;
      58                 :            : using ::xmloff::token::XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE;
      59                 :            : using ::xmloff::token::XML_OUTLINE_LEVEL;
      60                 :            : 
      61                 :            : const sal_Char sAPI_MainEntryCharacterStyleName[] = "MainEntryCharacterStyleName";
      62                 :            : const sal_Char sAPI_UseAlphabeticalSeparators[] = "UseAlphabeticalSeparators";
      63                 :            : const sal_Char sAPI_UseCombinedEntries[] = "UseCombinedEntries";
      64                 :            : const sal_Char sAPI_IsCaseSensitive[] = "IsCaseSensitive";
      65                 :            : const sal_Char sAPI_UseKeyAsEntry[] = "UseKeyAsEntry";
      66                 :            : const sal_Char sAPI_UseUpperCase[] = "UseUpperCase";
      67                 :            : const sal_Char sAPI_UseDash[] = "UseDash";
      68                 :            : const sal_Char sAPI_UsePP[] = "UsePP";
      69                 :            : const sal_Char sAPI_SortAlgorithm[] = "SortAlgorithm";
      70                 :            : const sal_Char sAPI_Locale[] = "Locale";
      71                 :            : 
      72                 :            : 
      73 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLIndexAlphabeticalSourceContext, XMLIndexSourceBaseContext );
      74                 :            : 
      75                 :          4 : XMLIndexAlphabeticalSourceContext::XMLIndexAlphabeticalSourceContext(
      76                 :            :     SvXMLImport& rImport,
      77                 :            :     sal_uInt16 nPrfx,
      78                 :            :     const OUString& rLocalName,
      79                 :            :     Reference<XPropertySet> & rPropSet)
      80                 :            : :   XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, rPropSet, sal_False)
      81                 :            : ,   sMainEntryCharacterStyleName(RTL_CONSTASCII_USTRINGPARAM(sAPI_MainEntryCharacterStyleName))
      82                 :            : ,   sUseAlphabeticalSeparators(RTL_CONSTASCII_USTRINGPARAM(sAPI_UseAlphabeticalSeparators))
      83                 :            : ,   sUseCombinedEntries(RTL_CONSTASCII_USTRINGPARAM(sAPI_UseCombinedEntries))
      84                 :            : ,   sIsCaseSensitive(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsCaseSensitive))
      85                 :            : ,   sUseKeyAsEntry(RTL_CONSTASCII_USTRINGPARAM(sAPI_UseKeyAsEntry))
      86                 :            : ,   sUseUpperCase(RTL_CONSTASCII_USTRINGPARAM(sAPI_UseUpperCase))
      87                 :            : ,   sUseDash(RTL_CONSTASCII_USTRINGPARAM(sAPI_UseDash))
      88                 :            : ,   sUsePP(RTL_CONSTASCII_USTRINGPARAM(sAPI_UsePP))
      89                 :            : ,   sIsCommaSeparated(RTL_CONSTASCII_USTRINGPARAM("IsCommaSeparated"))
      90                 :            : ,   sSortAlgorithm(RTL_CONSTASCII_USTRINGPARAM(sAPI_SortAlgorithm))
      91                 :            : ,   sLocale(RTL_CONSTASCII_USTRINGPARAM(sAPI_Locale))
      92                 :            : ,   bMainEntryStyleNameOK(sal_False)
      93                 :            : ,   bSeparators(sal_False)
      94                 :            : ,   bCombineEntries(sal_True)
      95                 :            : ,   bCaseSensitive(sal_True)
      96                 :            : ,   bEntry(sal_False)
      97                 :            : ,   bUpperCase(sal_False)
      98                 :            : ,   bCombineDash(sal_False)
      99                 :            : ,   bCombinePP(sal_True)
     100 [ +  - ][ +  - ]:          4 : ,   bCommaSeparated(sal_False)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     101                 :            : {
     102                 :          4 : }
     103                 :            : 
     104                 :          4 : XMLIndexAlphabeticalSourceContext::~XMLIndexAlphabeticalSourceContext()
     105                 :            : {
     106         [ -  + ]:          8 : }
     107                 :            : 
     108                 :         12 : void XMLIndexAlphabeticalSourceContext::ProcessAttribute(
     109                 :            :     enum IndexSourceParamEnum eParam,
     110                 :            :     const OUString& rValue)
     111                 :            : {
     112                 :         12 :     bool bTmp(false);
     113                 :            : 
     114   [ -  -  -  -  :         12 :     switch (eParam)
          -  -  -  -  -  
             +  +  +  - ]
     115                 :            :     {
     116                 :            :         case XML_TOK_INDEXSOURCE_MAIN_ENTRY_STYLE:
     117                 :            :             {
     118                 :          0 :                 sMainEntryStyleName = rValue;
     119                 :          0 :                 OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
     120         [ #  # ]:          0 :                     XML_STYLE_FAMILY_TEXT_TEXT, sMainEntryStyleName );
     121                 :            :                 const Reference < ::com::sun::star::container::XNameContainer >&
     122 [ #  # ][ #  # ]:          0 :                     rStyles = GetImport().GetTextImport()->GetTextStyles();
         [ #  # ][ #  # ]
     123 [ #  # ][ #  # ]:          0 :                 bMainEntryStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
         [ #  # ][ #  # ]
     124                 :            :             }
     125                 :          0 :             break;
     126                 :            : 
     127                 :            :         case XML_TOK_INDEXSOURCE_IGNORE_CASE:
     128 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     129                 :            :             {
     130                 :          0 :                 bCaseSensitive = !bTmp;
     131                 :            :             }
     132                 :          0 :             break;
     133                 :            : 
     134                 :            :         case XML_TOK_INDEXSOURCE_SEPARATORS:
     135 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     136                 :            :             {
     137                 :          0 :                 bSeparators = bTmp;
     138                 :            :             }
     139                 :          0 :             break;
     140                 :            : 
     141                 :            :         case XML_TOK_INDEXSOURCE_COMBINE_ENTRIES:
     142 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     143                 :            :             {
     144                 :          0 :                 bCombineEntries = bTmp;
     145                 :            :             }
     146                 :          0 :             break;
     147                 :            : 
     148                 :            :         case XML_TOK_INDEXSOURCE_COMBINE_WITH_DASH:
     149 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     150                 :            :             {
     151                 :          0 :                 bCombineDash = bTmp;
     152                 :            :             }
     153                 :          0 :             break;
     154                 :            :         case XML_TOK_INDEXSOURCE_KEYS_AS_ENTRIES:
     155 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     156                 :            :             {
     157                 :          0 :                 bEntry = bTmp;
     158                 :            :             }
     159                 :          0 :             break;
     160                 :            : 
     161                 :            :         case XML_TOK_INDEXSOURCE_COMBINE_WITH_PP:
     162 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     163                 :            :             {
     164                 :          0 :                 bCombinePP = bTmp;
     165                 :            :             }
     166                 :          0 :             break;
     167                 :            : 
     168                 :            :         case XML_TOK_INDEXSOURCE_CAPITALIZE:
     169 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     170                 :            :             {
     171                 :          0 :                 bUpperCase = bTmp;
     172                 :            :             }
     173                 :          0 :             break;
     174                 :            : 
     175                 :            :         case XML_TOK_INDEXSOURCE_COMMA_SEPARATED:
     176 [ #  # ][ #  # ]:          0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     177                 :            :             {
     178                 :          0 :                 bCommaSeparated = bTmp;
     179                 :            :             }
     180                 :          0 :             break;
     181                 :            : 
     182                 :            :         case XML_TOK_INDEXSOURCE_SORT_ALGORITHM:
     183                 :          4 :             sAlgorithm = rValue;
     184                 :          4 :             break;
     185                 :            :         case XML_TOK_INDEXSOURCE_LANGUAGE:
     186                 :          4 :             aLocale.Language = rValue;
     187                 :          4 :             break;
     188                 :            :         case XML_TOK_INDEXSOURCE_COUNTRY:
     189                 :          4 :             aLocale.Country = rValue;
     190                 :          4 :             break;
     191                 :            : 
     192                 :            :         default:
     193         [ #  # ]:          0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     194                 :          0 :             break;
     195                 :            :     }
     196                 :         12 : }
     197                 :            : 
     198                 :          4 : void XMLIndexAlphabeticalSourceContext::EndElement()
     199                 :            : {
     200                 :            : 
     201                 :          4 :     Any aAny;
     202                 :            : 
     203         [ -  + ]:          4 :     if (bMainEntryStyleNameOK)
     204                 :            :     {
     205                 :          0 :         aAny <<= GetImport().GetStyleDisplayName(
     206 [ #  # ][ #  # ]:          0 :                             XML_STYLE_FAMILY_TEXT_TEXT, sMainEntryStyleName );
     207 [ #  # ][ #  # ]:          0 :         rIndexPropertySet->setPropertyValue(sMainEntryCharacterStyleName,aAny);
     208                 :            :     }
     209                 :            : 
     210         [ +  - ]:          4 :     aAny.setValue(&bSeparators, ::getBooleanCppuType());
     211 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sUseAlphabeticalSeparators, aAny);
     212                 :            : 
     213         [ +  - ]:          4 :     aAny.setValue(&bCombineEntries, ::getBooleanCppuType());
     214 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sUseCombinedEntries, aAny);
     215                 :            : 
     216         [ +  - ]:          4 :     aAny.setValue(&bCaseSensitive, ::getBooleanCppuType());
     217 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sIsCaseSensitive, aAny);
     218                 :            : 
     219         [ +  - ]:          4 :     aAny.setValue(&bEntry, ::getBooleanCppuType());
     220 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sUseKeyAsEntry, aAny);
     221                 :            : 
     222         [ +  - ]:          4 :     aAny.setValue(&bUpperCase, ::getBooleanCppuType());
     223 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sUseUpperCase, aAny);
     224                 :            : 
     225         [ +  - ]:          4 :     aAny.setValue(&bCombineDash, ::getBooleanCppuType());
     226 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sUseDash, aAny);
     227                 :            : 
     228         [ +  - ]:          4 :     aAny.setValue(&bCombinePP, ::getBooleanCppuType());
     229 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sUsePP, aAny);
     230                 :            : 
     231         [ +  - ]:          4 :     aAny.setValue(&bCommaSeparated, ::getBooleanCppuType());
     232 [ +  - ][ +  - ]:          4 :     rIndexPropertySet->setPropertyValue(sIsCommaSeparated, aAny);
     233                 :            : 
     234                 :            : 
     235         [ +  - ]:          4 :     if (!sAlgorithm.isEmpty())
     236                 :            :     {
     237         [ +  - ]:          4 :         aAny <<= sAlgorithm;
     238 [ +  - ][ +  - ]:          4 :         rIndexPropertySet->setPropertyValue(sSortAlgorithm, aAny);
     239                 :            :     }
     240                 :            : 
     241 [ +  - ][ +  - ]:          4 :     if ( !aLocale.Language.isEmpty()  && !aLocale.Country.isEmpty() )
                 [ +  - ]
     242                 :            :     {
     243         [ +  - ]:          4 :         aAny <<= aLocale;
     244 [ +  - ][ +  - ]:          4 :         rIndexPropertySet->setPropertyValue(sLocale, aAny);
     245                 :            :     }
     246                 :            : 
     247         [ +  - ]:          4 :     XMLIndexSourceBaseContext::EndElement();
     248                 :          4 : }
     249                 :            : 
     250                 :         20 : SvXMLImportContext* XMLIndexAlphabeticalSourceContext::CreateChildContext(
     251                 :            :     sal_uInt16 nPrefix,
     252                 :            :     const OUString& rLocalName,
     253                 :            :     const Reference<XAttributeList> & xAttrList )
     254                 :            : {
     255   [ +  -  +  + ]:         40 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
                 [ +  + ]
     256                 :         20 :          IsXMLToken( rLocalName, XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE ) )
     257                 :            :     {
     258                 :         16 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     259                 :            :                                            nPrefix, rLocalName,
     260                 :            :                                            aLevelNameAlphaMap,
     261                 :            :                                            XML_OUTLINE_LEVEL,
     262                 :            :                                            aLevelStylePropNameAlphaMap,
     263         [ +  - ]:         16 :                                            aAllowedTokenTypesAlpha);
     264                 :            :     }
     265                 :            :     else
     266                 :            :     {
     267                 :            :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     268                 :            :                                                              rLocalName,
     269                 :         20 :                                                              xAttrList);
     270                 :            :     }
     271                 :            : }
     272                 :            : 
     273                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10