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