1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <sax/tools/converter.hxx>
25 #include <xmloff/maptype.hxx>
27 #include <xmloff/txtprmap.hxx>
28 #include <xmloff/nmspmap.hxx>
29 #include <xmloff/xmlnmspe.hxx>
30 #include <xmloff/xmluconv.hxx>
31 #include <xmloff/xmltoken.hxx>
32 #include <xmloff/xmlnume.hxx>
33 #include <tools/debug.hxx>
34 #include <rtl/ustring.hxx>
35 #include <rtl/ustrbuf.hxx>
40 using namespace ::xmloff::token
;
43 using ::com::sun::star::style::NumberingType::ARABIC
;
46 void XMLSectionFootnoteConfigExport::exportXML(
49 const vector
<XMLPropertyState
> *pProperties
,
55 const rtl::Reference
<XMLPropertySetMapper
> & rMapper
)
57 // store and initialize the values
59 bool bNumRestart
= false;
60 sal_Int16 nNumRestartAt
= 0;
61 sal_Int16 nNumberingType
= ARABIC
;
66 // find entries in property states vector
67 sal_uInt32 nCount
= pProperties
->size();
68 for(sal_uInt32 i
= 0; i
< nCount
; i
++)
70 const XMLPropertyState
& rState
= (*pProperties
)[i
];
72 sal_Int16 nContextId
= rMapper
->GetEntryContextId(rState
.mnIndex
);
77 case CTF_SECTION_FOOTNOTE_NUM_OWN
:
78 rState
.maValue
>>= bNumOwn
;
80 case CTF_SECTION_FOOTNOTE_NUM_RESTART
:
81 rState
.maValue
>>= bNumRestart
;
83 case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
:
84 rState
.maValue
>>= nNumRestartAt
;
86 case CTF_SECTION_FOOTNOTE_NUM_TYPE
:
87 rState
.maValue
>>= nNumberingType
;
89 case CTF_SECTION_FOOTNOTE_NUM_PREFIX
:
90 rState
.maValue
>>= sNumPrefix
;
92 case CTF_SECTION_FOOTNOTE_NUM_SUFFIX
:
93 rState
.maValue
>>= sNumSuffix
;
95 case CTF_SECTION_FOOTNOTE_END
:
96 DBG_ASSERT( i
== nIdx
,
97 "received wrong property state index" );
98 rState
.maValue
>>= bEnd
;
106 case CTF_SECTION_ENDNOTE_NUM_OWN
:
107 rState
.maValue
>>= bNumOwn
;
109 case CTF_SECTION_ENDNOTE_NUM_RESTART
:
110 rState
.maValue
>>= bNumRestart
;
112 case CTF_SECTION_ENDNOTE_NUM_RESTART_AT
:
113 rState
.maValue
>>= nNumRestartAt
;
115 case CTF_SECTION_ENDNOTE_NUM_TYPE
:
116 rState
.maValue
>>= nNumberingType
;
118 case CTF_SECTION_ENDNOTE_NUM_PREFIX
:
119 rState
.maValue
>>= sNumPrefix
;
121 case CTF_SECTION_ENDNOTE_NUM_SUFFIX
:
122 rState
.maValue
>>= sNumSuffix
;
124 case CTF_SECTION_ENDNOTE_END
:
125 DBG_ASSERT( i
== nIdx
,
126 "received wrong property state index" );
127 rState
.maValue
>>= bEnd
;
133 // we only make an element if we have an own footnote/endnote numbering
136 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
,
137 GetXMLToken( bEndnote
? XML_ENDNOTE
143 // restart number is stored as 0.., but interpreted as 1..
144 ::sax::Converter::convertNumber(sBuf
,
145 (sal_Int32
)(nNumRestartAt
+1));
146 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_START_VALUE
,
147 sBuf
.makeStringAndClear());
153 if (!sNumPrefix
.isEmpty())
155 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_PREFIX
,
158 if (!sNumSuffix
.isEmpty())
160 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_SUFFIX
,
164 // number type: num format
165 rExport
.GetMM100UnitConverter().convertNumFormat( sBuf
,
167 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
168 sBuf
.makeStringAndClear());
170 // and letter sync, if applicable
171 SvXMLUnitConverter::convertNumLetterSync(
172 sBuf
, nNumberingType
);
175 rExport
.AddAttribute(XML_NAMESPACE_STYLE
,
177 sBuf
.makeStringAndClear());
181 // and finally, the element
182 SvXMLElementExport
rElem(rExport
, XML_NAMESPACE_TEXT
,
183 XML_NOTES_CONFIGURATION
,
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */