tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / style / XMLFootnoteSeparatorExport.cxx
blobc5e160dffd3e7e38425ad10c1e21f13492327d41
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 <sax/tools/converter.hxx>
25 #include <xmloff/xmlexp.hxx>
26 #include <xmloff/xmlnamespace.hxx>
27 #include <xmloff/xmluconv.hxx>
28 #include <xmloff/xmltoken.hxx>
29 #include <xmloff/xmlprmap.hxx>
30 #include <xmloff/xmlement.hxx>
32 #include <PageMasterStyleMap.hxx>
33 #include <com/sun/star/text/HorizontalAdjust.hpp>
34 #include <rtl/ustrbuf.hxx>
37 using namespace ::com::sun::star;
38 using namespace ::xmloff::token;
39 using ::std::vector;
41 XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport& rExp) :
42 rExport(rExp)
46 void XMLFootnoteSeparatorExport::exportXML(
47 const vector<XMLPropertyState> * pProperties,
48 sal_uInt32 const nIdx,
49 const rtl::Reference<XMLPropertySetMapper> & rMapper)
51 assert(pProperties);
53 // initialize values
54 text::HorizontalAdjust eLineAdjust = text::HorizontalAdjust_LEFT;
55 sal_Int32 nLineColor = 0;
56 sal_Int32 nLineDistance = 0;
57 sal_Int8 nLineRelWidth = 0;
58 sal_Int32 nLineTextDistance = 0;
59 sal_Int16 nLineWeight = 0;
60 sal_Int8 nLineStyle = 0;
62 // find indices into property map and get values
63 sal_uInt32 nCount = pProperties->size();
64 for(sal_uInt32 i = 0; i < nCount; i++)
66 const XMLPropertyState& rState = (*pProperties)[i];
68 if( rState.mnIndex == -1 )
69 continue;
71 switch (rMapper->GetEntryContextId(rState.mnIndex))
73 case CTF_PM_FTN_LINE_ADJUST:
75 sal_Int16 nTmp;
76 if (rState.maValue >>= nTmp)
77 eLineAdjust = static_cast<text::HorizontalAdjust>(nTmp);
78 break;
80 case CTF_PM_FTN_LINE_COLOR:
81 rState.maValue >>= nLineColor;
82 break;
83 case CTF_PM_FTN_DISTANCE:
84 rState.maValue >>= nLineDistance;
85 break;
86 case CTF_PM_FTN_LINE_WIDTH:
87 rState.maValue >>= nLineRelWidth;
88 break;
89 case CTF_PM_FTN_LINE_DISTANCE:
90 rState.maValue >>= nLineTextDistance;
91 break;
92 case CTF_PM_FTN_LINE_WEIGHT:
93 (void) nIdx;
94 assert(i == nIdx && "received wrong property state index");
95 rState.maValue >>= nLineWeight;
96 break;
97 case CTF_PM_FTN_LINE_STYLE:
98 rState.maValue >>= nLineStyle;
99 break;
103 OUStringBuffer sBuf;
105 // weight/width
106 if (nLineWeight > 0)
108 rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf, nLineWeight);
109 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_WIDTH,
110 sBuf.makeStringAndClear());
113 // line text distance
114 if (nLineTextDistance > 0)
116 rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
117 nLineTextDistance);
118 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_BEFORE_SEP,
119 sBuf.makeStringAndClear());
122 // line distance
123 if (nLineDistance > 0)
125 rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
126 nLineDistance);
127 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_AFTER_SEP,
128 sBuf.makeStringAndClear());
131 // line style
132 static const SvXMLEnumMapEntry<sal_Int8> aXML_LineStyle_Enum[] =
134 { XML_NONE, 0 },
135 { XML_SOLID, 1 },
136 { XML_DOTTED, 2 },
137 { XML_DASH, 3 },
138 { XML_TOKEN_INVALID, 0 }
140 if (SvXMLUnitConverter::convertEnum(
141 sBuf, nLineStyle, aXML_LineStyle_Enum ) )
143 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_LINE_STYLE,
144 sBuf.makeStringAndClear());
147 // adjustment
148 static const SvXMLEnumMapEntry<text::HorizontalAdjust> aXML_HorizontalAdjust_Enum[] =
150 { XML_LEFT, text::HorizontalAdjust_LEFT },
151 { XML_CENTER, text::HorizontalAdjust_CENTER },
152 { XML_RIGHT, text::HorizontalAdjust_RIGHT },
153 { XML_TOKEN_INVALID, text::HorizontalAdjust(0) }
156 if (SvXMLUnitConverter::convertEnum(
157 sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
159 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_ADJUSTMENT,
160 sBuf.makeStringAndClear());
163 // relative line width
164 ::sax::Converter::convertPercent(sBuf, nLineRelWidth);
165 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_REL_WIDTH,
166 sBuf.makeStringAndClear());
168 // color
169 ::sax::Converter::convertColor(sBuf, nLineColor);
170 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_COLOR,
171 sBuf.makeStringAndClear());
173 // line-style
175 SvXMLElementExport aElem(rExport, XML_NAMESPACE_STYLE,
176 XML_FOOTNOTE_SEP, true, true);
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */