LibreOffice Module xmloff (master) 1
XMLSectionFootnoteConfigExport.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#include <xmloff/xmlexp.hxx>
22#include <xmloff/xmlprmap.hxx>
23#include <com/sun/star/style/NumberingType.hpp>
24#include <xmloff/maptype.hxx>
25
26#include <xmloff/txtprmap.hxx>
28#include <xmloff/xmluconv.hxx>
29#include <xmloff/xmltoken.hxx>
30#include <rtl/ustring.hxx>
31#include <rtl/ustrbuf.hxx>
32#include <sal/log.hxx>
33
34#include <vector>
35
36
37using namespace ::xmloff::token;
38
39using ::std::vector;
40using css::style::NumberingType::ARABIC;
41
42
44 SvXMLExport& rExport,
45 bool bEndnote,
46 const vector<XMLPropertyState> *pProperties,
47 sal_uInt32 nIdx,
49{
50 // store and initialize the values
51 bool bNumOwn = false;
52 bool bNumRestart = false;
53 sal_Int16 nNumRestartAt = 0;
54 sal_Int16 nNumberingType = ARABIC;
55 OUString sNumPrefix;
56 OUString sNumSuffix;
57 bool bEnd = false;
58
59 // find entries in property states vector
60 sal_uInt32 nCount = pProperties->size();
61 for(sal_uInt32 i = 0; i < nCount; i++)
62 {
63 const XMLPropertyState& rState = (*pProperties)[i];
64
65 sal_Int16 nContextId = rMapper->GetEntryContextId(rState.mnIndex);
66 if (!bEndnote)
67 {
68 switch (nContextId)
69 {
71 rState.maValue >>= bNumOwn;
72 break;
74 rState.maValue >>= bNumRestart;
75 break;
77 rState.maValue >>= nNumRestartAt;
78 break;
80 rState.maValue >>= nNumberingType;
81 break;
83 rState.maValue >>= sNumPrefix;
84 break;
86 rState.maValue >>= sNumSuffix;
87 break;
89 SAL_WARN_IF( i != nIdx, "xmloff",
90 "received wrong property state index" );
91 rState.maValue >>= bEnd;
92 break;
93 }
94 }
95 else
96 {
97 switch (nContextId)
98 {
100 rState.maValue >>= bNumOwn;
101 break;
103 rState.maValue >>= bNumRestart;
104 break;
106 rState.maValue >>= nNumRestartAt;
107 break;
109 rState.maValue >>= nNumberingType;
110 break;
112 rState.maValue >>= sNumPrefix;
113 break;
115 rState.maValue >>= sNumSuffix;
116 break;
118 SAL_WARN_IF( i != nIdx, "xmloff",
119 "received wrong property state index" );
120 rState.maValue >>= bEnd;
121 break;
122 }
123 }
124 }
125
126 // we only make an element if we have an own footnote/endnote numbering
127 if (!bEnd)
128 return;
129
131 GetXMLToken( bEndnote ? XML_ENDNOTE
132 : XML_FOOTNOTE ) );
133 // start numbering
134 if (bNumRestart)
135 {
136 // restart number is stored as 0.., but interpreted as 1..
138 OUString::number(nNumRestartAt+1));
139 }
140
141 if (bNumOwn)
142 {
143 // prefix and suffix
144 if (!sNumPrefix.isEmpty())
145 {
147 sNumPrefix);
148 }
149 if (!sNumSuffix.isEmpty())
150 {
152 sNumSuffix);
153 }
154
155 // number type: num format
156 OUStringBuffer sBuf;
158 nNumberingType );
160 sBuf.makeStringAndClear());
161
162 // and letter sync, if applicable
164 sBuf, nNumberingType );
165 if (!sBuf.isEmpty())
166 {
169 sBuf.makeStringAndClear());
170 }
171 }
172
173 // and finally, the element
176 true, true);
177}
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:907
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:391
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, std::u16string_view rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
Definition: xmluconv.cxx:655
static void convertNumLetterSync(OUStringBuffer &rBuffer, sal_Int16 nType)
Definition: xmluconv.cxx:752
static void exportXML(SvXMLExport &rExport, bool bEndnote, const ::std::vector< XMLPropertyState > *pProperties, sal_uInt32 nIdx, const rtl::Reference< XMLPropertySetMapper > &rMapper)
int nCount
#define SAL_WARN_IF(condition, area, stream)
int i
ARABIC
Handling of tokens in XML:
@ XML_NOTES_CONFIGURATION
Definition: xmltoken.hxx:2624
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3541
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:140
css::uno::Any maValue
Definition: maptype.hxx:142
sal_Int32 mnIndex
Definition: maptype.hxx:141
#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
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE