• 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

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

30
namespace {
31

32
/// <summary>
33
/// Return a vector containing string split at each delim.
34
/// </summary>
35
/// <remark>
36
/// This should maybe be in a utility header so it can be used elsewhere.
37
/// </remarks>
38
/*
39
std::vector<std::string> split_string(const std::string &string, char delim)
40
{
41
    std::vector<std::string> split;
42
    std::string::size_type previous_index = 0;
43
    auto separator_index = string.find(delim);
44

45
    while (separator_index != std::string::npos)
46
    {
47
        auto part = string.substr(previous_index, separator_index - previous_index);
48
        split.push_back(part);
49

50
        previous_index = separator_index + 1;
51
        separator_index = string.find(delim, previous_index);
52
    }
53

54
    split.push_back(string.substr(previous_index));
55

56
    return split;
57
}
58
*/
59

60
/*
61
std::vector<std::pair<std::string, std::string>> split_named_range(const std::string &named_range_string)
62
{
63
    std::vector<std::pair<std::string, std::string>> result;
64

65
    for (auto part : split_string(named_range_string, ','))
66
    {
67
        auto split = split_string(part, '!');
68

69
        if (split[0].front() == '\'' && split[0].back() == '\'')
70
        {
71
            split[0] = split[0].substr(1, split[0].length() - 2);
72
        }
73

74
        // Try to parse it. Use empty string if it's not a valid range.
75
        try
76
        {
77
            xlnt::range_reference ref(split[1]);
78
        }
79
        catch (xlnt::invalid_cell_reference)
80
        {
81
            split[1] = "";
82
        }
83

84
        result.push_back({ split[0], split[1] });
85
    }
86

87
    return result;
88
}
89
*/
90

91
} // namespace
92

93
namespace xlnt {
94

95
std::string named_range::name() const
×
96
{
97
    return name_;
×
98
}
99

100
const std::vector<named_range::target> &named_range::targets() const
7✔
101
{
102
    return targets_;
7✔
103
}
104

105
named_range::named_range()
10✔
106
{
107
}
10✔
108

109
named_range::named_range(const named_range &other)
×
110
{
111
    *this = other;
×
112
}
×
113

114
named_range::named_range(const std::string &name, const std::vector<named_range::target> &targets)
10✔
115
    : name_(name), targets_(targets)
10✔
116
{
117
}
10✔
118

119
named_range &named_range::operator=(const named_range &other)
10✔
120
{
121
    name_ = other.name_;
10✔
122
    targets_ = other.targets_;
10✔
123

124
    return *this;
10✔
125
}
126

127
bool named_range::operator==(const named_range &rhs) const
×
128
{
129
    return name_ == rhs.name_
×
130
        && targets_ == rhs.targets_;
×
131
}
132

NEW
133
bool named_range::operator!=(const named_range &rhs) const
×
134
{
NEW
135
    return !(*this == rhs);
×
136
}
137

138
} // 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