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

xlnt-community / xlnt / aa719a12-330c-47b2-9460-5b2d61336ff6

03 Feb 2025 05:39PM UTC coverage: 81.978% (-1.5%) from 83.482%
aa719a12-330c-47b2-9460-5b2d61336ff6

push

circleci

web-flow
Use C++23 for generating coverage report. (#57)

Using C++23 for coverage reporting, prepares the library for coverage
testing of future post-C++11 features.

This PR makes as few changes as possible to ensure all coverage changes
are due to the changed C++/compiler version used for generating the
coverage report.

Temporarily disable warnings as errors for coverage reporting until
better C++20/23 support is added in PR #55.

11395 of 13900 relevant lines covered (81.98%)

1202684.1 hits per line

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

81.48
./source/drawing/spreadsheet_drawing.cpp
1
// Copyright (c) 2018-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/drawing/spreadsheet_drawing.hpp>
26
#include <detail/constants.hpp>
27

28
#include <detail/external/include_libstudxml.hpp>
29

30
namespace {
31
// copy elements to the serializer provided and extract the embed ids
32
// from blip elements
33
std::vector<std::string> copy_and_extract(xml::parser &p, xml::serializer &s)
5✔
34
{
35
    std::vector<std::string> embed_ids;
5✔
36
    int nest_level = 0;
5✔
37
    while (nest_level > 0 || (p.peek() != xml::parser::event_type::end_element && p.peek() != xml::parser::event_type::eof))
219✔
38
    {
39
        switch (p.next())
214✔
40
        {
41
        case xml::parser::start_element: {
95✔
42
            ++nest_level;
95✔
43
            auto attribs = p.attribute_map();
95✔
44
            auto current_ns = p.namespace_();
95✔
45
            s.start_element(p.qname());
95✔
46
            s.namespace_decl(current_ns, p.prefix());
95✔
47
            if (p.qname().name() == "blip")
95✔
48
            {
49
                embed_ids.push_back(attribs.at(xml::qname(xlnt::constants::ns("r"), "embed")).value);
12✔
50
            }
51
            p.peek();
95✔
52
            auto new_ns = p.namespace_();
95✔
53
            if (new_ns != current_ns)
95✔
54
            {
55
                auto pref = p.prefix();
15✔
56
                s.namespace_decl(new_ns, pref);
15✔
57
            }
15✔
58
            for (auto &ele : attribs)
131✔
59
            {
60
                s.attribute(ele.first, ele.second.value);
36✔
61
            }
62
            break;
95✔
63
        }
95✔
64
        case xml::parser::end_element: {
95✔
65
            --nest_level;
95✔
66
            s.end_element();
95✔
67
            break;
95✔
68
        }
69
        case xml::parser::start_namespace_decl: {
×
70
            s.namespace_decl(p.namespace_(), p.prefix());
×
71
            break;
×
72
        }
73
        case xml::parser::end_namespace_decl: { // nothing required here
×
74
            break;
×
75
        }
76
        case xml::parser::characters: {
24✔
77
            s.characters(p.value());
24✔
78
            break;
24✔
79
        }
80
        case xml::parser::eof:
×
81
            return embed_ids;
×
82
        case xml::parser::start_attribute:
×
83
        case xml::parser::end_attribute:
84
        default:
85
            break;
×
86
        }
87
    }
88
    return embed_ids;
5✔
89
}
×
90
} // namespace
91

92
namespace xlnt {
93
namespace drawing {
94

95
spreadsheet_drawing::spreadsheet_drawing(xml::parser &parser)
3✔
96
{
97
    std::ostringstream serialization_stream;
3✔
98
    xml::serializer s(serialization_stream, "", 0);
3✔
99
    embed_ids_ = copy_and_extract(parser, s);
3✔
100
    serialized_value_ = serialization_stream.str();
3✔
101
}
3✔
102

103
// void spreadsheet_drawing::serialize(xml::serializer &serializer, const std::string& ns)
104
void spreadsheet_drawing::serialize(xml::serializer &serializer)
2✔
105
{
106
    std::istringstream ser(serialized_value_);
2✔
107
    xml::parser p(ser, "", xml::parser::receive_default);
2✔
108
    copy_and_extract(p, serializer);
2✔
109
}
2✔
110

111
std::vector<std::string> spreadsheet_drawing::get_embed_ids()
3✔
112
{
113
    return embed_ids_;
3✔
114
}
115

116
} // namespace drawing
117
} // 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