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 <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>
37 using namespace ::xmloff::token
;
40 using css::style::NumberingType::ARABIC
;
43 void XMLSectionFootnoteConfigExport::exportXML(
46 const vector
<XMLPropertyState
> *pProperties
,
48 const rtl::Reference
<XMLPropertySetMapper
> & rMapper
)
50 // store and initialize the values
52 bool bNumRestart
= false;
53 sal_Int16 nNumRestartAt
= 0;
54 sal_Int16 nNumberingType
= ARABIC
;
59 // find entries in property states vector
60 sal_uInt32 nCount
= pProperties
->size();
61 for(sal_uInt32 i
= 0; i
< nCount
; i
++)
63 const XMLPropertyState
& rState
= (*pProperties
)[i
];
65 sal_Int16 nContextId
= rMapper
->GetEntryContextId(rState
.mnIndex
);
70 case CTF_SECTION_FOOTNOTE_NUM_OWN
:
71 rState
.maValue
>>= bNumOwn
;
73 case CTF_SECTION_FOOTNOTE_NUM_RESTART
:
74 rState
.maValue
>>= bNumRestart
;
76 case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
:
77 rState
.maValue
>>= nNumRestartAt
;
79 case CTF_SECTION_FOOTNOTE_NUM_TYPE
:
80 rState
.maValue
>>= nNumberingType
;
82 case CTF_SECTION_FOOTNOTE_NUM_PREFIX
:
83 rState
.maValue
>>= sNumPrefix
;
85 case CTF_SECTION_FOOTNOTE_NUM_SUFFIX
:
86 rState
.maValue
>>= sNumSuffix
;
88 case CTF_SECTION_FOOTNOTE_END
:
89 SAL_WARN_IF( i
!= nIdx
, "xmloff",
90 "received wrong property state index" );
91 rState
.maValue
>>= bEnd
;
99 case CTF_SECTION_ENDNOTE_NUM_OWN
:
100 rState
.maValue
>>= bNumOwn
;
102 case CTF_SECTION_ENDNOTE_NUM_RESTART
:
103 rState
.maValue
>>= bNumRestart
;
105 case CTF_SECTION_ENDNOTE_NUM_RESTART_AT
:
106 rState
.maValue
>>= nNumRestartAt
;
108 case CTF_SECTION_ENDNOTE_NUM_TYPE
:
109 rState
.maValue
>>= nNumberingType
;
111 case CTF_SECTION_ENDNOTE_NUM_PREFIX
:
112 rState
.maValue
>>= sNumPrefix
;
114 case CTF_SECTION_ENDNOTE_NUM_SUFFIX
:
115 rState
.maValue
>>= sNumSuffix
;
117 case CTF_SECTION_ENDNOTE_END
:
118 SAL_WARN_IF( i
!= nIdx
, "xmloff",
119 "received wrong property state index" );
120 rState
.maValue
>>= bEnd
;
126 // we only make an element if we have an own footnote/endnote numbering
130 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
,
131 GetXMLToken( bEndnote
? XML_ENDNOTE
136 // restart number is stored as 0.., but interpreted as 1..
137 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_START_VALUE
,
138 OUString::number(nNumRestartAt
+1));
144 if (!sNumPrefix
.isEmpty())
146 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_PREFIX
,
149 if (!sNumSuffix
.isEmpty())
151 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_SUFFIX
,
155 // number type: num format
157 rExport
.GetMM100UnitConverter().convertNumFormat( sBuf
,
159 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
160 sBuf
.makeStringAndClear());
162 // and letter sync, if applicable
163 SvXMLUnitConverter::convertNumLetterSync(
164 sBuf
, nNumberingType
);
167 rExport
.AddAttribute(XML_NAMESPACE_STYLE
,
169 sBuf
.makeStringAndClear());
173 // and finally, the element
174 SvXMLElementExport
rElem(rExport
, XML_NAMESPACE_TEXT
,
175 XML_NOTES_CONFIGURATION
,
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */