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 "XMLFootnoteSeparatorExport.hxx" 31*cdf0e10cSrcweir #include <tools/debug.hxx> 32*cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 33*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 34*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 35*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 36*cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX 39*cdf0e10cSrcweir #include <xmloff/PageMasterStyleMap.hxx> 40*cdf0e10cSrcweir #endif 41*cdf0e10cSrcweir #include <com/sun/star/text/HorizontalAdjust.hpp> 42*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir using namespace ::com::sun::star; 46*cdf0e10cSrcweir using namespace ::xmloff::token; 47*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 48*cdf0e10cSrcweir using ::std::vector; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport& rExp) : 51*cdf0e10cSrcweir rExport(rExp) 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir XMLFootnoteSeparatorExport::~XMLFootnoteSeparatorExport() 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir void XMLFootnoteSeparatorExport::exportXML( 61*cdf0e10cSrcweir const vector<XMLPropertyState> * pProperties, 62*cdf0e10cSrcweir sal_uInt32 63*cdf0e10cSrcweir #ifdef DBG_UTIL 64*cdf0e10cSrcweir nIdx 65*cdf0e10cSrcweir #endif 66*cdf0e10cSrcweir , 67*cdf0e10cSrcweir const UniReference<XMLPropertySetMapper> & rMapper) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir DBG_ASSERT(NULL != pProperties, "Need property states"); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir // intialize values 72*cdf0e10cSrcweir sal_Int16 eLineAdjust = text::HorizontalAdjust_LEFT; 73*cdf0e10cSrcweir sal_Int32 nLineColor = 0; 74*cdf0e10cSrcweir sal_Int32 nLineDistance = 0; 75*cdf0e10cSrcweir sal_Int8 nLineRelWidth = 0; 76*cdf0e10cSrcweir sal_Int32 nLineTextDistance = 0; 77*cdf0e10cSrcweir sal_Int16 nLineWeight = 0; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // find indices into property map and get values 80*cdf0e10cSrcweir sal_uInt32 nCount = pProperties->size(); 81*cdf0e10cSrcweir for(sal_uInt32 i = 0; i < nCount; i++) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir const XMLPropertyState& rState = (*pProperties)[i]; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir if( rState.mnIndex == -1 ) 86*cdf0e10cSrcweir continue; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir switch (rMapper->GetEntryContextId(rState.mnIndex)) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir case CTF_PM_FTN_LINE_ADJUST: 91*cdf0e10cSrcweir rState.maValue >>= eLineAdjust; 92*cdf0e10cSrcweir break; 93*cdf0e10cSrcweir case CTF_PM_FTN_LINE_COLOR: 94*cdf0e10cSrcweir rState.maValue >>= nLineColor; 95*cdf0e10cSrcweir break; 96*cdf0e10cSrcweir case CTF_PM_FTN_DISTANCE: 97*cdf0e10cSrcweir rState.maValue >>= nLineDistance; 98*cdf0e10cSrcweir break; 99*cdf0e10cSrcweir case CTF_PM_FTN_LINE_WIDTH: 100*cdf0e10cSrcweir rState.maValue >>= nLineRelWidth; 101*cdf0e10cSrcweir break; 102*cdf0e10cSrcweir case CTF_PM_FTN_LINE_DISTANCE: 103*cdf0e10cSrcweir rState.maValue >>= nLineTextDistance; 104*cdf0e10cSrcweir break; 105*cdf0e10cSrcweir case CTF_PM_FTN_LINE_WEIGTH: 106*cdf0e10cSrcweir DBG_ASSERT( i == nIdx, 107*cdf0e10cSrcweir "received wrong property state index" ); 108*cdf0e10cSrcweir rState.maValue >>= nLineWeight; 109*cdf0e10cSrcweir break; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir OUStringBuffer sBuf; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // weight/width 116*cdf0e10cSrcweir if (nLineWeight > 0) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertMeasure(sBuf, nLineWeight); 119*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_WIDTH, 120*cdf0e10cSrcweir sBuf.makeStringAndClear()); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // line text distance 124*cdf0e10cSrcweir if (nLineTextDistance > 0) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertMeasure(sBuf,nLineTextDistance); 127*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_BEFORE_SEP, 128*cdf0e10cSrcweir sBuf.makeStringAndClear()); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir // line distance 132*cdf0e10cSrcweir if (nLineDistance > 0) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertMeasure(sBuf, nLineDistance); 135*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_AFTER_SEP, 136*cdf0e10cSrcweir sBuf.makeStringAndClear()); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir // adjustment 140*cdf0e10cSrcweir static const SvXMLEnumMapEntry aXML_HorizontalAdjust_Enum[] = 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir { XML_LEFT, text::HorizontalAdjust_LEFT }, 143*cdf0e10cSrcweir { XML_CENTER, text::HorizontalAdjust_CENTER }, 144*cdf0e10cSrcweir { XML_RIGHT, text::HorizontalAdjust_RIGHT }, 145*cdf0e10cSrcweir { XML_TOKEN_INVALID, 0 } 146*cdf0e10cSrcweir }; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir if (rExport.GetMM100UnitConverter().convertEnum( 149*cdf0e10cSrcweir sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum)) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_ADJUSTMENT, 152*cdf0e10cSrcweir sBuf.makeStringAndClear()); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // relative line width 156*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent(sBuf, nLineRelWidth); 157*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_REL_WIDTH, 158*cdf0e10cSrcweir sBuf.makeStringAndClear()); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir // color 161*cdf0e10cSrcweir rExport.GetMM100UnitConverter().convertColor(sBuf, nLineColor); 162*cdf0e10cSrcweir rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_COLOR, 163*cdf0e10cSrcweir sBuf.makeStringAndClear()); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir SvXMLElementExport aElem(rExport, XML_NAMESPACE_STYLE, 166*cdf0e10cSrcweir XML_FOOTNOTE_SEP, sal_True, sal_True); 167*cdf0e10cSrcweir } 168