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