1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
41 XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport
& rExp
) :
46 void XMLFootnoteSeparatorExport::exportXML(
47 const vector
<XMLPropertyState
> * pProperties
,
48 sal_uInt32
const nIdx
,
49 const rtl::Reference
<XMLPropertySetMapper
> & rMapper
)
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 )
71 switch (rMapper
->GetEntryContextId(rState
.mnIndex
))
73 case CTF_PM_FTN_LINE_ADJUST
:
76 if (rState
.maValue
>>= nTmp
)
77 eLineAdjust
= static_cast<text::HorizontalAdjust
>(nTmp
);
80 case CTF_PM_FTN_LINE_COLOR
:
81 rState
.maValue
>>= nLineColor
;
83 case CTF_PM_FTN_DISTANCE
:
84 rState
.maValue
>>= nLineDistance
;
86 case CTF_PM_FTN_LINE_WIDTH
:
87 rState
.maValue
>>= nLineRelWidth
;
89 case CTF_PM_FTN_LINE_DISTANCE
:
90 rState
.maValue
>>= nLineTextDistance
;
92 case CTF_PM_FTN_LINE_WEIGHT
:
94 assert(i
== nIdx
&& "received wrong property state index");
95 rState
.maValue
>>= nLineWeight
;
97 case CTF_PM_FTN_LINE_STYLE
:
98 rState
.maValue
>>= nLineStyle
;
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
,
118 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_DISTANCE_BEFORE_SEP
,
119 sBuf
.makeStringAndClear());
123 if (nLineDistance
> 0)
125 rExport
.GetMM100UnitConverter().convertMeasureToXML(sBuf
,
127 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_DISTANCE_AFTER_SEP
,
128 sBuf
.makeStringAndClear());
132 static const SvXMLEnumMapEntry
<sal_Int8
> aXML_LineStyle_Enum
[] =
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());
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());
169 ::sax::Converter::convertColor(sBuf
, nLineColor
);
170 rExport
.AddAttribute(XML_NAMESPACE_STYLE
, XML_COLOR
,
171 sBuf
.makeStringAndClear());
175 SvXMLElementExport
aElem(rExport
, XML_NAMESPACE_STYLE
,
176 XML_FOOTNOTE_SEP
, true, true);
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */