Update ooo320-m1
[ooovba.git] / xmloff / source / text / XMLSectionFootnoteConfigExport.cxx
blobe3b54fa3ecec416df9d0b7362b00610a18b26c7c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLSectionFootnoteConfigExport.cxx,v $
10 * $Revision: 1.12 $
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>
41 #endif
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>
49 #ifndef _RTL_USTRING
50 #include <rtl/ustring.hxx>
51 #endif
52 #include <rtl/ustrbuf.hxx>
54 #include <vector>
57 using namespace ::xmloff::token;
59 using ::std::vector;
60 using ::rtl::OUString;
61 using ::rtl::OUStringBuffer;
62 using ::com::sun::star::style::NumberingType::ARABIC;
65 void XMLSectionFootnoteConfigExport::exportXML(
66 SvXMLExport& rExport,
67 sal_Bool bEndnote,
68 const vector<XMLPropertyState> *pProperties,
69 sal_uInt32
70 #ifdef DBG_UTIL
71 nIdx
72 #endif
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;
81 OUString sNumPrefix;
82 OUString sNumSuffix;
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);
92 if (!bEndnote)
94 switch (nContextId)
96 case CTF_SECTION_FOOTNOTE_NUM_OWN:
97 rState.maValue >>= bNumOwn;
98 break;
99 case CTF_SECTION_FOOTNOTE_NUM_RESTART:
100 rState.maValue >>= bNumRestart;
101 break;
102 case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT:
103 rState.maValue >>= nNumRestartAt;
104 break;
105 case CTF_SECTION_FOOTNOTE_NUM_TYPE:
106 rState.maValue >>= nNumberingType;
107 break;
108 case CTF_SECTION_FOOTNOTE_NUM_PREFIX:
109 rState.maValue >>= sNumPrefix;
110 break;
111 case CTF_SECTION_FOOTNOTE_NUM_SUFFIX:
112 rState.maValue >>= sNumSuffix;
113 break;
114 case CTF_SECTION_FOOTNOTE_END:
115 DBG_ASSERT( i == nIdx,
116 "received wrong property state index" );
117 rState.maValue >>= bEnd;
118 break;
121 else
123 switch (nContextId)
125 case CTF_SECTION_ENDNOTE_NUM_OWN:
126 rState.maValue >>= bNumOwn;
127 break;
128 case CTF_SECTION_ENDNOTE_NUM_RESTART:
129 rState.maValue >>= bNumRestart;
130 break;
131 case CTF_SECTION_ENDNOTE_NUM_RESTART_AT:
132 rState.maValue >>= nNumRestartAt;
133 break;
134 case CTF_SECTION_ENDNOTE_NUM_TYPE:
135 rState.maValue >>= nNumberingType;
136 break;
137 case CTF_SECTION_ENDNOTE_NUM_PREFIX:
138 rState.maValue >>= sNumPrefix;
139 break;
140 case CTF_SECTION_ENDNOTE_NUM_SUFFIX:
141 rState.maValue >>= sNumSuffix;
142 break;
143 case CTF_SECTION_ENDNOTE_END:
144 DBG_ASSERT( i == nIdx,
145 "received wrong property state index" );
146 rState.maValue >>= bEnd;
147 break;
152 // we only make an element if we have an own footnote/endnote numbering
153 if (bEnd)
155 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
156 GetXMLToken( bEndnote ? XML_ENDNOTE
157 : XML_FOOTNOTE ) );
158 // start numbering
159 OUStringBuffer sBuf;
160 if (bNumRestart)
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());
169 if (bNumOwn)
171 // prefix and suffix
172 if (sNumPrefix.getLength() > 0)
174 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX,
175 sNumPrefix);
177 if (sNumSuffix.getLength() > 0)
179 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX,
180 sNumSuffix);
183 // number type: num format
184 rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
185 nNumberingType );
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,
195 XML_NUM_LETTER_SYNC,
196 sBuf.makeStringAndClear());
200 // and finally, the element
201 SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT,
202 XML_NOTES_CONFIGURATION,
203 sal_True, sal_True);