Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "XMLFootnoteSeparatorExport.hxx"
22 :
23 : #include <sax/tools/converter.hxx>
24 :
25 : #include <xmloff/xmlexp.hxx>
26 : #include <xmloff/xmlnmspe.hxx>
27 : #include <xmloff/xmluconv.hxx>
28 : #include <xmloff/xmltoken.hxx>
29 : #include <xmloff/xmlprmap.hxx>
30 :
31 : #include <xmloff/PageMasterStyleMap.hxx>
32 : #include <com/sun/star/text/HorizontalAdjust.hpp>
33 : #include <rtl/ustrbuf.hxx>
34 :
35 :
36 : using namespace ::com::sun::star;
37 : using namespace ::xmloff::token;
38 : using ::std::vector;
39 :
40 102 : XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport& rExp) :
41 102 : rExport(rExp)
42 : {
43 102 : }
44 :
45 102 : XMLFootnoteSeparatorExport::~XMLFootnoteSeparatorExport()
46 : {
47 102 : }
48 :
49 :
50 87 : void XMLFootnoteSeparatorExport::exportXML(
51 : const vector<XMLPropertyState> * pProperties,
52 : sal_uInt32 const nIdx,
53 : const rtl::Reference<XMLPropertySetMapper> & rMapper)
54 : {
55 : assert(pProperties);
56 :
57 : // intialize values
58 87 : sal_Int16 eLineAdjust = text::HorizontalAdjust_LEFT;
59 87 : sal_Int32 nLineColor = 0;
60 87 : sal_Int32 nLineDistance = 0;
61 87 : sal_Int8 nLineRelWidth = 0;
62 87 : sal_Int32 nLineTextDistance = 0;
63 87 : sal_Int16 nLineWeight = 0;
64 87 : sal_Int8 nLineStyle = 0;
65 :
66 : // find indices into property map and get values
67 87 : sal_uInt32 nCount = pProperties->size();
68 2184 : for(sal_uInt32 i = 0; i < nCount; i++)
69 : {
70 2097 : const XMLPropertyState& rState = (*pProperties)[i];
71 :
72 2097 : if( rState.mnIndex == -1 )
73 163 : continue;
74 :
75 1934 : switch (rMapper->GetEntryContextId(rState.mnIndex))
76 : {
77 : case CTF_PM_FTN_LINE_ADJUST:
78 87 : rState.maValue >>= eLineAdjust;
79 87 : break;
80 : case CTF_PM_FTN_LINE_COLOR:
81 87 : rState.maValue >>= nLineColor;
82 87 : break;
83 : case CTF_PM_FTN_DISTANCE:
84 87 : rState.maValue >>= nLineDistance;
85 87 : break;
86 : case CTF_PM_FTN_LINE_WIDTH:
87 87 : rState.maValue >>= nLineRelWidth;
88 87 : break;
89 : case CTF_PM_FTN_LINE_DISTANCE:
90 87 : rState.maValue >>= nLineTextDistance;
91 87 : break;
92 : case CTF_PM_FTN_LINE_WEIGHT:
93 : (void) nIdx;
94 : assert(i == nIdx && "received wrong property state index");
95 87 : rState.maValue >>= nLineWeight;
96 87 : break;
97 : case CTF_PM_FTN_LINE_STYLE:
98 87 : rState.maValue >>= nLineStyle;
99 87 : break;
100 : }
101 : }
102 :
103 87 : OUStringBuffer sBuf;
104 :
105 : // weight/width
106 87 : if (nLineWeight > 0)
107 : {
108 87 : rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf, nLineWeight);
109 : rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_WIDTH,
110 87 : sBuf.makeStringAndClear());
111 : }
112 :
113 : // line text distance
114 87 : if (nLineTextDistance > 0)
115 : {
116 87 : rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
117 174 : nLineTextDistance);
118 : rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_BEFORE_SEP,
119 87 : sBuf.makeStringAndClear());
120 : }
121 :
122 : // line distance
123 87 : if (nLineDistance > 0)
124 : {
125 87 : rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
126 174 : nLineDistance);
127 : rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_AFTER_SEP,
128 87 : sBuf.makeStringAndClear());
129 : }
130 :
131 : // line style
132 : static const SvXMLEnumMapEntry aXML_LineStyle_Enum[] =
133 : {
134 : { XML_NONE, 0 },
135 : { XML_SOLID, 1 },
136 : { XML_DOTTED, 2 },
137 : { XML_DASH, 3 },
138 : { XML_TOKEN_INVALID, 0 }
139 : };
140 87 : if (SvXMLUnitConverter::convertEnum(
141 87 : sBuf, nLineStyle, aXML_LineStyle_Enum ) )
142 : {
143 : rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_LINE_STYLE,
144 87 : sBuf.makeStringAndClear());
145 : }
146 :
147 : // adjustment
148 : static const SvXMLEnumMapEntry aXML_HorizontalAdjust_Enum[] =
149 : {
150 : { XML_LEFT, text::HorizontalAdjust_LEFT },
151 : { XML_CENTER, text::HorizontalAdjust_CENTER },
152 : { XML_RIGHT, text::HorizontalAdjust_RIGHT },
153 : { XML_TOKEN_INVALID, 0 }
154 : };
155 :
156 87 : if (SvXMLUnitConverter::convertEnum(
157 87 : sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
158 : {
159 : rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_ADJUSTMENT,
160 87 : sBuf.makeStringAndClear());
161 : }
162 :
163 : // relative line width
164 87 : ::sax::Converter::convertPercent(sBuf, nLineRelWidth);
165 : rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_REL_WIDTH,
166 87 : sBuf.makeStringAndClear());
167 :
168 : // color
169 87 : ::sax::Converter::convertColor(sBuf, nLineColor);
170 : rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_COLOR,
171 87 : sBuf.makeStringAndClear());
172 :
173 : // line-style
174 :
175 : SvXMLElementExport aElem(rExport, XML_NAMESPACE_STYLE,
176 87 : XML_FOOTNOTE_SEP, true, true);
177 87 : }
178 :
179 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|