differential code coverage report with master
Current view: top level - source/styles - border.cpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 81.6 % 87 71 16 71
Current Date: 2025-12-15 23:01:28 Functions: 92.9 % 14 13 1 13
Baseline: coverage_master.info Branches: 62.1 % 58 36 44 72
Baseline Date: 2025-12-15 23:01:27

             Branch data    TLA  Line data    Source code
       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                 :                : 
      26                 :                : #include <xlnt/styles/border.hpp>
      27                 :                : #include <xlnt/utils/exceptions.hpp>
      28                 :                : #include <detail/default_case.hpp>
      29                 :                : 
      30                 :                : namespace xlnt {
      31                 :                : 
      32                 :CBC        8411 : optional<xlnt::color> border::border_property::color() const
      33                 :                : {
      34                 :           8411 :     return color_;
      35                 :                : }
      36                 :                : 
      37                 :            279 : border::border_property &border::border_property::color(const xlnt::color &c)
      38                 :                : {
      39                 :            279 :     color_ = c;
      40                 :            279 :     return *this;
      41                 :                : }
      42                 :                : 
      43                 :           8411 : optional<border_style> border::border_property::style() const
      44                 :                : {
      45                 :           8411 :     return style_;
      46                 :                : }
      47                 :                : 
      48                 :            280 : border::border_property &border::border_property::style(border_style s)
      49                 :                : {
      50                 :            280 :     style_ = s;
      51                 :            280 :     return *this;
      52                 :                : }
      53                 :                : 
      54                 :           2625 : bool border::border_property::operator==(const border::border_property &right) const
      55                 :                : {
      56                 :           2625 :     auto &left = *this;
      57                 :                : 
      58         [ -  + ]:           2625 :     if (left.style().is_set() != right.style().is_set())
      59                 :                :     {
      60                 :UBC           0 :         return false;
      61                 :                :     }
      62                 :                : 
      63         [ -  + ]:CBC        2625 :     if (left.style().is_set())
      64                 :                :     {
      65   [ #  #  #  # ]:UBC           0 :         if (left.style().get() != right.style().get())
      66                 :                :         {
      67                 :              0 :             return false;
      68                 :                :         }
      69                 :                :     }
      70                 :                : 
      71         [ -  + ]:CBC        2625 :     if (left.color().is_set() != right.color().is_set())
      72                 :                :     {
      73                 :UBC           0 :         return false;
      74                 :                :     }
      75                 :                : 
      76         [ -  + ]:CBC        2625 :     if (left.color().is_set())
      77                 :                :     {
      78   [ #  #  #  #  :UBC           0 :         if (left.color().get() != right.color().get())
                      # ]
      79                 :                :         {
      80                 :              0 :             return false;
      81                 :                :         }
      82                 :                :     }
      83                 :                : 
      84                 :CBC        2625 :     return true;
      85                 :                : }
      86                 :                : 
      87                 :           2625 : bool border::border_property::operator!=(const border::border_property &right) const
      88                 :                : {
      89                 :           2625 :     return !(*this == right);
      90                 :                : }
      91                 :                : 
      92                 :            450 : border::border()
      93                 :                : {
      94                 :            450 : }
      95                 :                : 
      96                 :            614 : const std::vector<xlnt::border_side> &border::all_sides()
      97                 :                : {
      98                 :                :     static auto sides = std::vector<xlnt::border_side>{xlnt::border_side::start, xlnt::border_side::end,
      99                 :                :         xlnt::border_side::top, xlnt::border_side::bottom, xlnt::border_side::diagonal, xlnt::border_side::vertical,
     100   [ +  +  +  -  :            616 :         xlnt::border_side::horizontal};
                +  -  - ]
     101                 :                : 
     102                 :            614 :     return sides;
     103                 :                : }
     104                 :                : 
     105                 :          17336 : optional<border::border_property> border::side(border_side s) const
     106                 :                : {
     107   [ +  +  +  +  :          17336 :     switch (s)
             +  +  +  - ]
     108                 :                :     {
     109                 :           2800 :     case border_side::bottom:
     110                 :           2800 :         return bottom_;
     111                 :           2800 :     case border_side::top:
     112                 :           2800 :         return top_;
     113                 :           2804 :     case border_side::start:
     114                 :           2804 :         return start_;
     115                 :           2800 :     case border_side::end:
     116                 :           2800 :         return end_;
     117                 :           1666 :     case border_side::vertical:
     118                 :           1666 :         return vertical_;
     119                 :           1666 :     case border_side::horizontal:
     120                 :           1666 :         return horizontal_;
     121                 :           2800 :     case border_side::diagonal:
     122                 :           2800 :         return diagonal_;
     123                 :                :     }
     124                 :                : 
     125            [ # ]:UBC           0 :     default_case(start_);
     126                 :                : }
     127                 :                : 
     128                 :CBC        2226 : border &border::side(border_side s, const border_property &prop)
     129                 :                : {
     130   [ +  +  +  +  :           2226 :     switch (s)
             -  -  +  - ]
     131                 :                :     {
     132                 :            446 :     case border_side::bottom:
     133                 :            446 :         bottom_ = prop;
     134                 :            446 :         break;
     135                 :            445 :     case border_side::top:
     136                 :            445 :         top_ = prop;
     137                 :            445 :         break;
     138                 :            445 :     case border_side::start:
     139                 :            445 :         start_ = prop;
     140                 :            445 :         break;
     141                 :            445 :     case border_side::end:
     142                 :            445 :         end_ = prop;
     143                 :            445 :         break;
     144                 :UBC           0 :     case border_side::vertical:
     145                 :              0 :         vertical_ = prop;
     146                 :              0 :         break;
     147                 :              0 :     case border_side::horizontal:
     148                 :              0 :         horizontal_ = prop;
     149                 :              0 :         break;
     150                 :CBC         445 :     case border_side::diagonal:
     151                 :            445 :         diagonal_ = prop;
     152                 :            445 :         break;
     153                 :                :     }
     154                 :                : 
     155                 :           2226 :     return *this;
     156                 :                : }
     157                 :                : 
     158                 :              1 : border &border::diagonal(diagonal_direction direction)
     159                 :                : {
     160                 :              1 :     diagonal_direction_ = direction;
     161                 :              1 :     return *this;
     162                 :                : }
     163                 :                : 
     164                 :             85 : optional<diagonal_direction> border::diagonal() const
     165                 :                : {
     166                 :             85 :     return diagonal_direction_;
     167                 :                : }
     168                 :                : 
     169                 :            529 : bool border::operator==(const border &right) const
     170                 :                : {
     171                 :            529 :     auto &left = *this;
     172                 :                : 
     173      [ +  +  + ]:           4218 :     for (auto side : border::all_sides())
     174                 :                :     {
     175   [ +  +  +  + ]:           3691 :         if (left.side(side).is_set() != right.side(side).is_set())
     176                 :                :         {
     177                 :              2 :             return false;
     178                 :                :         }
     179                 :                : 
     180      [ +  +  + ]:           3689 :         if (left.side(side).is_set())
     181                 :                :         {
     182   [ +  +  +  +  :           2625 :             if (left.side(side).get() != right.side(side).get())
                +  -  + ]
     183                 :                :             {
     184                 :UBC           0 :                 return false;
     185                 :                :             }
     186                 :                :         }
     187                 :                :     }
     188                 :                : 
     189                 :CBC         527 :     return true;
     190                 :                : }
     191                 :                : 
     192                 :UBC           0 : bool border::operator!=(const border &right) const
     193                 :                : {
     194                 :              0 :     return !(*this == right);
     195                 :                : }
     196                 :                : 
     197                 :                : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta