1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 30*cdf0e10cSrcweir #include "XMLSectionFootnoteConfigExport.hxx" 31*cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 32*cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx> 33*cdf0e10cSrcweir #include <com/sun/star/style/NumberingType.hpp> 34*cdf0e10cSrcweir #include <xmloff/maptype.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #ifndef _XMLOFF_TXTPRMAP_HXX 37*cdf0e10cSrcweir #include <xmloff/txtprmap.hxx> 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 40*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 41*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 42*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 43*cdf0e10cSrcweir #include <xmloff/xmlnume.hxx> 44*cdf0e10cSrcweir #include <tools/debug.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #ifndef _RTL_USTRING 47*cdf0e10cSrcweir #include <rtl/ustring.hxx> 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include <vector> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir using namespace ::xmloff::token; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir using ::std::vector; 57*cdf0e10cSrcweir using ::rtl::OUString; 58*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 59*cdf0e10cSrcweir using ::com::sun::star::style::NumberingType::ARABIC; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir void XMLSectionFootnoteConfigExport::exportXML( 63*cdf0e10cSrcweir SvXMLExport& rExport, 64*cdf0e10cSrcweir sal_Bool bEndnote, 65*cdf0e10cSrcweir const vector<XMLPropertyState> *pProperties, 66*cdf0e10cSrcweir sal_uInt32 67*cdf0e10cSrcweir #ifdef DBG_UTIL 68*cdf0e10cSrcweir nIdx 69*cdf0e10cSrcweir #endif 70*cdf0e10cSrcweir , 71*cdf0e10cSrcweir const UniReference<XMLPropertySetMapper> & rMapper) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir // store and initialize the values 74*cdf0e10cSrcweir sal_Bool bNumOwn = sal_False; 75*cdf0e10cSrcweir sal_Bool bNumRestart = sal_False; 76*cdf0e10cSrcweir sal_Int16 nNumRestartAt = 0; 77*cdf0e10cSrcweir sal_Int16 nNumberingType = ARABIC; 78*cdf0e10cSrcweir OUString sNumPrefix; 79*cdf0e10cSrcweir OUString sNumSuffix; 80*cdf0e10cSrcweir sal_Bool bEnd = sal_False; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir // find entries in property states vector 83*cdf0e10cSrcweir sal_uInt32 nCount = pProperties->size(); 84*cdf0e10cSrcweir for(sal_uInt32 i = 0; i < nCount; i++) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir const XMLPropertyState& rState = (*pProperties)[i]; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir sal_Int16 nContextId = rMapper->GetEntryContextId(rState.mnIndex); 89*cdf0e10cSrcweir if (!bEndnote) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir switch (nContextId) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_OWN: 94*cdf0e10cSrcweir rState.maValue >>= bNumOwn; 95*cdf0e10cSrcweir break; 96*cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_RESTART: 97*cdf0e10cSrcweir rState.maValue >>= bNumRestart; 98*cdf0e10cSrcweir break; 99*cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT: 100*cdf0e10cSrcweir rState.maValue >>= nNumRestartAt; 101*cdf0e10cSrcweir break; 102*cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_TYPE: 103*cdf0e10cSrcweir rState.maValue >>= nNumberingType; 104*cdf0e10cSrcweir break; 105*cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_PREFIX: 106*cdf0e10cSrcweir rState.maValue >>= sNumPrefix; 107*cdf0e10cSrcweir break; 108*cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_NUM_SUFFIX: 109*cdf0e10cSrcweir rState.maValue >>= sNumSuffix; 110*cdf0e10cSrcweir break; 111*cdf0e10cSrcweir case CTF_SECTION_FOOTNOTE_END: 112*cdf0e10cSrcweir DBG_ASSERT( i == nIdx, 113*cdf0e10cSrcweir "received wrong property state index" ); 114*cdf0e10cSrcweir rState.maValue >>= bEnd; 115*cdf0e10cSrcweir break; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir else 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir switch (nContextId) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_OWN: 123*cdf0e10cSrcweir rState.maValue >>= bNumOwn; 124*cdf0e10cSrcweir break; 125*cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_RESTART: 126*cdf0e10cSrcweir rState.maValue >>= bNumRestart; 127*cdf0e10cSrcweir break; 128*cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_RESTART_AT: 129*cdf0e10cSrcweir rState.maValue >>= nNumRestartAt; 130*cdf0e10cSrcweir break; 131*cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_TYPE: 132*cdf0e10cSrcweir rState.maValue >>= nNumberingType; 133*cdf0e10cSrcweir break; 134*cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_PREFIX: 135*cdf0e10cSrcweir rState.maValue >>= sNumPrefix; 136*cdf0e10cSrcweir break; 137*cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_NUM_SUFFIX: 138*cdf0e10cSrcweir rState.maValue >>= sNumSuffix; 139*cdf0e10cSrcweir break; 140*cdf0e10cSrcweir case CTF_SECTION_ENDNOTE_END: 141*cdf0e10cSrcweir DBG_ASSERT( i == nIdx, 142*cdf0e10cSrcweir "received wrong property state index" ); 143*cdf0e10cSrcweir rState.maValue >>= bEnd; 144*cdf0e10cSrcweir break; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // we only make an element if we have an own footnote/endnote numbering 150*cdf0e10cSrcweir if (bEnd) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS, 153*cdf0e10cSrcweir GetXMLToken( bEndnote ? XML_ENDNOTE 154*cdf0e10cSrcweir : XML_FOOTNOTE ) ); 155*cdf0e10cSrcweir // start numbering 156*cdf0e10cSrcweir OUStringBuffer sBuf; 157*cdf0e10cSrcweir if (bNumRestart) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir // restart number is stored as 0.., but interpreted as 1.. 160*cdf0e10cSrcweir SvXMLUnitConverter::convertNumber(sBuf, 161*cdf0e10cSrcweir (sal_Int32)(nNumRestartAt+1)); 162*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE, 163*cdf0e10cSrcweir sBuf.makeStringAndClear()); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir if (bNumOwn) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir // prefix and suffix 169*cdf0e10cSrcweir if (sNumPrefix.getLength() > 0) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX, 172*cdf0e10cSrcweir sNumPrefix); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir if (sNumSuffix.getLength() > 0) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX, 177*cdf0e10cSrcweir sNumSuffix); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // number type: num format 181*cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertNumFormat( sBuf, 182*cdf0e10cSrcweir nNumberingType ); 183*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT, 184*cdf0e10cSrcweir sBuf.makeStringAndClear()); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir // and letter sync, if applicable 187*cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertNumLetterSync( 188*cdf0e10cSrcweir sBuf, nNumberingType ); 189*cdf0e10cSrcweir if (sBuf.getLength()) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, 192*cdf0e10cSrcweir XML_NUM_LETTER_SYNC, 193*cdf0e10cSrcweir sBuf.makeStringAndClear()); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir // and finally, the element 198*cdf0e10cSrcweir SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT, 199*cdf0e10cSrcweir XML_NOTES_CONFIGURATION, 200*cdf0e10cSrcweir sal_True, sal_True); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203