1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLSectionFootnoteConfigExport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "XMLSectionFootnoteConfigExport.hxx"
34 #include <xmloff/xmlexp.hxx>
35 #include <xmloff/xmlprmap.hxx>
36 #include <com/sun/star/style/NumberingType.hpp>
37 #include <xmloff/maptype.hxx>
39 #ifndef _XMLOFF_TXTPRMAP_HXX
40 #include <xmloff/txtprmap.hxx>
42 #include <xmloff/nmspmap.hxx>
43 #include "xmlnmspe.hxx"
44 #include <xmloff/xmluconv.hxx>
45 #include <xmloff/xmltoken.hxx>
46 #include <xmloff/xmlnume.hxx>
47 #include <tools/debug.hxx>
50 #include <rtl/ustring.hxx>
52 #include <rtl/ustrbuf.hxx>
57 using namespace ::xmloff::token
;
60 using ::rtl::OUString
;
61 using ::rtl::OUStringBuffer
;
62 using ::com::sun::star::style::NumberingType::ARABIC
;
65 void XMLSectionFootnoteConfigExport::exportXML(
68 const vector
<XMLPropertyState
> *pProperties
,
74 const UniReference
<XMLPropertySetMapper
> & rMapper
)
76 // store and initialize the values
77 sal_Bool bNumOwn
= sal_False
;
78 sal_Bool bNumRestart
= sal_False
;
79 sal_Int16 nNumRestartAt
= 0;
80 sal_Int16 nNumberingType
= ARABIC
;
83 sal_Bool bEnd
= sal_False
;
85 // find entries in property states vector
86 sal_uInt32 nCount
= pProperties
->size();
87 for(sal_uInt32 i
= 0; i
< nCount
; i
++)
89 const XMLPropertyState
& rState
= (*pProperties
)[i
];
91 sal_Int16 nContextId
= rMapper
->GetEntryContextId(rState
.mnIndex
);
96 case CTF_SECTION_FOOTNOTE_NUM_OWN
:
97 rState
.maValue
>>= bNumOwn
;
99 case CTF_SECTION_FOOTNOTE_NUM_RESTART
:
100 rState
.maValue
>>= bNumRestart
;
102 case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT
:
103 rState
.maValue
>>= nNumRestartAt
;
105 case CTF_SECTION_FOOTNOTE_NUM_TYPE
:
106 rState
.maValue
>>= nNumberingType
;
108 case CTF_SECTION_FOOTNOTE_NUM_PREFIX
:
109 rState
.maValue
>>= sNumPrefix
;
111 case CTF_SECTION_FOOTNOTE_NUM_SUFFIX
:
112 rState
.maValue
>>= sNumSuffix
;
114 case CTF_SECTION_FOOTNOTE_END
:
115 DBG_ASSERT( i
== nIdx
,
116 "received wrong property state index" );
117 rState
.maValue
>>= bEnd
;
125 case CTF_SECTION_ENDNOTE_NUM_OWN
:
126 rState
.maValue
>>= bNumOwn
;
128 case CTF_SECTION_ENDNOTE_NUM_RESTART
:
129 rState
.maValue
>>= bNumRestart
;
131 case CTF_SECTION_ENDNOTE_NUM_RESTART_AT
:
132 rState
.maValue
>>= nNumRestartAt
;
134 case CTF_SECTION_ENDNOTE_NUM_TYPE
:
135 rState
.maValue
>>= nNumberingType
;
137 case CTF_SECTION_ENDNOTE_NUM_PREFIX
:
138 rState
.maValue
>>= sNumPrefix
;
140 case CTF_SECTION_ENDNOTE_NUM_SUFFIX
:
141 rState
.maValue
>>= sNumSuffix
;
143 case CTF_SECTION_ENDNOTE_END
:
144 DBG_ASSERT( i
== nIdx
,
145 "received wrong property state index" );
146 rState
.maValue
>>= bEnd
;
152 // we only make an element if we have an own footnote/endnote numbering
155 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_NOTE_CLASS
,
156 GetXMLToken( bEndnote
? XML_ENDNOTE
162 // restart number is stored as 0.., but interpreted as 1..
163 SvXMLUnitConverter::convertNumber(sBuf
,
164 (sal_Int32
)(nNumRestartAt
+1));
165 rExport
.AddAttribute(XML_NAMESPACE_TEXT
, XML_START_VALUE
,
166 sBuf
.makeStringAndClear());
172 if (sNumPrefix
.getLength() > 0)
174 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_PREFIX
,
177 if (sNumSuffix
.getLength() > 0)
179 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_SUFFIX
,
183 // number type: num format
184 rExport
.GetMM100UnitConverter().convertNumFormat( sBuf
,
186 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_NUM_FORMAT
,
187 sBuf
.makeStringAndClear());
189 // and letter sync, if applicable
190 rExport
.GetMM100UnitConverter().convertNumLetterSync(
191 sBuf
, nNumberingType
);
192 if (sBuf
.getLength())
194 rExport
.AddAttribute(XML_NAMESPACE_STYLE
,
196 sBuf
.makeStringAndClear());
200 // and finally, the element
201 SvXMLElementExport
rElem(rExport
, XML_NAMESPACE_TEXT
,
202 XML_NOTES_CONFIGURATION
,