LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLIndexBibliographyEntryContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 40 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 "XMLIndexBibliographyEntryContext.hxx"
      21             : #include "XMLIndexTemplateContext.hxx"
      22             : #include <xmloff/xmlictxt.hxx>
      23             : #include <xmloff/xmlimp.hxx>
      24             : #include <xmloff/txtimp.hxx>
      25             : #include <xmloff/nmspmap.hxx>
      26             : #include <xmloff/xmlnmspe.hxx>
      27             : #include <xmloff/xmltoken.hxx>
      28             : #include <xmloff/xmluconv.hxx>
      29             : #include <com/sun/star/text/BibliographyDataField.hpp>
      30             : 
      31             : 
      32             : using namespace ::com::sun::star::text;
      33             : using namespace ::xmloff::token;
      34             : 
      35             : using ::com::sun::star::beans::PropertyValue;
      36             : using ::com::sun::star::beans::PropertyValues;
      37             : using ::com::sun::star::uno::Reference;
      38             : using ::com::sun::star::uno::Sequence;
      39             : using ::com::sun::star::uno::Any;
      40             : using ::com::sun::star::xml::sax::XAttributeList;
      41             : 
      42           0 : TYPEINIT1( XMLIndexBibliographyEntryContext, XMLIndexSimpleEntryContext);
      43             : 
      44           0 : XMLIndexBibliographyEntryContext::XMLIndexBibliographyEntryContext(
      45             :     SvXMLImport& rImport,
      46             :     XMLIndexTemplateContext& rTemplate,
      47             :     sal_uInt16 nPrfx,
      48             :     const OUString& rLocalName ) :
      49             :         XMLIndexSimpleEntryContext(rImport,
      50             :                                    rTemplate.sTokenBibliographyDataField,
      51             :                                    rTemplate,
      52             :                                    nPrfx, rLocalName),
      53             :         nBibliographyInfo(BibliographyDataField::IDENTIFIER),
      54           0 :         bBibliographyInfoOK(sal_False)
      55             : {
      56           0 : }
      57             : 
      58           0 : XMLIndexBibliographyEntryContext::~XMLIndexBibliographyEntryContext()
      59             : {
      60           0 : }
      61             : 
      62             : const SvXMLEnumMapEntry aBibliographyDataFieldMap[] =
      63             : {
      64             :     { XML_ADDRESS,              BibliographyDataField::ADDRESS },
      65             :     { XML_ANNOTE,               BibliographyDataField::ANNOTE },
      66             :     { XML_AUTHOR,               BibliographyDataField::AUTHOR },
      67             :     { XML_BIBLIOGRAPHY_TYPE,    BibliographyDataField::BIBILIOGRAPHIC_TYPE },
      68             :     // #96658#: also read old documents (bib*i*liographic...)
      69             :     { XML_BIBILIOGRAPHIC_TYPE,  BibliographyDataField::BIBILIOGRAPHIC_TYPE },
      70             :     { XML_BOOKTITLE,            BibliographyDataField::BOOKTITLE },
      71             :     { XML_CHAPTER,              BibliographyDataField::CHAPTER },
      72             :     { XML_CUSTOM1,              BibliographyDataField::CUSTOM1 },
      73             :     { XML_CUSTOM2,              BibliographyDataField::CUSTOM2 },
      74             :     { XML_CUSTOM3,              BibliographyDataField::CUSTOM3 },
      75             :     { XML_CUSTOM4,              BibliographyDataField::CUSTOM4 },
      76             :     { XML_CUSTOM5,              BibliographyDataField::CUSTOM5 },
      77             :     { XML_EDITION,              BibliographyDataField::EDITION },
      78             :     { XML_EDITOR,               BibliographyDataField::EDITOR },
      79             :     { XML_HOWPUBLISHED,         BibliographyDataField::HOWPUBLISHED },
      80             :     { XML_IDENTIFIER,           BibliographyDataField::IDENTIFIER },
      81             :     { XML_INSTITUTION,          BibliographyDataField::INSTITUTION },
      82             :     { XML_ISBN,                 BibliographyDataField::ISBN },
      83             :     { XML_JOURNAL,              BibliographyDataField::JOURNAL },
      84             :     { XML_MONTH,                BibliographyDataField::MONTH },
      85             :     { XML_NOTE,                 BibliographyDataField::NOTE },
      86             :     { XML_NUMBER,               BibliographyDataField::NUMBER },
      87             :     { XML_ORGANIZATIONS,        BibliographyDataField::ORGANIZATIONS },
      88             :     { XML_PAGES,                BibliographyDataField::PAGES },
      89             :     { XML_PUBLISHER,            BibliographyDataField::PUBLISHER },
      90             :     { XML_REPORT_TYPE,          BibliographyDataField::REPORT_TYPE },
      91             :     { XML_SCHOOL,               BibliographyDataField::SCHOOL },
      92             :     { XML_SERIES,               BibliographyDataField::SERIES },
      93             :     { XML_TITLE,                BibliographyDataField::TITLE },
      94             :     { XML_URL,                  BibliographyDataField::URL },
      95             :     { XML_VOLUME,               BibliographyDataField::VOLUME },
      96             :     { XML_YEAR,                 BibliographyDataField::YEAR },
      97             :     { XML_TOKEN_INVALID, 0 }
      98             : };
      99             : 
     100           0 : void XMLIndexBibliographyEntryContext::StartElement(
     101             :     const Reference<XAttributeList> & xAttrList)
     102             : {
     103             :     // handle both, style name and bibliography info
     104           0 :     sal_Int16 nLength = xAttrList->getLength();
     105           0 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
     106             :     {
     107           0 :         OUString sLocalName;
     108           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
     109           0 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
     110           0 :                               &sLocalName );
     111           0 :         if (XML_NAMESPACE_TEXT == nPrefix)
     112             :         {
     113           0 :             if ( IsXMLToken( sLocalName, XML_STYLE_NAME ) )
     114             :             {
     115           0 :                 sCharStyleName = xAttrList->getValueByIndex(nAttr);
     116           0 :                 bCharStyleNameOK = sal_True;
     117             :             }
     118           0 :             else if ( IsXMLToken( sLocalName, XML_BIBLIOGRAPHY_DATA_FIELD ) )
     119             :             {
     120             :                 sal_uInt16 nTmp;
     121           0 :                 if (SvXMLUnitConverter::convertEnum(
     122           0 :                     nTmp, xAttrList->getValueByIndex(nAttr),
     123           0 :                     aBibliographyDataFieldMap))
     124             :                 {
     125           0 :                     nBibliographyInfo = nTmp;
     126           0 :                     bBibliographyInfoOK = sal_True;
     127             :                 }
     128             :             }
     129             :         }
     130           0 :     }
     131             : 
     132             :     // if we have a style name, set it!
     133           0 :     if (bCharStyleNameOK)
     134             :     {
     135           0 :         nValues++;
     136             :     }
     137             : 
     138             :     // always bibliography; else element is not valid
     139           0 :     nValues++;
     140           0 : }
     141             : 
     142           0 : void XMLIndexBibliographyEntryContext::EndElement()
     143             : {
     144             :     // only valid, if we have bibliography info
     145           0 :     if (bBibliographyInfoOK)
     146             :     {
     147           0 :         XMLIndexSimpleEntryContext::EndElement();
     148             :     }
     149           0 : }
     150             : 
     151           0 : void XMLIndexBibliographyEntryContext::FillPropertyValues(
     152             :     ::com::sun::star::uno::Sequence<
     153             :         ::com::sun::star::beans::PropertyValue> & rValues)
     154             : {
     155             :     // entry name and (optionally) style name in parent class
     156           0 :     XMLIndexSimpleEntryContext::FillPropertyValues(rValues);
     157             : 
     158             :     // bibliography data field
     159           0 :     sal_Int32 nIndex = bCharStyleNameOK ? 2 : 1;
     160           0 :     rValues[nIndex].Name = rTemplateContext.sBibliographyDataField;
     161           0 :     Any aAny;
     162           0 :     aAny <<= nBibliographyInfo;
     163           0 :     rValues[nIndex].Value = aAny;
     164           0 : }
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10