Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/style/XMLFootnoteSeparatorImport.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 "XMLFootnoteSeparatorImport.hxx"
22
23
#include <sal/log.hxx>
24
25
#include <com/sun/star/uno/Reference.h>
26
#include <com/sun/star/text/HorizontalAdjust.hpp>
27
28
29
#include <sax/tools/converter.hxx>
30
31
#include <utility>
32
#include <xmloff/xmlimp.hxx>
33
#include <xmloff/xmltoken.hxx>
34
#include <xmloff/xmluconv.hxx>
35
#include <xmloff/xmlprmap.hxx>
36
#include <xmloff/xmlnamespace.hxx>
37
#include <xmloff/maptype.hxx>
38
#include <xmloff/xmlement.hxx>
39
40
#include <PageMasterStyleMap.hxx>
41
42
43
using namespace ::com::sun::star;
44
using namespace ::xmloff::token;
45
46
using ::std::vector;
47
using ::com::sun::star::uno::Any;
48
using ::com::sun::star::uno::Reference;
49
50
51
XMLFootnoteSeparatorImport::XMLFootnoteSeparatorImport(
52
    SvXMLImport& rImport,
53
    sal_Int32 /*nElement*/,
54
    vector<XMLPropertyState> & rProps,
55
    rtl::Reference<XMLPropertySetMapper> xMapperRef,
56
    sal_Int32 nIndex) :
57
2.00k
        SvXMLImportContext(rImport),
58
2.00k
        rProperties(rProps),
59
2.00k
        rMapper(std::move(xMapperRef)),
60
2.00k
        nPropIndex(nIndex)
61
2.00k
{
62
2.00k
}
63
64
XMLFootnoteSeparatorImport::~XMLFootnoteSeparatorImport()
65
2.00k
{
66
2.00k
}
67
68
void XMLFootnoteSeparatorImport::startFastElement(
69
    sal_Int32 /*nElement*/,
70
    const Reference<css::xml::sax::XFastAttributeList> & xAttrList)
71
2.00k
{
72
    // get the values from the properties
73
2.00k
    sal_Int16 nLineWeight = 0;
74
2.00k
    sal_Int32 nLineColor = 0;
75
2.00k
    sal_Int8 nLineRelWidth = 0;
76
2.00k
    text::HorizontalAdjust eLineAdjust = text::HorizontalAdjust_LEFT;
77
2.00k
    sal_Int32 nLineTextDistance = 0;
78
2.00k
    sal_Int32 nLineDistance = 0;
79
80
    // Default separator line style should be SOLID (used to be default before
81
    // the choice selector was available)
82
2.00k
    sal_Int8 nLineStyle = 1;
83
84
    // iterate over xattribute list and fill values
85
2.00k
    for (auto &aIter : sax_fastparser::castToFastAttributeList(xAttrList))
86
12.1k
    {
87
12.1k
        sal_Int32 nTmp;
88
12.1k
        switch (aIter.getToken())
89
12.1k
        {
90
1.45k
            case XML_ELEMENT(STYLE, XML_WIDTH):
91
1.45k
            {
92
1.45k
                if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
93
1.45k
                    nTmp, aIter.toView()))
94
1.41k
                {
95
1.41k
                    nLineWeight = static_cast<sal_Int16>(nTmp);
96
1.41k
                }
97
1.45k
                break;
98
0
            }
99
1.45k
            case XML_ELEMENT(STYLE, XML_DISTANCE_BEFORE_SEP):
100
1.45k
            {
101
1.45k
                if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
102
1.45k
                                                        nTmp, aIter.toView()))
103
1.37k
                    nLineTextDistance = nTmp;
104
1.45k
                break;
105
0
            }
106
1.45k
            case XML_ELEMENT(STYLE, XML_DISTANCE_AFTER_SEP):
107
1.45k
            {
108
1.45k
                if (GetImport().GetMM100UnitConverter().convertMeasureToCore(
109
1.45k
                                                        nTmp, aIter.toView()))
110
1.38k
                    nLineDistance = nTmp;
111
1.45k
                break;
112
0
            }
113
1.93k
            case XML_ELEMENT(STYLE, XML_ADJUSTMENT ):
114
1.93k
            {
115
1.93k
                static const SvXMLEnumMapEntry<text::HorizontalAdjust> aXML_HorizontalAdjust_Enum[] =
116
1.93k
                {
117
1.93k
                    { XML_LEFT,     text::HorizontalAdjust_LEFT },
118
1.93k
                    { XML_CENTER,   text::HorizontalAdjust_CENTER },
119
1.93k
                    { XML_RIGHT,    text::HorizontalAdjust_RIGHT },
120
1.93k
                    { XML_TOKEN_INVALID, text::HorizontalAdjust(0) }
121
1.93k
                };
122
123
1.93k
                SvXMLUnitConverter::convertEnum(
124
1.93k
                            eLineAdjust, aIter.toView(), aXML_HorizontalAdjust_Enum);
125
1.93k
                break;
126
0
            }
127
1.86k
            case XML_ELEMENT(STYLE, XML_REL_WIDTH ):
128
1.86k
            {
129
1.86k
                if (::sax::Converter::convertPercent(nTmp, aIter.toView()))
130
1.86k
                    nLineRelWidth = static_cast<sal_uInt8>(nTmp);
131
1.86k
                break;
132
0
            }
133
1.99k
            case XML_ELEMENT(STYLE, XML_COLOR):
134
1.99k
            {
135
1.99k
                if (::sax::Converter::convertColor(nTmp, aIter.toView()))
136
1.97k
                {
137
1.97k
                    nLineColor = nTmp;
138
1.97k
                }
139
1.99k
                break;
140
0
            }
141
1.91k
            case XML_ELEMENT(STYLE, XML_LINE_STYLE ):
142
1.91k
            {
143
1.91k
                static const SvXMLEnumMapEntry<sal_Int8> aXML_LineStyle_Enum[] =
144
1.91k
                {
145
1.91k
                    { XML_NONE,     0 },
146
1.91k
                    { XML_SOLID,    1 },
147
1.91k
                    { XML_DOTTED,   2 },
148
1.91k
                    { XML_DASH,     3 },
149
1.91k
                    { XML_TOKEN_INVALID, 0 }
150
1.91k
                };
151
152
1.91k
                SvXMLUnitConverter::convertEnum(nLineStyle, aIter.toView(), aXML_LineStyle_Enum);
153
1.91k
                break;
154
0
            }
155
41
            default:
156
41
                XMLOFF_WARN_UNKNOWN("xmloff", aIter);
157
12.1k
        }
158
12.1k
    }
159
160
    // OK, now we have all values and can fill the XMLPropertyState vector
161
2.00k
    sal_Int32 nIndex;
162
163
2.00k
    nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_ADJUST);
164
2.00k
    XMLPropertyState aLineAdjust( nIndex, uno::Any(sal_Int16(eLineAdjust)) );
165
2.00k
    rProperties.push_back(aLineAdjust);
166
167
2.00k
    nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_COLOR);
168
2.00k
    XMLPropertyState aLineColor( nIndex, uno::Any(nLineColor) );
169
2.00k
    rProperties.push_back(aLineColor);
170
171
2.00k
    nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_STYLE);
172
2.00k
    XMLPropertyState aLineStyle( nIndex, uno::Any(nLineStyle) );
173
2.00k
    rProperties.push_back(aLineStyle);
174
175
2.00k
    nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_DISTANCE);
176
2.00k
    XMLPropertyState aLineDistance( nIndex, uno::Any(nLineDistance) );
177
2.00k
    rProperties.push_back(aLineDistance);
178
179
2.00k
    nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_WIDTH);
180
2.00k
    XMLPropertyState aLineRelWidth( nIndex, uno::Any(nLineRelWidth));
181
2.00k
    rProperties.push_back(aLineRelWidth);
182
183
2.00k
    nIndex = rMapper->FindEntryIndex(CTF_PM_FTN_LINE_DISTANCE);
184
2.00k
    XMLPropertyState aLineTextDistance( nIndex, uno::Any(nLineTextDistance));
185
2.00k
    rProperties.push_back(aLineTextDistance);
186
187
2.00k
    SAL_WARN_IF( rMapper->FindEntryIndex(CTF_PM_FTN_LINE_WEIGHT) != nPropIndex, "xmloff",
188
2.00k
                "Received wrong property map index!" );
189
2.00k
    XMLPropertyState aLineWeight( nPropIndex, uno::Any(nLineWeight) );
190
2.00k
    rProperties.push_back(aLineWeight);
191
2.00k
}
192
193
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */