LibreOffice Module xmloff (master) 1
XMLSectionFootnoteConfigImport.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
21
22#include <rtl/ustring.hxx>
23#include <com/sun/star/uno/Reference.h>
24#include <com/sun/star/xml/sax/XAttributeList.hpp>
25#include <com/sun/star/style/NumberingType.hpp>
26#include <sal/log.hxx>
28#include <utility>
29#include <xmloff/xmlimp.hxx>
30#include <xmloff/xmltoken.hxx>
31#include <xmloff/xmluconv.hxx>
32#include <xmloff/xmlprmap.hxx>
35#include <xmloff/maptype.hxx>
36#include <xmloff/txtprmap.hxx>
37
38#include <vector>
39
40
41using namespace ::xmloff::token;
42using namespace ::com::sun::star::style;
43
44using ::std::vector;
45using ::com::sun::star::uno::Any;
46using ::com::sun::star::uno::Reference;
47using ::com::sun::star::xml::sax::XAttributeList;
48
49
51 SvXMLImport& rImport,
52 sal_Int32 /*nElement*/,
53 vector<XMLPropertyState> & rProps,
55 SvXMLImportContext(rImport),
56 rProperties(rProps),
57 rMapper(std::move(xMapperRef))
58{
59}
60
62{
63}
64
66 sal_Int32 /*nElement*/,
67 const Reference<css::xml::sax::XFastAttributeList> & xAttrList)
68{
69 bool bNumOwn = false;
70 bool bNumRestart = false;
71 bool bEndnote = false;
72 sal_Int16 nNumRestartAt = 0;
73 OUString sNumPrefix;
74 OUString sNumSuffix;
75 OUString sNumFormat;
76 OUString sNumLetterSync;
77
78 // iterate over xattribute list and fill values
79 for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList))
80 {
81 switch(aIter.getToken())
82 {
84 {
85 sal_Int32 nTmp;
86 if (::sax::Converter::convertNumber(nTmp, aIter.toView()))
87 {
88 nNumRestartAt = static_cast< sal_Int16 >( nTmp ) - 1;
89 bNumRestart = true;
90 }
91 break;
92 }
94 {
95 if( IsXMLToken( aIter, XML_ENDNOTE ) )
96 bEndnote = true;
97 break;
98 }
100 {
101 sNumPrefix = aIter.toString();
102 bNumOwn = true;
103 break;
104 }
106 {
107 sNumSuffix = aIter.toString();
108 bNumOwn = true;
109 break;
110 }
112 {
113 sNumFormat = aIter.toString();
114 bNumOwn = true;
115 break;
116 }
118 {
119 sNumLetterSync = aIter.toString();
120 bNumOwn = true;
121 break;
122 }
123 default:
124 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
125 }
126 }
127
128 // OK, now we have all values and can fill the XMLPropertyState vector
129
130 sal_Int32 nIndex = rMapper->FindEntryIndex( bEndnote ?
132 XMLPropertyState aNumOwn( nIndex, css::uno::Any(bNumOwn) );
133 rProperties.push_back( aNumOwn );
134
135 nIndex = rMapper->FindEntryIndex( bEndnote ?
137 XMLPropertyState aNumRestart( nIndex, css::uno::Any(bNumRestart) );
138 rProperties.push_back( aNumRestart );
139
140 nIndex = rMapper->FindEntryIndex( bEndnote ?
143 XMLPropertyState aNumRestartAtState( nIndex, css::uno::Any(nNumRestartAt) );
144 rProperties.push_back( aNumRestartAtState );
145
146 sal_Int16 nNumType = NumberingType::ARABIC;
147 GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
148 sNumFormat,
149 sNumLetterSync );
150 nIndex = rMapper->FindEntryIndex( bEndnote ?
152 XMLPropertyState aNumFormatState( nIndex, css::uno::Any(nNumType) );
153 rProperties.push_back( aNumFormatState );
154
155 nIndex = rMapper->FindEntryIndex( bEndnote ?
157 XMLPropertyState aPrefixState( nIndex, css::uno::Any(sNumPrefix) );
158 rProperties.push_back( aPrefixState );
159
160 nIndex = rMapper->FindEntryIndex( bEndnote ?
162 XMLPropertyState aSuffixState( nIndex, css::uno::Any(sNumSuffix) );
163 rProperties.push_back( aSuffixState );
164
165 nIndex = rMapper->FindEntryIndex( bEndnote ?
167 XMLPropertyState aEndState( nIndex, css::uno::Any(true) ); // we're inside the element, so this is true
168 rProperties.push_back( aEndState );
169}
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
XMLSectionFootnoteConfigImport(SvXMLImport &rImport, sal_Int32 nElement, ::std::vector< XMLPropertyState > &rProperties, rtl::Reference< XMLPropertySetMapper > xMapperRef)
::std::vector< XMLPropertyState > & rProperties
rtl::Reference< XMLPropertySetMapper > rMapper
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
sal_Int32 nIndex
sal_Int16 nNumType
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3585
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:140
TEXT
#define CTF_SECTION_ENDNOTE_NUM_SUFFIX
Definition: txtprmap.hxx:127
#define CTF_SECTION_ENDNOTE_NUM_RESTART_AT
Definition: txtprmap.hxx:124
#define CTF_SECTION_FOOTNOTE_NUM_SUFFIX
Definition: txtprmap.hxx:120
#define CTF_SECTION_FOOTNOTE_NUM_OWN
Definition: txtprmap.hxx:121
#define CTF_SECTION_ENDNOTE_NUM_OWN
Definition: txtprmap.hxx:128
#define CTF_SECTION_ENDNOTE_NUM_RESTART
Definition: txtprmap.hxx:123
#define CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
Definition: txtprmap.hxx:117
#define CTF_SECTION_ENDNOTE_END
Definition: txtprmap.hxx:122
#define CTF_SECTION_ENDNOTE_NUM_TYPE
Definition: txtprmap.hxx:125
#define CTF_SECTION_FOOTNOTE_NUM_TYPE
Definition: txtprmap.hxx:118
#define CTF_SECTION_ENDNOTE_NUM_PREFIX
Definition: txtprmap.hxx:126
#define CTF_SECTION_FOOTNOTE_END
Definition: txtprmap.hxx:115
#define CTF_SECTION_FOOTNOTE_NUM_PREFIX
Definition: txtprmap.hxx:119
#define CTF_SECTION_FOOTNOTE_NUM_RESTART
Definition: txtprmap.hxx:116
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97