LibreOffice Module xmloff (master) 1
XMLFootnoteSeparatorExport.cxx
Go to the documentation of this file.
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
22
24
25#include <xmloff/xmlexp.hxx>
27#include <xmloff/xmluconv.hxx>
28#include <xmloff/xmltoken.hxx>
29#include <xmloff/xmlprmap.hxx>
30#include <xmloff/xmlement.hxx>
31
33#include <com/sun/star/text/HorizontalAdjust.hpp>
34#include <rtl/ustrbuf.hxx>
35
36
37using namespace ::com::sun::star;
38using namespace ::xmloff::token;
39using ::std::vector;
40
42 rExport(rExp)
43{
44}
45
47 const vector<XMLPropertyState> * pProperties,
48 sal_uInt32 const nIdx,
50{
51 assert(pProperties);
52
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;
61
62 // find indices into property map and get values
63 sal_uInt32 nCount = pProperties->size();
64 for(sal_uInt32 i = 0; i < nCount; i++)
65 {
66 const XMLPropertyState& rState = (*pProperties)[i];
67
68 if( rState.mnIndex == -1 )
69 continue;
70
71 switch (rMapper->GetEntryContextId(rState.mnIndex))
72 {
74 {
75 sal_Int16 nTmp;
76 if (rState.maValue >>= nTmp)
77 eLineAdjust = static_cast<text::HorizontalAdjust>(nTmp);
78 break;
79 }
81 rState.maValue >>= nLineColor;
82 break;
84 rState.maValue >>= nLineDistance;
85 break;
87 rState.maValue >>= nLineRelWidth;
88 break;
90 rState.maValue >>= nLineTextDistance;
91 break;
93 (void) nIdx;
94 assert(i == nIdx && "received wrong property state index");
95 rState.maValue >>= nLineWeight;
96 break;
98 rState.maValue >>= nLineStyle;
99 break;
100 }
101 }
102
103 OUStringBuffer sBuf;
104
105 // weight/width
106 if (nLineWeight > 0)
107 {
110 sBuf.makeStringAndClear());
111 }
112
113 // line text distance
114 if (nLineTextDistance > 0)
115 {
117 nLineTextDistance);
119 sBuf.makeStringAndClear());
120 }
121
122 // line distance
123 if (nLineDistance > 0)
124 {
126 nLineDistance);
128 sBuf.makeStringAndClear());
129 }
130
131 // line style
132 static const SvXMLEnumMapEntry<sal_Int8> 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 };
141 sBuf, nLineStyle, aXML_LineStyle_Enum ) )
142 {
144 sBuf.makeStringAndClear());
145 }
146
147 // adjustment
149 {
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) }
154 };
155
157 sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
158 {
160 sBuf.makeStringAndClear());
161 }
162
163 // relative line width
164 ::sax::Converter::convertPercent(sBuf, nLineRelWidth);
166 sBuf.makeStringAndClear());
167
168 // color
169 ::sax::Converter::convertColor(sBuf, nLineColor);
171 sBuf.makeStringAndClear());
172
173 // line-style
174
176 XML_FOOTNOTE_SEP, true, true);
177}
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define CTF_PM_FTN_LINE_STYLE
#define CTF_PM_FTN_LINE_WEIGHT
#define CTF_PM_FTN_LINE_WIDTH
#define CTF_PM_FTN_LINE_COLOR
#define CTF_PM_FTN_DISTANCE
#define CTF_PM_FTN_LINE_DISTANCE
#define CTF_PM_FTN_LINE_ADJUST
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:911
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:396
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
Definition: xmluconv.cxx:206
void exportXML(const ::std::vector< XMLPropertyState > *pProperties, sal_uInt32 nIdx, const rtl::Reference< XMLPropertySetMapper > &rMapper)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
int nCount
int i
Handling of tokens in XML:
@ XML_DISTANCE_AFTER_SEP
Definition: xmltoken.hxx:692
@ XML_DISTANCE_BEFORE_SEP
Definition: xmltoken.hxx:693
SvXMLEnumMapEntry< text::HorizontalAdjust > const aXML_HorizontalAdjust_Enum[]
Definition: prhdlfac.cxx:74
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:140
css::uno::Any maValue
Definition: maptype.hxx:142
sal_Int32 mnIndex
Definition: maptype.hxx:141
signed char sal_Int8
constexpr sal_uInt16 XML_NAMESPACE_STYLE