differential code coverage report with master
Current view: top level - source/styles - font.cpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 99.1 % 114 113 1 113
Current Date: 2025-12-07 02:01:22 Functions: 100.0 % 38 38 38
Baseline: coverage_master.info Branches: 75.3 % 81 61 40 122
Baseline Date: 2025-12-07 02:01:21

             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 <cmath>
      27                 :                : 
      28                 :                : #include <xlnt/styles/font.hpp>
      29                 :                : 
      30                 :                : namespace {
      31                 :CBC           2 : const std::string &Default_Name()
      32                 :                : {
      33   [ +  +  +  - ]:              2 :     static const std::string Default("Calibri");
      34                 :              2 :     return Default;
      35                 :                : }
      36                 :                : constexpr double Default_Size = 12.0;
      37                 :                : } // namespace
      38                 :                : 
      39                 :                : namespace xlnt {
      40                 :                : 
      41                 :           1093 : font::font()
      42                 :                : {
      43                 :           1093 : }
      44                 :                : 
      45                 :            187 : font &font::bold(bool bold)
      46                 :                : {
      47                 :            187 :     bold_ = bold;
      48                 :            187 :     return *this;
      49                 :                : }
      50                 :                : 
      51                 :           1605 : bool font::bold() const
      52                 :                : {
      53                 :           1605 :     return bold_;
      54                 :                : }
      55                 :                : 
      56                 :             10 : font &font::superscript(bool value)
      57                 :                : {
      58                 :             10 :     superscript_ = value;
      59                 :             10 :     return *this;
      60                 :                : }
      61                 :                : 
      62                 :           1527 : bool font::superscript() const
      63                 :                : {
      64                 :           1527 :     return superscript_;
      65                 :                : }
      66                 :                : 
      67                 :             19 : font &font::subscript(bool value)
      68                 :                : {
      69                 :             19 :     subscript_ = value;
      70                 :             19 :     return *this;
      71                 :                : }
      72                 :                : 
      73                 :           1515 : bool font::subscript() const
      74                 :                : {
      75                 :           1515 :     return subscript_;
      76                 :                : }
      77                 :                : 
      78                 :             46 : font &font::italic(bool italic)
      79                 :                : {
      80                 :             46 :     italic_ = italic;
      81                 :             46 :     return *this;
      82                 :                : }
      83                 :                : 
      84                 :           1535 : bool font::italic() const
      85                 :                : {
      86                 :           1535 :     return italic_;
      87                 :                : }
      88                 :                : 
      89                 :             23 : font &font::strikethrough(bool strikethrough)
      90                 :                : {
      91                 :             23 :     strikethrough_ = strikethrough;
      92                 :             23 :     return *this;
      93                 :                : }
      94                 :                : 
      95                 :           1547 : bool font::strikethrough() const
      96                 :                : {
      97                 :           1547 :     return strikethrough_;
      98                 :                : }
      99                 :                : 
     100                 :              1 : font &font::outline(bool outline)
     101                 :                : {
     102                 :              1 :     outline_ = outline;
     103                 :              1 :     return *this;
     104                 :                : }
     105                 :                : 
     106                 :             72 : bool font::outline() const
     107                 :                : {
     108                 :             72 :     return outline_;
     109                 :                : }
     110                 :                : 
     111                 :              1 : font &font::shadow(bool shadow)
     112                 :                : {
     113                 :              1 :     shadow_ = shadow;
     114                 :              1 :     return *this;
     115                 :                : }
     116                 :                : 
     117                 :           1272 : bool font::shadow() const
     118                 :                : {
     119                 :           1272 :     return shadow_;
     120                 :                : }
     121                 :                : 
     122                 :             80 : font &font::underline(underline_style new_underline)
     123                 :                : {
     124                 :             80 :     underline_ = new_underline;
     125                 :             80 :     return *this;
     126                 :                : }
     127                 :                : 
     128                 :            214 : bool font::underlined() const
     129                 :                : {
     130                 :            214 :     return underline_ != underline_style::none;
     131                 :                : }
     132                 :                : 
     133                 :           1371 : font::underline_style font::underline() const
     134                 :                : {
     135                 :           1371 :     return underline_;
     136                 :                : }
     137                 :                : 
     138                 :           2459 : bool font::has_size() const
     139                 :                : {
     140                 :           2459 :     return size_.is_set();
     141                 :                : }
     142                 :                : 
     143                 :           1054 : font &font::size(double size)
     144                 :                : {
     145                 :           1054 :     size_ = size;
     146                 :           1054 :     return *this;
     147                 :                : }
     148                 :                : 
     149                 :           1671 : double font::size() const
     150                 :                : {
     151         [ +  - ]:           1671 :     if (size_.is_set())
     152                 :                :     {
     153                 :           1671 :         return size_.get();
     154                 :                :     }
     155                 :UBC           0 :     return Default_Size;
     156                 :                : }
     157                 :                : 
     158                 :CBC        2595 : bool font::has_name() const
     159                 :                : {
     160                 :           2595 :     return name_.is_set();
     161                 :                : }
     162                 :                : 
     163                 :           1067 : font &font::name(const std::string &name)
     164                 :                : {
     165                 :           1067 :     name_ = name;
     166                 :           1067 :     return *this;
     167                 :                : }
     168                 :                : 
     169                 :           1751 : const std::string &font::name() const
     170                 :                : {
     171         [ +  + ]:           1751 :     if (name_.is_set())
     172                 :                :     {
     173                 :           1749 :         return name_.get();
     174                 :                :     }
     175                 :              2 :     return Default_Name();
     176                 :                : }
     177                 :                : 
     178                 :           2342 : bool font::has_color() const
     179                 :                : {
     180                 :           2342 :     return color_.is_set();
     181                 :                : }
     182                 :                : 
     183                 :            962 : font &font::color(const xlnt::color &c)
     184                 :                : {
     185                 :            962 :     color_ = c;
     186                 :            962 :     return *this;
     187                 :                : }
     188                 :                : 
     189                 :           2339 : bool font::has_family() const
     190                 :                : {
     191                 :           2339 :     return family_.is_set();
     192                 :                : }
     193                 :                : 
     194                 :            870 : font &font::family(std::size_t family)
     195                 :                : {
     196                 :            870 :     family_ = family;
     197                 :            870 :     return *this;
     198                 :                : }
     199                 :                : 
     200                 :           2004 : bool font::has_charset() const
     201                 :                : {
     202                 :           2004 :     return charset_.is_set();
     203                 :                : }
     204                 :                : 
     205                 :              1 : font &font::charset(std::size_t charset)
     206                 :                : {
     207                 :              1 :     charset_ = charset;
     208                 :              1 :     return *this;
     209                 :                : }
     210                 :                : 
     211                 :              1 : std::size_t font::charset() const
     212                 :                : {
     213                 :              1 :     return charset_.get();
     214                 :                : }
     215                 :                : 
     216                 :           2331 : bool font::has_scheme() const
     217                 :                : {
     218                 :           2331 :     return scheme_.is_set();
     219                 :                : }
     220                 :                : 
     221                 :            844 : font &font::scheme(const std::string &scheme)
     222                 :                : {
     223                 :            844 :     scheme_ = scheme;
     224                 :            844 :     return *this;
     225                 :                : }
     226                 :                : 
     227                 :           1479 : color font::color() const
     228                 :                : {
     229                 :           1479 :     return color_.get();
     230                 :                : }
     231                 :                : 
     232                 :           1478 : std::size_t font::family() const
     233                 :                : {
     234                 :           1478 :     return family_.get();
     235                 :                : }
     236                 :                : 
     237                 :           1429 : const std::string &font::scheme() const
     238                 :                : {
     239                 :           1429 :     return scheme_.get();
     240                 :                : }
     241                 :                : 
     242                 :            774 : bool font::operator==(const font &other) const
     243                 :                : {
     244                 :                :     // name
     245         [ +  + ]:            774 :     if (has_name() != other.has_name()) return false;
     246   [ +  +  +  +  :            745 :     if (has_name() && name() != other.name()) return false;
                   +  + ]
     247                 :                :     // size
     248         [ -  + ]:            719 :     if (has_size() != other.has_size()) return false;
     249   [ +  +  +  +  :            719 :     if (has_size() && std::fabs(size() - other.size()) != 0.0) return false;
                   +  + ]
     250                 :                :     // family
     251         [ +  + ]:            684 :     if (has_family() != other.has_family()) return false;
     252   [ +  +  -  +  :            680 :     if (has_family() && family() != other.family()) return false;
                   -  + ]
     253                 :                :     // scheme
     254         [ -  + ]:            680 :     if (has_scheme() != other.has_scheme()) return false;
     255   [ +  +  -  +  :            680 :     if (has_scheme() && scheme() != other.scheme()) return false;
                   -  + ]
     256                 :                :     // color
     257         [ -  + ]:            680 :     if (has_color() != other.has_color()) return false;
     258   [ +  +  +  +  :            680 :     if (has_color() && color() != other.color()) return false;
          +  +  +  +  +  
          +  +  +  +  -  
                -  -  - ]
     259                 :                :     // charset
     260         [ -  + ]:            644 :     if (has_charset() != other.has_charset()) return false;
     261   [ -  +  -  -  :            644 :     if (has_charset() && charset() != other.charset()) return false;
                   -  + ]
     262                 :                :     // modifiers
     263         [ +  + ]:            644 :     if (bold() != other.bold()) return false;
     264         [ -  + ]:            630 :     if (italic() != other.italic()) return false;
     265         [ +  + ]:            630 :     if (strikethrough() != other.strikethrough()) return false;
     266         [ +  + ]:            626 :     if (superscript() != other.superscript()) return false;
     267         [ +  + ]:            622 :     if (subscript() != other.subscript()) return false;
     268         [ +  + ]:            618 :     if (underline() != other.underline()) return false;
     269         [ -  + ]:            600 :     if (shadow() != other.shadow()) return false;
     270                 :                : 
     271                 :            600 :     return true;
     272                 :                : }
     273                 :                : 
     274                 :                : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta