Coverage Report

Created: 2026-06-30 11:14

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