• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

xlnt-community / xlnt / 796b5d63-faf9-48e9-946d-5f649cf3d172

05 Mar 2025 05:11AM UTC coverage: 82.27% (+0.4%) from 81.87%
796b5d63-faf9-48e9-946d-5f649cf3d172

push

circleci

web-flow
Fix workbook comparisons, cleanup of included headers (#59)

This PR does the following:
1. Fixes issue https://github.com/xlnt-community/xlnt/issues/58. Please
read the issue for detailed infos.
2. Changes / removes a few definitions of `XLNT_API(_INTERNAL)` which
were defined in the wrong places (e.g. `.cpp` file, or in the header
although the function was implemented in the header too).
3. Cleans up many unnecessary or missing headers which I found along the
way.
4. Added `operator!=` to many classes to ease such comparisons and
improve programming experience.

103 of 143 new or added lines in 20 files covered. (72.03%)

3 existing lines in 2 files now uncovered.

11554 of 14044 relevant lines covered (82.27%)

1176465.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.8
./source/worksheet/phonetic_pr.cpp
1
// Copyright (c) 2014-2022 Thomas Fussell
2
// Copyright (c) 2024-2025 xlnt-community
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a copy
5
// of this software and associated documentation files (the "Software"), to deal
6
// in the Software without restriction, including without limitation the rights
7
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
// copies of the Software, and to permit persons to whom the Software is
9
// furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
// THE SOFTWARE
21
//
22
// @license: http://www.opensource.org/licenses/mit-license.php
23
// @author: see AUTHORS file
24

25
#include <xlnt/worksheet/phonetic_pr.hpp>
26
#include <array>
27
namespace {
28
// Order of elements defined by phonetic_pr::Type enum
29
const std::array<std::string, 4> &Types()
343✔
30
{
31
    static const std::array<std::string, 4> types{
32
        std::string("fullwidthKatakana"),
1✔
33
        std::string("halfwidthKatakana"),
34
        std::string("Hiragana"),
35
        std::string("noConversion")};
344✔
36
    return types;
343✔
37
}
38

39
// Order of elements defined by phonetic_pr::alignment enum
40
const std::array<std::string, 4> &Alignments()
2✔
41
{
42
    static const std::array<std::string, 4> alignments{
43
        std::string("Center"),
44
        std::string("Distributed"),
45
        std::string("Left"),
46
        std::string("NoControl")};
2✔
47
    return alignments;
2✔
48
}
49

50
} // namespace
51

52
namespace xlnt {
53
/// <summary>
54
/// out of line initialiser for static const member
55
/// </summary>
56
std::string phonetic_pr::Serialised_ID()
8✔
57
{
58
    return "phoneticPr";
16✔
59
}
60

61
phonetic_pr::phonetic_pr(font_id_t font)
47✔
62
    : font_id_(font)
47✔
63
{
64
}
47✔
65

66
void phonetic_pr::serialise(std::ostream &output_stream) const
×
67
{
68
    output_stream << '<' << Serialised_ID() << R"( fontID=")" << std::to_string(font_id_) << '"';
×
69
    if (has_type())
×
70
    {
71
        output_stream << R"( type=")" << type_as_string(type_.get()) << '"';
×
72
    }
73
    if (has_alignment())
×
74
    {
75
        output_stream << R"( alignment=")" << alignment_as_string(alignment_.get()) << '"';
×
76
    }
77
    output_stream << "/>";
×
78
}
×
79

80
phonetic_pr::font_id_t phonetic_pr::font_id() const
7✔
81
{
82
    return font_id_;
7✔
83
}
84

85
void phonetic_pr::font_id(font_id_t font)
×
86
{
87
    font_id_ = font;
×
88
}
×
89

90
bool phonetic_pr::has_type() const
8✔
91
{
92
    return type_.is_set();
8✔
93
}
94

95
phonetic_pr::phonetic_type phonetic_pr::type() const
5✔
96
{
97
    return type_.get();
5✔
98
}
99

100
void phonetic_pr::type(phonetic_type type)
43✔
101
{
102
    type_.set(type);
43✔
103
}
43✔
104

105
bool phonetic_pr::has_alignment() const
8✔
106
{
107
    return alignment_.is_set();
8✔
108
}
109

110
phonetic_pr::align phonetic_pr::alignment() const
×
111
{
112
    return alignment_.get();
×
113
}
114

115
void phonetic_pr::alignment(align align)
1✔
116
{
117
    alignment_.set(align);
1✔
118
}
1✔
119

120
// serialisation
121
const std::string &phonetic_pr::type_as_string(phonetic_pr::phonetic_type type)
5✔
122
{
123
    return Types()[static_cast<std::size_t>(type)];
5✔
124
}
125

126
phonetic_pr::phonetic_type phonetic_pr::type_from_string(const std::string &str)
43✔
127
{
128
    for (std::size_t i = 0; i < Types().size(); ++i)
338✔
129
    {
130
        if (str == Types()[i])
169✔
131
        {
132
            return static_cast<phonetic_type>(i);
43✔
133
        }
134
    }
135
    return phonetic_type::no_conversion;
×
136
}
137

138
const std::string &phonetic_pr::alignment_as_string(align type)
×
139
{
140
    return Alignments()[static_cast<std::size_t>(type)];
×
141
}
142

143
phonetic_pr::align phonetic_pr::alignment_from_string(const std::string &str)
1✔
144
{
145
    for (std::size_t i = 0; i < Alignments().size(); ++i)
2✔
146
    {
147
        if (str == Alignments()[i])
1✔
148
        {
149
            return static_cast<align>(i);
1✔
150
        }
151
    }
152
    return align::no_control;
×
153
}
154

155
bool phonetic_pr::operator==(const phonetic_pr &rhs) const
2✔
156
{
157
    return font_id_ == rhs.font_id_
2✔
158
        && type_ == rhs.type_
2✔
159
        && alignment_ == rhs.alignment_;
4✔
160
}
161

NEW
162
bool phonetic_pr::operator!=(const phonetic_pr &rhs) const
×
163
{
NEW
164
    return !(*this == rhs);
×
165
}
166

167
} // namespace xlnt
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc