LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexUserSourceContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 62 66.1 %
Date: 2015-06-13 12:38:46 Functions: 6 11 54.5 %
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 "XMLIndexUserSourceContext.hxx"
      21             : #include <com/sun/star/beans/XPropertySet.hpp>
      22             : #include <com/sun/star/container/XIndexReplace.hpp>
      23             : #include <sax/tools/converter.hxx>
      24             : #include "XMLIndexTemplateContext.hxx"
      25             : #include "XMLIndexTitleTemplateContext.hxx"
      26             : #include "XMLIndexTOCStylesContext.hxx"
      27             : #include <xmloff/xmlictxt.hxx>
      28             : #include <xmloff/xmlimp.hxx>
      29             : #include <xmloff/txtimp.hxx>
      30             : #include <xmloff/xmlnmspe.hxx>
      31             : #include <xmloff/nmspmap.hxx>
      32             : #include <xmloff/xmltoken.hxx>
      33             : #include <rtl/ustring.hxx>
      34             : 
      35             : 
      36             : using ::com::sun::star::beans::XPropertySet;
      37             : using ::com::sun::star::uno::Reference;
      38             : using ::com::sun::star::uno::Any;
      39             : using ::com::sun::star::xml::sax::XAttributeList;
      40             : using ::xmloff::token::IsXMLToken;
      41             : using ::xmloff::token::XML_USER_INDEX_ENTRY_TEMPLATE;
      42             : using ::xmloff::token::XML_OUTLINE_LEVEL;
      43             : 
      44             : 
      45             : const sal_Char sAPI_CreateFromEmbeddedObjects[] = "CreateFromEmbeddedObjects";
      46             : const sal_Char sAPI_CreateFromGraphicObjects[] = "CreateFromGraphicObjects";
      47             : const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks";
      48             : const sal_Char sAPI_CreateFromTables[] = "CreateFromTables";
      49             : const sal_Char sAPI_CreateFromTextFrames[] = "CreateFromTextFrames";
      50             : const sal_Char sAPI_UseLevelFromSource[] = "UseLevelFromSource";
      51             : const sal_Char sAPI_CreateFromLevelParagraphStyles[] = "CreateFromLevelParagraphStyles";
      52             : const sal_Char sAPI_UserIndexName[] = "UserIndexName";
      53             : 
      54             : 
      55           0 : TYPEINIT1(XMLIndexUserSourceContext, XMLIndexSourceBaseContext);
      56             : 
      57             : 
      58           2 : XMLIndexUserSourceContext::XMLIndexUserSourceContext(
      59             :     SvXMLImport& rImport,
      60             :     sal_uInt16 nPrfx,
      61             :     const OUString& rLocalName,
      62             :     Reference<XPropertySet> & rPropSet) :
      63             :         XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
      64             :                                   rPropSet, true),
      65             :         sCreateFromEmbeddedObjects(sAPI_CreateFromEmbeddedObjects),
      66             :         sCreateFromGraphicObjects(sAPI_CreateFromGraphicObjects),
      67             :         sCreateFromMarks(sAPI_CreateFromMarks),
      68             :         sCreateFromTables(sAPI_CreateFromTables),
      69             :         sCreateFromTextFrames(sAPI_CreateFromTextFrames),
      70             :         sUseLevelFromSource(sAPI_UseLevelFromSource),
      71             :         sCreateFromLevelParagraphStyles(sAPI_CreateFromLevelParagraphStyles),
      72             :         sUserIndexName(sAPI_UserIndexName),
      73             :         bUseObjects(false),
      74             :         bUseGraphic(false),
      75             :         bUseMarks(false),
      76             :         bUseTables(false),
      77             :         bUseFrames(false),
      78             :         bUseLevelFromSource(false),
      79           2 :         bUseLevelParagraphStyles(false)
      80             : {
      81           2 : }
      82             : 
      83           4 : XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
      84             : {
      85           4 : }
      86             : 
      87           4 : void XMLIndexUserSourceContext::ProcessAttribute(
      88             :     enum IndexSourceParamEnum eParam,
      89             :     const OUString& rValue)
      90             : {
      91           4 :     bool bTmp(false);
      92             : 
      93           4 :     switch (eParam)
      94             :     {
      95             :         case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
      96           2 :             if (::sax::Converter::convertBool(bTmp, rValue))
      97             :             {
      98           2 :                 bUseMarks = bTmp;
      99             :             }
     100           2 :             break;
     101             : 
     102             :         case XML_TOK_INDEXSOURCE_USE_OBJECTS:
     103           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     104             :             {
     105           0 :                 bUseObjects = bTmp;
     106             :             }
     107           0 :             break;
     108             : 
     109             :         case XML_TOK_INDEXSOURCE_USE_GRAPHICS:
     110           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     111             :             {
     112           0 :                 bUseGraphic = bTmp;
     113             :             }
     114           0 :             break;
     115             : 
     116             :         case XML_TOK_INDEXSOURCE_USE_TABLES:
     117           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     118             :             {
     119           0 :                 bUseTables = bTmp;
     120             :             }
     121           0 :             break;
     122             : 
     123             :         case XML_TOK_INDEXSOURCE_USE_FRAMES:
     124           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     125             :             {
     126           0 :                 bUseFrames = bTmp;
     127             :             }
     128           0 :             break;
     129             : 
     130             :         case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS:
     131           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     132             :             {
     133           0 :                 bUseLevelFromSource = bTmp;
     134             :             }
     135           0 :             break;
     136             : 
     137             :         case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES:
     138           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
     139             :             {
     140           0 :                 bUseLevelParagraphStyles = bTmp;
     141             :             }
     142           0 :             break;
     143             : 
     144             :         case XML_TOK_INDEXSOURCE_USER_INDEX_NAME:
     145           2 :             sIndexName = rValue;
     146           2 :             break;
     147             : 
     148             :         default:
     149           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     150           0 :             break;
     151             :     }
     152           4 : }
     153             : 
     154             : 
     155           2 : void XMLIndexUserSourceContext::EndElement()
     156             : {
     157           2 :     Any aAny;
     158             : 
     159           2 :     aAny.setValue(&bUseObjects, cppu::UnoType<bool>::get());
     160           2 :     rIndexPropertySet->setPropertyValue(sCreateFromEmbeddedObjects, aAny);
     161             : 
     162           2 :     aAny.setValue(&bUseGraphic, cppu::UnoType<bool>::get());
     163           2 :     rIndexPropertySet->setPropertyValue(sCreateFromGraphicObjects, aAny);
     164             : 
     165           2 :     aAny.setValue(&bUseLevelFromSource, cppu::UnoType<bool>::get());
     166           2 :     rIndexPropertySet->setPropertyValue(sUseLevelFromSource, aAny);
     167             : 
     168           2 :     aAny.setValue(&bUseMarks, cppu::UnoType<bool>::get());
     169           2 :     rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny);
     170             : 
     171           2 :     aAny.setValue(&bUseTables, cppu::UnoType<bool>::get());
     172           2 :     rIndexPropertySet->setPropertyValue(sCreateFromTables, aAny);
     173             : 
     174           2 :     aAny.setValue(&bUseFrames, cppu::UnoType<bool>::get());
     175           2 :     rIndexPropertySet->setPropertyValue(sCreateFromTextFrames, aAny);
     176             : 
     177           2 :     aAny.setValue(&bUseLevelParagraphStyles, cppu::UnoType<bool>::get());
     178           2 :     rIndexPropertySet->setPropertyValue(sCreateFromLevelParagraphStyles, aAny);
     179             : 
     180           2 :     if( !sIndexName.isEmpty() )
     181             :     {
     182           2 :         aAny <<= sIndexName;
     183           2 :         rIndexPropertySet->setPropertyValue(sUserIndexName, aAny);
     184             :     }
     185             : 
     186           2 :     XMLIndexSourceBaseContext::EndElement();
     187           2 : }
     188             : 
     189             : 
     190          22 : SvXMLImportContext* XMLIndexUserSourceContext::CreateChildContext(
     191             :     sal_uInt16 nPrefix,
     192             :     const OUString& rLocalName,
     193             :     const Reference<XAttributeList> & xAttrList )
     194             : {
     195          44 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
     196          22 :          (IsXMLToken(rLocalName, XML_USER_INDEX_ENTRY_TEMPLATE)) )
     197             :     {
     198          20 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     199             :                                            nPrefix, rLocalName,
     200             :                                            aSvLevelNameTOCMap,
     201             :                                            XML_OUTLINE_LEVEL,
     202             :                                            aLevelStylePropNameTOCMap,
     203          20 :                                            aAllowedTokenTypesUser);
     204             :     }
     205             :     else
     206             :     {
     207             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     208             :                                                              rLocalName,
     209           2 :                                                              xAttrList);
     210             :     }
     211             : 
     212             : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11