1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include "XMLSectionFootnoteConfigExport.hxx"
27cdf0e10cSrcweir #include <xmloff/xmlexp.hxx>
28cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx>
29cdf0e10cSrcweir #include <com/sun/star/style/NumberingType.hpp>
30cdf0e10cSrcweir #include <xmloff/maptype.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #ifndef _XMLOFF_TXTPRMAP_HXX
33cdf0e10cSrcweir #include <xmloff/txtprmap.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
36cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
37cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
38cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
39cdf0e10cSrcweir #include <xmloff/xmlnume.hxx>
40cdf0e10cSrcweir #include <tools/debug.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir #ifndef _RTL_USTRING
43cdf0e10cSrcweir #include <rtl/ustring.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include <vector>
48cdf0e10cSrcweir
49cdf0e10cSrcweir
50cdf0e10cSrcweir using namespace ::xmloff::token;
51cdf0e10cSrcweir
52cdf0e10cSrcweir using ::std::vector;
53cdf0e10cSrcweir using ::rtl::OUString;
54cdf0e10cSrcweir using ::rtl::OUStringBuffer;
55cdf0e10cSrcweir using ::com::sun::star::style::NumberingType::ARABIC;
56cdf0e10cSrcweir
57cdf0e10cSrcweir
exportXML(SvXMLExport & rExport,sal_Bool bEndnote,const vector<XMLPropertyState> * pProperties,sal_uInt32 nIdx,const UniReference<XMLPropertySetMapper> & rMapper)58cdf0e10cSrcweir void XMLSectionFootnoteConfigExport::exportXML(
59cdf0e10cSrcweir SvXMLExport& rExport,
60cdf0e10cSrcweir sal_Bool bEndnote,
61cdf0e10cSrcweir const vector<XMLPropertyState> *pProperties,
62cdf0e10cSrcweir sal_uInt32
63cdf0e10cSrcweir #ifdef DBG_UTIL
64cdf0e10cSrcweir nIdx
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir ,
67cdf0e10cSrcweir const UniReference<XMLPropertySetMapper> & rMapper)
68cdf0e10cSrcweir {
69cdf0e10cSrcweir // store and initialize the values
70cdf0e10cSrcweir sal_Bool bNumOwn = sal_False;
71cdf0e10cSrcweir sal_Bool bNumRestart = sal_False;
72cdf0e10cSrcweir sal_Int16 nNumRestartAt = 0;
73cdf0e10cSrcweir sal_Int16 nNumberingType = ARABIC;
74cdf0e10cSrcweir OUString sNumPrefix;
75cdf0e10cSrcweir OUString sNumSuffix;
76cdf0e10cSrcweir sal_Bool bEnd = sal_False;
77cdf0e10cSrcweir
78cdf0e10cSrcweir // find entries in property states vector
79cdf0e10cSrcweir sal_uInt32 nCount = pProperties->size();
80cdf0e10cSrcweir for(sal_uInt32 i = 0; i < nCount; i++)
81cdf0e10cSrcweir {
82cdf0e10cSrcweir const XMLPropertyState& rState = (*pProperties)[i];
83cdf0e10cSrcweir
84cdf0e10cSrcweir sal_Int16 nContextId = rMapper->GetEntryContextId(rState.mnIndex);
85cdf0e10cSrcweir if (!bEndnote)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir switch (nContextId)
88cdf0e10cSrcweir {
89cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_OWN:
90cdf0e10cSrcweir rState.maValue >>= bNumOwn;
91cdf0e10cSrcweir break;
92cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_RESTART:
93cdf0e10cSrcweir rState.maValue >>= bNumRestart;
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT:
96cdf0e10cSrcweir rState.maValue >>= nNumRestartAt;
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_TYPE:
99cdf0e10cSrcweir rState.maValue >>= nNumberingType;
100cdf0e10cSrcweir break;
101cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_PREFIX:
102cdf0e10cSrcweir rState.maValue >>= sNumPrefix;
103cdf0e10cSrcweir break;
104cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_SUFFIX:
105cdf0e10cSrcweir rState.maValue >>= sNumSuffix;
106cdf0e10cSrcweir break;
107cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_END:
108cdf0e10cSrcweir DBG_ASSERT( i == nIdx,
109cdf0e10cSrcweir "received wrong property state index" );
110cdf0e10cSrcweir rState.maValue >>= bEnd;
111cdf0e10cSrcweir break;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir else
115cdf0e10cSrcweir {
116cdf0e10cSrcweir switch (nContextId)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_OWN:
119cdf0e10cSrcweir rState.maValue >>= bNumOwn;
120cdf0e10cSrcweir break;
121cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_RESTART:
122cdf0e10cSrcweir rState.maValue >>= bNumRestart;
123cdf0e10cSrcweir break;
124cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_RESTART_AT:
125cdf0e10cSrcweir rState.maValue >>= nNumRestartAt;
126cdf0e10cSrcweir break;
127cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_TYPE:
128cdf0e10cSrcweir rState.maValue >>= nNumberingType;
129cdf0e10cSrcweir break;
130cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_PREFIX:
131cdf0e10cSrcweir rState.maValue >>= sNumPrefix;
132cdf0e10cSrcweir break;
133cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_SUFFIX:
134cdf0e10cSrcweir rState.maValue >>= sNumSuffix;
135cdf0e10cSrcweir break;
136cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_END:
137cdf0e10cSrcweir DBG_ASSERT( i == nIdx,
138cdf0e10cSrcweir "received wrong property state index" );
139cdf0e10cSrcweir rState.maValue >>= bEnd;
140cdf0e10cSrcweir break;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir }
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir // we only make an element if we have an own footnote/endnote numbering
146cdf0e10cSrcweir if (bEnd)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
149cdf0e10cSrcweir GetXMLToken( bEndnote ? XML_ENDNOTE
150cdf0e10cSrcweir : XML_FOOTNOTE ) );
151cdf0e10cSrcweir // start numbering
152cdf0e10cSrcweir OUStringBuffer sBuf;
153cdf0e10cSrcweir if (bNumRestart)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir // restart number is stored as 0.., but interpreted as 1..
156cdf0e10cSrcweir SvXMLUnitConverter::convertNumber(sBuf,
157cdf0e10cSrcweir (sal_Int32)(nNumRestartAt+1));
158cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE,
159cdf0e10cSrcweir sBuf.makeStringAndClear());
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir if (bNumOwn)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir // prefix and suffix
165cdf0e10cSrcweir if (sNumPrefix.getLength() > 0)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX,
168cdf0e10cSrcweir sNumPrefix);
169cdf0e10cSrcweir }
170cdf0e10cSrcweir if (sNumSuffix.getLength() > 0)
171cdf0e10cSrcweir {
172cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX,
173cdf0e10cSrcweir sNumSuffix);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir // number type: num format
177cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
178cdf0e10cSrcweir nNumberingType );
179cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
180cdf0e10cSrcweir sBuf.makeStringAndClear());
181cdf0e10cSrcweir
182cdf0e10cSrcweir // and letter sync, if applicable
183cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertNumLetterSync(
184cdf0e10cSrcweir sBuf, nNumberingType );
185cdf0e10cSrcweir if (sBuf.getLength())
186cdf0e10cSrcweir {
187cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE,
188cdf0e10cSrcweir XML_NUM_LETTER_SYNC,
189cdf0e10cSrcweir sBuf.makeStringAndClear());
190cdf0e10cSrcweir }
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir // and finally, the element
194cdf0e10cSrcweir SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT,
195cdf0e10cSrcweir XML_NOTES_CONFIGURATION,
196cdf0e10cSrcweir sal_True, sal_True);
197cdf0e10cSrcweir }
198cdf0e10cSrcweir }
199