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