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

Generated by: LCOV version 1.10