tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / xmloff / source / text / XMLSectionFootnoteConfigExport.cxx
blobbf0d05825cc7f0dacc8d5ea17e16fad26375dbf9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "XMLSectionFootnoteConfigExport.hxx"
21 #include <xmloff/xmlexp.hxx>
22 #include <xmloff/xmlprmap.hxx>
23 #include <com/sun/star/style/NumberingType.hpp>
24 #include <xmloff/maptype.hxx>
26 #include <xmloff/txtprmap.hxx>
27 #include <xmloff/xmlnamespace.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>
35 using namespace ::xmloff::token;
37 using ::std::vector;
38 using css::style::NumberingType::ARABIC;
41 void XMLSectionFootnoteConfigExport::exportXML(
42 SvXMLExport& rExport,
43 bool bEndnote,
44 const vector<XMLPropertyState> *pProperties,
45 sal_uInt32 nIdx,
46 const rtl::Reference<XMLPropertySetMapper> & rMapper)
48 // store and initialize the values
49 bool bNumOwn = false;
50 bool bNumRestart = false;
51 sal_Int16 nNumRestartAt = 0;
52 sal_Int16 nNumberingType = ARABIC;
53 OUString sNumPrefix;
54 OUString sNumSuffix;
55 bool bEnd = false;
57 // find entries in property states vector
58 sal_uInt32 nCount = pProperties->size();
59 for(sal_uInt32 i = 0; i < nCount; i++)
61 const XMLPropertyState& rState = (*pProperties)[i];
63 sal_Int16 nContextId = rMapper->GetEntryContextId(rState.mnIndex);
64 if (!bEndnote)
66 switch (nContextId)
68 case CTF_SECTION_FOOTNOTE_NUM_OWN:
69 rState.maValue >>= bNumOwn;
70 break;
71 case CTF_SECTION_FOOTNOTE_NUM_RESTART:
72 rState.maValue >>= bNumRestart;
73 break;
74 case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT:
75 rState.maValue >>= nNumRestartAt;
76 break;
77 case CTF_SECTION_FOOTNOTE_NUM_TYPE:
78 rState.maValue >>= nNumberingType;
79 break;
80 case CTF_SECTION_FOOTNOTE_NUM_PREFIX:
81 rState.maValue >>= sNumPrefix;
82 break;
83 case CTF_SECTION_FOOTNOTE_NUM_SUFFIX:
84 rState.maValue >>= sNumSuffix;
85 break;
86 case CTF_SECTION_FOOTNOTE_END:
87 SAL_WARN_IF( i != nIdx, "xmloff",
88 "received wrong property state index" );
89 rState.maValue >>= bEnd;
90 break;
93 else
95 switch (nContextId)
97 case CTF_SECTION_ENDNOTE_NUM_OWN:
98 rState.maValue >>= bNumOwn;
99 break;
100 case CTF_SECTION_ENDNOTE_NUM_RESTART:
101 rState.maValue >>= bNumRestart;
102 break;
103 case CTF_SECTION_ENDNOTE_NUM_RESTART_AT:
104 rState.maValue >>= nNumRestartAt;
105 break;
106 case CTF_SECTION_ENDNOTE_NUM_TYPE:
107 rState.maValue >>= nNumberingType;
108 break;
109 case CTF_SECTION_ENDNOTE_NUM_PREFIX:
110 rState.maValue >>= sNumPrefix;
111 break;
112 case CTF_SECTION_ENDNOTE_NUM_SUFFIX:
113 rState.maValue >>= sNumSuffix;
114 break;
115 case CTF_SECTION_ENDNOTE_END:
116 SAL_WARN_IF( i != nIdx, "xmloff",
117 "received wrong property state index" );
118 rState.maValue >>= bEnd;
119 break;
124 // we only make an element if we have an own footnote/endnote numbering
125 if (!bEnd)
126 return;
128 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
129 GetXMLToken( bEndnote ? XML_ENDNOTE
130 : XML_FOOTNOTE ) );
131 // start numbering
132 if (bNumRestart)
134 // restart number is stored as 0.., but interpreted as 1..
135 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE,
136 OUString::number(nNumRestartAt+1));
139 if (bNumOwn)
141 // prefix and suffix
142 if (!sNumPrefix.isEmpty())
144 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX,
145 sNumPrefix);
147 if (!sNumSuffix.isEmpty())
149 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX,
150 sNumSuffix);
153 // number type: num format
154 OUStringBuffer sBuf;
155 rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
156 nNumberingType );
157 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
158 sBuf.makeStringAndClear());
160 // and letter sync, if applicable
161 SvXMLUnitConverter::convertNumLetterSync(
162 sBuf, nNumberingType );
163 if (!sBuf.isEmpty())
165 rExport.AddAttribute(XML_NAMESPACE_STYLE,
166 XML_NUM_LETTER_SYNC,
167 sBuf.makeStringAndClear());
171 // and finally, the element
172 SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT,
173 XML_NOTES_CONFIGURATION,
174 true, true);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */