LibreOffice Module xmloff (master) 1
XMLIndexBibliographyEntryContext.cxx
Go to the documentation of this file.
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
22#include <xmloff/xmlimp.hxx>
23#include <xmloff/txtimp.hxx>
26#include <xmloff/xmltoken.hxx>
27#include <xmloff/xmluconv.hxx>
28#include <xmloff/xmlement.hxx>
29#include <com/sun/star/text/BibliographyDataField.hpp>
30#include <sal/log.hxx>
31
32
33using namespace ::com::sun::star::text;
34using namespace ::xmloff::token;
35
36using ::com::sun::star::beans::PropertyValue;
37using ::com::sun::star::uno::Reference;
38using ::com::sun::star::uno::Sequence;
39
40
42 SvXMLImport& rImport,
43 XMLIndexTemplateContext& rTemplate ) :
45 "TokenBibliographyDataField",
46 rTemplate),
47 nBibliographyInfo(BibliographyDataField::IDENTIFIER),
48 bBibliographyInfoOK(false)
49{
50}
51
53{
54}
55
57{
58 { XML_ADDRESS, BibliographyDataField::ADDRESS },
59 { XML_ANNOTE, BibliographyDataField::ANNOTE },
60 { XML_AUTHOR, BibliographyDataField::AUTHOR },
61 { XML_BIBLIOGRAPHY_TYPE, BibliographyDataField::BIBILIOGRAPHIC_TYPE },
62 // #96658#: also read old documents (bib*i*liographic...)
63 { XML_BIBILIOGRAPHIC_TYPE, BibliographyDataField::BIBILIOGRAPHIC_TYPE },
64 { XML_BOOKTITLE, BibliographyDataField::BOOKTITLE },
65 { XML_CHAPTER, BibliographyDataField::CHAPTER },
66 { XML_CUSTOM1, BibliographyDataField::CUSTOM1 },
67 { XML_CUSTOM2, BibliographyDataField::CUSTOM2 },
68 { XML_CUSTOM3, BibliographyDataField::CUSTOM3 },
69 { XML_CUSTOM4, BibliographyDataField::CUSTOM4 },
70 { XML_CUSTOM5, BibliographyDataField::CUSTOM5 },
71 { XML_EDITION, BibliographyDataField::EDITION },
72 { XML_EDITOR, BibliographyDataField::EDITOR },
73 { XML_HOWPUBLISHED, BibliographyDataField::HOWPUBLISHED },
74 { XML_IDENTIFIER, BibliographyDataField::IDENTIFIER },
75 { XML_INSTITUTION, BibliographyDataField::INSTITUTION },
76 { XML_ISBN, BibliographyDataField::ISBN },
77 { XML_JOURNAL, BibliographyDataField::JOURNAL },
78 { XML_MONTH, BibliographyDataField::MONTH },
79 { XML_NOTE, BibliographyDataField::NOTE },
80 { XML_NUMBER, BibliographyDataField::NUMBER },
81 { XML_ORGANIZATIONS, BibliographyDataField::ORGANIZATIONS },
82 { XML_PAGES, BibliographyDataField::PAGES },
83 { XML_PUBLISHER, BibliographyDataField::PUBLISHER },
84 { XML_REPORT_TYPE, BibliographyDataField::REPORT_TYPE },
85 { XML_SCHOOL, BibliographyDataField::SCHOOL },
86 { XML_SERIES, BibliographyDataField::SERIES },
87 { XML_TITLE, BibliographyDataField::TITLE },
88 { XML_URL, BibliographyDataField::URL },
89 { XML_VOLUME, BibliographyDataField::VOLUME },
90 { XML_YEAR, BibliographyDataField::YEAR },
92};
93
95 sal_Int32 /*nElement*/,
96 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
97{
98 // handle both, style name and bibliography info
99 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
100 {
101 switch(aIter.getToken())
102 {
104 {
105 m_sCharStyleName = aIter.toString();
106 m_bCharStyleNameOK = true;
107 break;
108 }
110 {
111 sal_uInt16 nTmp;
113 {
114 nBibliographyInfo = nTmp;
115 bBibliographyInfoOK = true;
116 }
117 break;
118 }
119 default:
120 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
121 }
122 }
123
124 // if we have a style name, set it!
126 {
127 m_nValues++;
128 }
129
130 // always bibliography; else element is not valid
131 m_nValues++;
132}
133
135{
136 // only valid, if we have bibliography info
138 {
140 }
141}
142
144 css::uno::Sequence<css::beans::PropertyValue> & rValues)
145{
146 // entry name and (optionally) style name in parent class
148
149 // bibliography data field
150 sal_Int32 nIndex = m_bCharStyleNameOK ? 2 : 1;
151 auto pValues = rValues.getArray();
152 pValues[nIndex].Name = "BibliographyDataField";
154}
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
const SvXMLEnumMapEntry< sal_uInt16 > aBibliographyDataFieldMap[]
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
XMLIndexBibliographyEntryContext(SvXMLImport &rImport, XMLIndexTemplateContext &rTemplate)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
process parameters
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
call FillPropertyValues and insert into template
virtual void FillPropertyValues(css::uno::Sequence< css::beans::PropertyValue > &rValues) override
fill property values for this template entry
Import index entry templates.
virtual void FillPropertyValues(css::uno::Sequence< css::beans::PropertyValue > &rValues)
fill property values for this template entry
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
call FillPropertyValues and insert into template
Import index entry templates.
sal_Int32 nIndex
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_BIBLIOGRAPHY_DATA_FIELD
Definition: xmltoken.hxx:329
@ XML_BIBLIOGRAPHY_TYPE
Definition: xmltoken.hxx:333
@ XML_BIBILIOGRAPHIC_TYPE
Definition: xmltoken.hxx:326
TEXT
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97