bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / style / XMLFootnoteSeparatorExport.cxx
blobb551194e65d8a83ebcb6221d5f9c07989de3b5af
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "XMLFootnoteSeparatorExport.hxx"
23 #include <tools/debug.hxx>
25 #include <sax/tools/converter.hxx>
27 #include <xmloff/xmlexp.hxx>
28 #include <xmloff/xmlnmspe.hxx>
29 #include <xmloff/xmluconv.hxx>
30 #include <xmloff/xmltoken.hxx>
31 #include <xmloff/xmlprmap.hxx>
33 #include <xmloff/PageMasterStyleMap.hxx>
34 #include <com/sun/star/text/HorizontalAdjust.hpp>
35 #include <rtl/ustrbuf.hxx>
38 using namespace ::com::sun::star;
39 using namespace ::xmloff::token;
40 using ::std::vector;
42 XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport& rExp) :
43 rExport(rExp)
47 XMLFootnoteSeparatorExport::~XMLFootnoteSeparatorExport()
52 void XMLFootnoteSeparatorExport::exportXML(
53 const vector<XMLPropertyState> * pProperties,
54 sal_uInt32
55 #ifdef DBG_UTIL
56 nIdx
57 #endif
59 const rtl::Reference<XMLPropertySetMapper> & rMapper)
61 DBG_ASSERT(NULL != pProperties, "Need property states");
63 // intialize values
64 sal_Int16 eLineAdjust = text::HorizontalAdjust_LEFT;
65 sal_Int32 nLineColor = 0;
66 sal_Int32 nLineDistance = 0;
67 sal_Int8 nLineRelWidth = 0;
68 sal_Int32 nLineTextDistance = 0;
69 sal_Int16 nLineWeight = 0;
70 sal_Int8 nLineStyle = 0;
72 // find indices into property map and get values
73 sal_uInt32 nCount = pProperties->size();
74 for(sal_uInt32 i = 0; i < nCount; i++)
76 const XMLPropertyState& rState = (*pProperties)[i];
78 if( rState.mnIndex == -1 )
79 continue;
81 switch (rMapper->GetEntryContextId(rState.mnIndex))
83 case CTF_PM_FTN_LINE_ADJUST:
84 rState.maValue >>= eLineAdjust;
85 break;
86 case CTF_PM_FTN_LINE_COLOR:
87 rState.maValue >>= nLineColor;
88 break;
89 case CTF_PM_FTN_DISTANCE:
90 rState.maValue >>= nLineDistance;
91 break;
92 case CTF_PM_FTN_LINE_WIDTH:
93 rState.maValue >>= nLineRelWidth;
94 break;
95 case CTF_PM_FTN_LINE_DISTANCE:
96 rState.maValue >>= nLineTextDistance;
97 break;
98 case CTF_PM_FTN_LINE_WEIGHT:
99 DBG_ASSERT( i == nIdx,
100 "received wrong property state index" );
101 rState.maValue >>= nLineWeight;
102 break;
103 case CTF_PM_FTN_LINE_STYLE:
104 rState.maValue >>= nLineStyle;
105 break;
109 OUStringBuffer sBuf;
111 // weight/width
112 if (nLineWeight > 0)
114 rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf, nLineWeight);
115 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_WIDTH,
116 sBuf.makeStringAndClear());
119 // line text distance
120 if (nLineTextDistance > 0)
122 rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
123 nLineTextDistance);
124 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_BEFORE_SEP,
125 sBuf.makeStringAndClear());
128 // line distance
129 if (nLineDistance > 0)
131 rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
132 nLineDistance);
133 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_AFTER_SEP,
134 sBuf.makeStringAndClear());
137 // line style
138 static const SvXMLEnumMapEntry aXML_LineStyle_Enum[] =
140 { XML_NONE, 0 },
141 { XML_SOLID, 1 },
142 { XML_DOTTED, 2 },
143 { XML_DASH, 3 },
144 { XML_TOKEN_INVALID, 0 }
146 if (SvXMLUnitConverter::convertEnum(
147 sBuf, nLineStyle, aXML_LineStyle_Enum ) )
149 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_LINE_STYLE,
150 sBuf.makeStringAndClear());
153 // adjustment
154 static const SvXMLEnumMapEntry aXML_HorizontalAdjust_Enum[] =
156 { XML_LEFT, text::HorizontalAdjust_LEFT },
157 { XML_CENTER, text::HorizontalAdjust_CENTER },
158 { XML_RIGHT, text::HorizontalAdjust_RIGHT },
159 { XML_TOKEN_INVALID, 0 }
162 if (SvXMLUnitConverter::convertEnum(
163 sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
165 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_ADJUSTMENT,
166 sBuf.makeStringAndClear());
169 // relative line width
170 ::sax::Converter::convertPercent(sBuf, nLineRelWidth);
171 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_REL_WIDTH,
172 sBuf.makeStringAndClear());
174 // color
175 ::sax::Converter::convertColor(sBuf, nLineColor);
176 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_COLOR,
177 sBuf.makeStringAndClear());
179 // line-style
181 SvXMLElementExport aElem(rExport, XML_NAMESPACE_STYLE,
182 XML_FOOTNOTE_SEP, true, true);
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */