differential code coverage report with master
Current view: top level - source/worksheet - phonetic_pr.cpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 67.8 % 59 40 19 40
Current Date: 2025-12-15 23:01:28 Functions: 73.7 % 19 14 5 14
Baseline: coverage_master.info Branches: 45.2 % 42 19 46 38
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) 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                 :CBC         343 : const std::array<std::string, 4> &Types()
      30                 :                : {
      31                 :                :     static const std::array<std::string, 4> types{
      32                 :              1 :         std::string("fullwidthKatakana"),
      33                 :                :         std::string("halfwidthKatakana"),
      34                 :                :         std::string("Hiragana"),
      35   [ +  +  +  -  :            344 :         std::string("noConversion")};
          +  +  +  +  -  
             -  -  -  -  
                      - ]
      36                 :            343 :     return types;
      37                 :                : }
      38                 :                : 
      39                 :                : // Order of elements defined by phonetic_pr::alignment enum
      40                 :              2 : const std::array<std::string, 4> &Alignments()
      41                 :                : {
      42                 :                :     static const std::array<std::string, 4> alignments{
      43                 :                :         std::string("Center"),
      44                 :                :         std::string("Distributed"),
      45                 :                :         std::string("Left"),
      46   [ +  +  +  - ]:              2 :         std::string("NoControl")};
      47                 :              2 :     return alignments;
      48                 :                : }
      49                 :                : 
      50                 :                : } // namespace
      51                 :                : 
      52                 :                : namespace xlnt {
      53                 :                : /// <summary>
      54                 :                : /// out of line initialiser for static const member
      55                 :                : /// </summary>
      56                 :              8 : std::string phonetic_pr::Serialised_ID()
      57                 :                : {
      58            [ + ]:             16 :     return "phoneticPr";
      59                 :                : }
      60                 :                : 
      61                 :             47 : phonetic_pr::phonetic_pr(font_id_t font)
      62                 :             47 :     : font_id_(font)
      63                 :                : {
      64                 :             47 : }
      65                 :                : 
      66                 :UBC           0 : void phonetic_pr::serialise(std::ostream &output_stream) const
      67                 :                : {
      68   [ #  #  #  #  :              0 :     output_stream << '<' << Serialised_ID() << R"( fontID=")" << std::to_string(font_id_) << '"';
                      # ]
      69         [ #  # ]:              0 :     if (has_type())
      70                 :                :     {
      71                 :              0 :         output_stream << R"( type=")" << type_as_string(type_.get()) << '"';
      72                 :                :     }
      73         [ #  # ]:              0 :     if (has_alignment())
      74                 :                :     {
      75                 :              0 :         output_stream << R"( alignment=")" << alignment_as_string(alignment_.get()) << '"';
      76                 :                :     }
      77                 :              0 :     output_stream << "/>";
      78                 :              0 : }
      79                 :                : 
      80                 :CBC           7 : phonetic_pr::font_id_t phonetic_pr::font_id() const
      81                 :                : {
      82                 :              7 :     return font_id_;
      83                 :                : }
      84                 :                : 
      85                 :UBC           0 : void phonetic_pr::font_id(font_id_t font)
      86                 :                : {
      87                 :              0 :     font_id_ = font;
      88                 :              0 : }
      89                 :                : 
      90                 :CBC           8 : bool phonetic_pr::has_type() const
      91                 :                : {
      92                 :              8 :     return type_.is_set();
      93                 :                : }
      94                 :                : 
      95                 :              5 : phonetic_pr::phonetic_type phonetic_pr::type() const
      96                 :                : {
      97                 :              5 :     return type_.get();
      98                 :                : }
      99                 :                : 
     100                 :             43 : void phonetic_pr::type(phonetic_type type)
     101                 :                : {
     102                 :             43 :     type_.set(type);
     103                 :             43 : }
     104                 :                : 
     105                 :              8 : bool phonetic_pr::has_alignment() const
     106                 :                : {
     107                 :              8 :     return alignment_.is_set();
     108                 :                : }
     109                 :                : 
     110                 :UBC           0 : phonetic_pr::align phonetic_pr::alignment() const
     111                 :                : {
     112                 :              0 :     return alignment_.get();
     113                 :                : }
     114                 :                : 
     115                 :CBC           1 : void phonetic_pr::alignment(align align)
     116                 :                : {
     117                 :              1 :     alignment_.set(align);
     118                 :              1 : }
     119                 :                : 
     120                 :                : // serialisation
     121                 :              5 : const std::string &phonetic_pr::type_as_string(phonetic_pr::phonetic_type type)
     122                 :                : {
     123                 :              5 :     return Types()[static_cast<std::size_t>(type)];
     124                 :                : }
     125                 :                : 
     126                 :             43 : phonetic_pr::phonetic_type phonetic_pr::type_from_string(const std::string &str)
     127                 :                : {
     128         [ +  - ]:            338 :     for (std::size_t i = 0; i < Types().size(); ++i)
     129                 :                :     {
     130         [ +  + ]:            169 :         if (str == Types()[i])
     131                 :                :         {
     132                 :             43 :             return static_cast<phonetic_type>(i);
     133                 :                :         }
     134                 :                :     }
     135                 :UBC           0 :     return phonetic_type::no_conversion;
     136                 :                : }
     137                 :                : 
     138                 :              0 : const std::string &phonetic_pr::alignment_as_string(align type)
     139                 :                : {
     140                 :              0 :     return Alignments()[static_cast<std::size_t>(type)];
     141                 :                : }
     142                 :                : 
     143                 :CBC           1 : phonetic_pr::align phonetic_pr::alignment_from_string(const std::string &str)
     144                 :                : {
     145         [ +  - ]:              2 :     for (std::size_t i = 0; i < Alignments().size(); ++i)
     146                 :                :     {
     147         [ +  - ]:              1 :         if (str == Alignments()[i])
     148                 :                :         {
     149                 :              1 :             return static_cast<align>(i);
     150                 :                :         }
     151                 :                :     }
     152                 :UBC           0 :     return align::no_control;
     153                 :                : }
     154                 :                : 
     155                 :CBC           2 : bool phonetic_pr::operator==(const phonetic_pr &rhs) const
     156                 :                : {
     157                 :              2 :     return font_id_ == rhs.font_id_
     158         [ +  - ]:              2 :         && type_ == rhs.type_
     159   [ +  -  +  - ]:              4 :         && alignment_ == rhs.alignment_;
     160                 :                : }
     161                 :                : 
     162                 :UBC           0 : bool phonetic_pr::operator!=(const phonetic_pr &rhs) const
     163                 :                : {
     164                 :              0 :     return !(*this == rhs);
     165                 :                : }
     166                 :                : 
     167                 :                : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta