Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sw/source/uibase/chrdlg/ccoll.cxx
Line
Count
Source (jump to first uncovered line)
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 <cmdid.h>
21
22
#include <ccoll.hxx>
23
#include <fmtcol.hxx>
24
#include <o3tl/string_view.hxx>
25
26
//!! order of entries has to be the same as in
27
//!! CommandStruct SwCondCollItem::aCmds[]
28
29
// note: also keep this in sync with the list of conditions in xmloff/source/style/prstylecond.cxx
30
31
constexpr OUString aCommandContext[COND_COMMAND_COUNT] =
32
{
33
    u"TableHeader"_ustr,
34
    u"Table"_ustr,
35
    u"Frame"_ustr,
36
    u"Section"_ustr,
37
    u"Footnote"_ustr,
38
    u"Endnote"_ustr,
39
    u"Header"_ustr,
40
    u"Footer"_ustr,
41
    u"OutlineLevel1"_ustr,
42
    u"OutlineLevel2"_ustr,
43
    u"OutlineLevel3"_ustr,
44
    u"OutlineLevel4"_ustr,
45
    u"OutlineLevel5"_ustr,
46
    u"OutlineLevel6"_ustr,
47
    u"OutlineLevel7"_ustr,
48
    u"OutlineLevel8"_ustr,
49
    u"OutlineLevel9"_ustr,
50
    u"OutlineLevel10"_ustr,
51
    u"NumberingLevel1"_ustr,
52
    u"NumberingLevel2"_ustr,
53
    u"NumberingLevel3"_ustr,
54
    u"NumberingLevel4"_ustr,
55
    u"NumberingLevel5"_ustr,
56
    u"NumberingLevel6"_ustr,
57
    u"NumberingLevel7"_ustr,
58
    u"NumberingLevel8"_ustr,
59
    u"NumberingLevel9"_ustr,
60
    u"NumberingLevel10"_ustr
61
};
62
63
sal_Int16 GetCommandContextIndex( std::u16string_view rContextName )
64
0
{
65
0
    sal_Int16 nRes = -1;
66
0
    for (sal_Int16 i = 0;  nRes == -1 && i < COND_COMMAND_COUNT;  ++i)
67
0
    {
68
0
        if (aCommandContext[i] == rContextName)
69
0
            nRes = i;
70
0
    }
71
0
    return nRes;
72
0
}
73
74
OUString GetCommandContextByIndex( sal_Int16 nIndex )
75
0
{
76
0
    OUString aRes;
77
0
    if (0 <= nIndex  &&  nIndex < COND_COMMAND_COUNT)
78
0
    {
79
0
        aRes = aCommandContext[ nIndex ];
80
0
    }
81
0
    return aRes;
82
0
}
83
84
// Globals
85
86
const CommandStruct SwCondCollItem::s_aCmds[] =
87
{
88
    { Master_CollCondition::PARA_IN_TABLEHEAD,    0 },
89
    { Master_CollCondition::PARA_IN_TABLEBODY,    0 },
90
    { Master_CollCondition::PARA_IN_FRAME,        0 },
91
    { Master_CollCondition::PARA_IN_SECTION,      0 },
92
    { Master_CollCondition::PARA_IN_FOOTNOTE,     0 },
93
    { Master_CollCondition::PARA_IN_ENDNOTE,      0 },
94
    { Master_CollCondition::PARA_IN_HEADER,       0 },
95
    { Master_CollCondition::PARA_IN_FOOTER,       0 },
96
    { Master_CollCondition::PARA_IN_OUTLINE,      0 },
97
    { Master_CollCondition::PARA_IN_OUTLINE,      1 },
98
    { Master_CollCondition::PARA_IN_OUTLINE,      2 },
99
    { Master_CollCondition::PARA_IN_OUTLINE,      3 },
100
    { Master_CollCondition::PARA_IN_OUTLINE,      4 },
101
    { Master_CollCondition::PARA_IN_OUTLINE,      5 },
102
    { Master_CollCondition::PARA_IN_OUTLINE,      6 },
103
    { Master_CollCondition::PARA_IN_OUTLINE,      7 },
104
    { Master_CollCondition::PARA_IN_OUTLINE,      8 },
105
    { Master_CollCondition::PARA_IN_OUTLINE,      9 },
106
    { Master_CollCondition::PARA_IN_LIST,         0 },
107
    { Master_CollCondition::PARA_IN_LIST,         1 },
108
    { Master_CollCondition::PARA_IN_LIST,         2 },
109
    { Master_CollCondition::PARA_IN_LIST,         3 },
110
    { Master_CollCondition::PARA_IN_LIST,         4 },
111
    { Master_CollCondition::PARA_IN_LIST,         5 },
112
    { Master_CollCondition::PARA_IN_LIST,         6 },
113
    { Master_CollCondition::PARA_IN_LIST,         7 },
114
    { Master_CollCondition::PARA_IN_LIST,         8 },
115
    { Master_CollCondition::PARA_IN_LIST,         9 }
116
};
117
118
119
// Item for the transport of the condition table
120
SwCondCollItem::SwCondCollItem() :
121
0
    SfxPoolItem(FN_COND_COLL)
122
0
{
123
0
}
124
125
SwCondCollItem::~SwCondCollItem()
126
0
{
127
0
}
128
129
SwCondCollItem* SwCondCollItem::Clone( SfxItemPool * /*pPool*/ ) const
130
0
{
131
0
    return new SwCondCollItem(*this);
132
0
}
133
134
bool SwCondCollItem::operator==( const SfxPoolItem& rItem) const
135
0
{
136
0
    assert(SfxPoolItem::operator==(rItem));
137
0
    bool bReturn = true;
138
0
    for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
139
0
        if (m_sStyles[i] !=
140
0
                static_cast<SwCondCollItem const&>(rItem).m_sStyles[i])
141
0
        {
142
0
            bReturn = false;
143
0
            break;
144
0
        }
145
146
0
    return bReturn;
147
0
}
148
149
UIName SwCondCollItem::GetStyle(sal_uInt16 const nPos) const
150
0
{
151
0
    return (nPos < COND_COMMAND_COUNT) ? m_sStyles[nPos] : UIName();
152
0
}
153
154
void
155
SwCondCollItem::SetStyle(UIName const*const pStyle, sal_uInt16 const nPos)
156
0
{
157
0
    if( nPos < COND_COMMAND_COUNT )
158
0
        m_sStyles[nPos] = pStyle ? *pStyle : UIName();
159
0
}
160
161
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */