Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/drawingml/textliststyle.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
#include <drawingml/textliststyle.hxx>
21
#include <sal/log.hxx>
22
#include <comphelper/sequenceashashmap.hxx>
23
24
using namespace css;
25
26
namespace oox::drawingml {
27
28
TextListStyle::TextListStyle()
29
608k
    : mbHasListStyleOnImport(false)
30
608k
{
31
608k
}
32
33
TextListStyle::~TextListStyle()
34
654k
{
35
654k
}
36
37
TextListStyle::TextListStyle(const TextListStyle& rStyle)
38
45.5k
    : mbHasListStyleOnImport(false)
39
45.5k
{
40
455k
    for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
41
409k
    {
42
409k
        maListStyle[i] = rStyle.maListStyle[i];
43
409k
        maAggregationListStyle[i] = rStyle.maAggregationListStyle[i];
44
409k
    }
45
45.5k
}
46
47
TextListStyle& TextListStyle::operator=(const TextListStyle& rStyle)
48
23.4k
{
49
23.4k
    if(this != &rStyle)
50
23.4k
    {
51
234k
        for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
52
210k
        {
53
210k
            maListStyle[i] = rStyle.maListStyle[i];
54
210k
            maAggregationListStyle[i] = rStyle.maAggregationListStyle[i];
55
210k
        }
56
23.4k
    }
57
23.4k
    return *this;
58
23.4k
}
59
60
static void applyStyleList( const TextParagraphPropertiesArray& rSourceListStyle, TextParagraphPropertiesArray& rDestListStyle )
61
993k
{
62
9.93M
    for ( size_t i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
63
8.93M
        rDestListStyle[i].apply(rSourceListStyle[i]);
64
993k
}
65
66
void TextListStyle::apply( const TextListStyle& rTextListStyle )
67
496k
{
68
496k
    applyStyleList( rTextListStyle.getAggregationListStyle(), getAggregationListStyle() );
69
496k
    applyStyleList( rTextListStyle.getListStyle(), getListStyle() );
70
496k
}
71
72
void TextListStyle::pushToNumberingRules(const uno::Reference<container::XIndexReplace>& xNumRules,
73
                                         std::optional<size_t> oIgnoreLevel)
74
90.9k
{
75
90.9k
    TextParagraphPropertiesArray& rListStyle = getListStyle();
76
90.9k
    size_t nLevels = xNumRules->getCount();
77
90.9k
    if (rListStyle.size() < nLevels)
78
90.9k
    {
79
90.9k
        nLevels = rListStyle.size();
80
90.9k
    }
81
82
909k
    for (size_t nLevel = 0; nLevel < nLevels; ++nLevel)
83
818k
    {
84
818k
        if (oIgnoreLevel && nLevel == *oIgnoreLevel)
85
55.6k
        {
86
55.6k
            continue;
87
55.6k
        }
88
89
762k
        comphelper::SequenceAsHashMap aMap(xNumRules->getByIndex(nLevel));
90
762k
        TextParagraphProperties& rLevel = rListStyle[nLevel];
91
762k
        bool bChanged = false;
92
762k
        if (rLevel.getParaLeftMargin())
93
203k
        {
94
203k
            aMap["LeftMargin"] <<= *rLevel.getParaLeftMargin();
95
203k
            bChanged = true;
96
203k
        }
97
762k
        if (rLevel.getFirstLineIndentation())
98
105k
        {
99
105k
            sal_Int32 nFirstLineIndentation = *rLevel.getFirstLineIndentation();
100
105k
            if (nFirstLineIndentation > 0)
101
0
            {
102
                // The opposite of this would be exported as <style:list-level-properties
103
                // text:min-label-width="..."> to ODF, where negative values are not allowed.
104
0
                nFirstLineIndentation = 0;
105
0
            }
106
105k
            aMap["FirstLineOffset"] <<= nFirstLineIndentation;
107
105k
            bChanged = true;
108
105k
        }
109
110
762k
        if (bChanged)
111
203k
        {
112
203k
            xNumRules->replaceByIndex(nLevel, aMap.getAsConstAny(true));
113
203k
        }
114
762k
    }
115
90.9k
}
116
117
#ifdef DBG_UTIL
118
void TextListStyle::dump() const
119
{
120
    for ( int i = 0; i < NUM_TEXT_LIST_STYLE_ENTRIES; i++ )
121
    {
122
        SAL_INFO("oox.drawingml", "text list style level: " << i);
123
        maListStyle[i].dump();
124
    }
125
}
126
#endif
127
}
128
129
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */