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>
27 #include <xmloff/xmlnmspe.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 
37 using namespace ::xmloff::token;
38 
39 using ::std::vector;
40 using css::style::NumberingType::ARABIC;
41 
42 
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  {
130  GetXMLToken( bEndnote ? XML_ENDNOTE
131  : XML_FOOTNOTE ) );
132  // start numbering
133  OUStringBuffer sBuf;
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  rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
157  nNumberingType );
159  sBuf.makeStringAndClear());
160 
161  // and letter sync, if applicable
163  sBuf, nNumberingType );
164  if (!sBuf.isEmpty())
165  {
168  sBuf.makeStringAndClear());
169  }
170  }
171 
172  // and finally, the element
173  SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT,
175  true, true);
176  }
177 }
178 
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:30
#define CTF_SECTION_FOOTNOTE_NUM_PREFIX
Definition: txtprmap.hxx:119
ARABIC
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, const OUString &rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
Definition: xmluconv.cxx:574
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:395
#define CTF_SECTION_ENDNOTE_NUM_RESTART
Definition: txtprmap.hxx:123
sal_Int32 mnIndex
Definition: maptype.hxx:106
#define CTF_SECTION_ENDNOTE_NUM_TYPE
Definition: txtprmap.hxx:125
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Definition: xmlnmspe.hxx:31
#define CTF_SECTION_ENDNOTE_NUM_PREFIX
Definition: txtprmap.hxx:126
#define CTF_SECTION_ENDNOTE_END
Definition: txtprmap.hxx:122
int nCount
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:926
int i
#define CTF_SECTION_FOOTNOTE_NUM_TYPE
Definition: txtprmap.hxx:118
#define CTF_SECTION_ENDNOTE_NUM_SUFFIX
Definition: txtprmap.hxx:127
#define CTF_SECTION_FOOTNOTE_NUM_RESTART
Definition: txtprmap.hxx:116
#define CTF_SECTION_FOOTNOTE_NUM_SUFFIX
Definition: txtprmap.hxx:120
#define CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
Definition: txtprmap.hxx:117
#define CTF_SECTION_FOOTNOTE_NUM_OWN
Definition: txtprmap.hxx:121
static void convertNumLetterSync(OUStringBuffer &rBuffer, sal_Int16 nType)
Definition: xmluconv.cxx:671
css::uno::Any maValue
Definition: maptype.hxx:107
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3366
Handling of tokens in XML:
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:104
#define CTF_SECTION_ENDNOTE_NUM_RESTART_AT
Definition: txtprmap.hxx:124
static void exportXML(SvXMLExport &rExport, bool bEndnote, const ::std::vector< XMLPropertyState > *pProperties, sal_uInt32 nIdx, const rtl::Reference< XMLPropertySetMapper > &rMapper)
#define CTF_SECTION_ENDNOTE_NUM_OWN
Definition: txtprmap.hxx:128
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
#define CTF_SECTION_FOOTNOTE_END
Definition: txtprmap.hxx:115