LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexUserSourceContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 62 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             : #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           0 : XMLIndexUserSourceContext::XMLIndexUserSourceContext(
      59             :     SvXMLImport& rImport,
      60             :     sal_uInt16 nPrfx,
      61             :     const OUString& rLocalName,
      62             :     Reference<XPropertySet> & rPropSet) :
      63             :         XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
      64             :                                   rPropSet, sal_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(sal_False),
      74             :         bUseGraphic(sal_False),
      75             :         bUseMarks(sal_False),
      76             :         bUseTables(sal_False),
      77             :         bUseFrames(sal_False),
      78             :         bUseLevelFromSource(sal_False),
      79           0 :         bUseLevelParagraphStyles(sal_False)
      80             : {
      81           0 : }
      82             : 
      83           0 : XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
      84             : {
      85           0 : }
      86             : 
      87           0 : void XMLIndexUserSourceContext::ProcessAttribute(
      88             :     enum IndexSourceParamEnum eParam,
      89             :     const OUString& rValue)
      90             : {
      91           0 :     bool bTmp(false);
      92             : 
      93           0 :     switch (eParam)
      94             :     {
      95             :         case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
      96           0 :             if (::sax::Converter::convertBool(bTmp, rValue))
      97             :             {
      98           0 :                 bUseMarks = bTmp;
      99             :             }
     100           0 :             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           0 :             sIndexName = rValue;
     146           0 :             break;
     147             : 
     148             :         default:
     149           0 :             XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
     150           0 :             break;
     151             :     }
     152           0 : }
     153             : 
     154             : 
     155           0 : void XMLIndexUserSourceContext::EndElement()
     156             : {
     157           0 :     Any aAny;
     158             : 
     159           0 :     aAny.setValue(&bUseObjects, ::getBooleanCppuType());
     160           0 :     rIndexPropertySet->setPropertyValue(sCreateFromEmbeddedObjects, aAny);
     161             : 
     162           0 :     aAny.setValue(&bUseGraphic, ::getBooleanCppuType());
     163           0 :     rIndexPropertySet->setPropertyValue(sCreateFromGraphicObjects, aAny);
     164             : 
     165           0 :     aAny.setValue(&bUseLevelFromSource, ::getBooleanCppuType());
     166           0 :     rIndexPropertySet->setPropertyValue(sUseLevelFromSource, aAny);
     167             : 
     168           0 :     aAny.setValue(&bUseMarks, ::getBooleanCppuType());
     169           0 :     rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny);
     170             : 
     171           0 :     aAny.setValue(&bUseTables, ::getBooleanCppuType());
     172           0 :     rIndexPropertySet->setPropertyValue(sCreateFromTables, aAny);
     173             : 
     174           0 :     aAny.setValue(&bUseFrames, ::getBooleanCppuType());
     175           0 :     rIndexPropertySet->setPropertyValue(sCreateFromTextFrames, aAny);
     176             : 
     177           0 :     aAny.setValue(&bUseLevelParagraphStyles, ::getBooleanCppuType());
     178           0 :     rIndexPropertySet->setPropertyValue(sCreateFromLevelParagraphStyles, aAny);
     179             : 
     180           0 :     if( !sIndexName.isEmpty() )
     181             :     {
     182           0 :         aAny <<= sIndexName;
     183           0 :         rIndexPropertySet->setPropertyValue(sUserIndexName, aAny);
     184             :     }
     185             : 
     186           0 :     XMLIndexSourceBaseContext::EndElement();
     187           0 : }
     188             : 
     189             : 
     190           0 : SvXMLImportContext* XMLIndexUserSourceContext::CreateChildContext(
     191             :     sal_uInt16 nPrefix,
     192             :     const OUString& rLocalName,
     193             :     const Reference<XAttributeList> & xAttrList )
     194             : {
     195           0 :     if ( (XML_NAMESPACE_TEXT == nPrefix) &&
     196           0 :          (IsXMLToken(rLocalName, XML_USER_INDEX_ENTRY_TEMPLATE)) )
     197             :     {
     198           0 :         return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
     199             :                                            nPrefix, rLocalName,
     200             :                                            aSvLevelNameTOCMap,
     201             :                                            XML_OUTLINE_LEVEL,
     202             :                                            aLevelStylePropNameTOCMap,
     203           0 :                                            aAllowedTokenTypesUser);
     204             :     }
     205             :     else
     206             :     {
     207             :         return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
     208             :                                                              rLocalName,
     209           0 :                                                              xAttrList);
     210             :     }
     211             : 
     212             : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10