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

Generated by: LCOV version 1.10