differential code coverage report with master
Current view: top level - source/detail/implementations - worksheet_impl.hpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 100.0 % 58 58 58
Current Date: 2025-12-15 23:01:28 Functions: 100.0 % 4 4 4
Baseline: coverage_master.info Branches: 56.5 % 46 26 40 52
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                 :                : #pragma once
      26                 :                : 
      27                 :                : #include <string>
      28                 :                : #include <unordered_map>
      29                 :                : #include <vector>
      30                 :                : 
      31                 :                : #include <xlnt/drawing/spreadsheet_drawing.hpp>
      32                 :                : #include <xlnt/packaging/ext_list.hpp>
      33                 :                : #include <xlnt/workbook/named_range.hpp>
      34                 :                : #include <xlnt/worksheet/column_properties.hpp>
      35                 :                : #include <xlnt/worksheet/header_footer.hpp>
      36                 :                : #include <xlnt/worksheet/phonetic_pr.hpp>
      37                 :                : #include <xlnt/worksheet/range.hpp>
      38                 :                : #include <xlnt/worksheet/range_reference.hpp>
      39                 :                : #include <xlnt/worksheet/row_properties.hpp>
      40                 :                : #include <xlnt/worksheet/sheet_format_properties.hpp>
      41                 :                : #include <xlnt/worksheet/sheet_view.hpp>
      42                 :                : #include <xlnt/worksheet/print_options.hpp>
      43                 :                : #include <xlnt/worksheet/sheet_pr.hpp>
      44                 :                : #include <detail/implementations/cell_impl.hpp>
      45                 :                : #include <detail/implementations/workbook_impl.hpp>
      46                 :                : 
      47                 :                : namespace xlnt {
      48                 :                : 
      49                 :                : class workbook;
      50                 :                : 
      51                 :                : namespace detail {
      52                 :                : 
      53                 :                : struct worksheet_impl
      54                 :                : {
      55                 :CBC         430 :     worksheet_impl(workbook *parent_workbook, std::size_t id, const std::string &title)
      56                 :            430 :         : parent_(parent_workbook->d_),
      57                 :            430 :           id_(id),
      58            [ + ]:            430 :           title_(title)
      59                 :                :     {
      60                 :            430 :     }
      61                 :                : 
      62                 :            306 :     worksheet_impl(const worksheet_impl &other)
      63                 :            306 :     {
      64            [ + ]:            306 :         *this = other;
      65                 :            306 :     }
      66                 :                : 
      67                 :            308 :     void operator=(const worksheet_impl &other)
      68                 :                :     {
      69                 :            308 :         parent_ = other.parent_;
      70                 :                : 
      71                 :            308 :         id_ = other.id_;
      72                 :            308 :         title_ = other.title_;
      73                 :            308 :         format_properties_ = other.format_properties_;
      74                 :            308 :         column_properties_ = other.column_properties_;
      75                 :            308 :         row_properties_ = other.row_properties_;
      76                 :            308 :         cell_map_ = other.cell_map_;
      77                 :            308 :         page_setup_ = other.page_setup_;
      78                 :            308 :         auto_filter_ = other.auto_filter_;
      79                 :            308 :         page_margins_ = other.page_margins_;
      80                 :            308 :         merged_cells_ = other.merged_cells_;
      81                 :            308 :         named_ranges_ = other.named_ranges_;
      82                 :            308 :         phonetic_properties_ = other.phonetic_properties_;
      83                 :            308 :         header_footer_ = other.header_footer_;
      84                 :            308 :         print_title_cols_ = other.print_title_cols_;
      85                 :            308 :         print_title_rows_ = other.print_title_rows_;
      86                 :            308 :         print_area_ = other.print_area_;
      87                 :            308 :         views_ = other.views_;
      88                 :            308 :         column_breaks_ = other.column_breaks_;
      89                 :            308 :         row_breaks_ = other.row_breaks_;
      90                 :            308 :         extension_list_ = other.extension_list_;
      91                 :            308 :         sheet_properties_ = other.sheet_properties_;
      92                 :            308 :         print_options_ = other.print_options_;
      93                 :                : 
      94         [ +  + ]:            313 :         for (auto &cell : cell_map_)
      95                 :                :         {
      96                 :              5 :             cell.second.parent_ = this;
      97                 :                :         }
      98                 :            308 :     }
      99                 :                : 
     100                 :                :     std::weak_ptr<workbook_impl> parent_;
     101                 :                : 
     102                 :             16 :     bool operator==(const worksheet_impl& rhs) const
     103                 :                :     {
     104                 :                :         // not comparing parent, id, title (title must be unique)
     105                 :             16 :         return format_properties_ == rhs.format_properties_
     106         [ +  - ]:             16 :             && column_properties_ == rhs.column_properties_
     107         [ +  - ]:             16 :             && row_properties_ == rhs.row_properties_
     108         [ +  + ]:             16 :             && cell_map_ == rhs.cell_map_
     109         [ +  - ]:             15 :             && page_setup_ == rhs.page_setup_
     110         [ +  - ]:             15 :             && auto_filter_ == rhs.auto_filter_
     111         [ +  - ]:             15 :             && page_margins_ == rhs.page_margins_
     112         [ +  - ]:             15 :             && merged_cells_ == rhs.merged_cells_
     113         [ +  - ]:             15 :             && named_ranges_ == rhs.named_ranges_
     114         [ +  - ]:             15 :             && phonetic_properties_ == rhs.phonetic_properties_
     115         [ +  - ]:             15 :             && header_footer_ == rhs.header_footer_
     116         [ +  - ]:             15 :             && print_title_cols_ == rhs.print_title_cols_
     117         [ +  - ]:             15 :             && print_title_rows_ == rhs.print_title_rows_
     118         [ +  - ]:             15 :             && print_area_ == rhs.print_area_
     119         [ +  - ]:             15 :             && views_ == rhs.views_
     120         [ +  - ]:             15 :             && column_breaks_ == rhs.column_breaks_
     121         [ +  - ]:             15 :             && row_breaks_ == rhs.row_breaks_
     122         [ +  - ]:             15 :             && comments_ == rhs.comments_
     123         [ +  - ]:             15 :             && print_options_ == rhs.print_options_
     124         [ +  - ]:             15 :             && sheet_properties_ == rhs.sheet_properties_
     125   [ +  -  +  - ]:             32 :             && extension_list_ == rhs.extension_list_;
     126                 :                :     }
     127                 :                : 
     128                 :                :     bool operator!=(const worksheet_impl& rhs) const
     129                 :                :     {
     130                 :                :         return !(*this == rhs);
     131                 :                :     }
     132                 :                : 
     133                 :                :     std::size_t id_ = 0;
     134                 :                :     std::string title_;
     135                 :                : 
     136                 :                :     sheet_format_properties format_properties_;
     137                 :                : 
     138                 :                :     std::unordered_map<column_t, column_properties> column_properties_;
     139                 :                :     std::unordered_map<row_t, row_properties> row_properties_;
     140                 :                : 
     141                 :                :     std::unordered_map<cell_reference, cell_impl> cell_map_;
     142                 :                : 
     143                 :                :     optional<page_setup> page_setup_;
     144                 :                :     optional<range_reference> auto_filter_;
     145                 :                :     optional<page_margins> page_margins_;
     146                 :                :     std::vector<range_reference> merged_cells_;
     147                 :                :     std::unordered_map<std::string, named_range> named_ranges_;
     148                 :                : 
     149                 :                :     optional<phonetic_pr> phonetic_properties_;
     150                 :                :     optional<header_footer> header_footer_;
     151                 :                : 
     152                 :                :     optional<std::pair<column_t, column_t>> print_title_cols_;
     153                 :                :     optional<std::pair<row_t, row_t>> print_title_rows_;
     154                 :                :     optional<range_reference> print_area_;
     155                 :                : 
     156                 :                :     std::vector<sheet_view> views_;
     157                 :                : 
     158                 :                :     std::vector<column_t> column_breaks_;
     159                 :                :     std::vector<row_t> row_breaks_;
     160                 :                : 
     161                 :                :     std::unordered_map<std::string, comment> comments_;
     162                 :                :     optional<print_options> print_options_;
     163                 :                :     optional<sheet_pr> sheet_properties_;
     164                 :                : 
     165                 :                :     optional<ext_list> extension_list_;
     166                 :                : 
     167                 :                :     std::string drawing_rel_id_;
     168                 :                :     optional<drawing::spreadsheet_drawing> drawing_;
     169                 :                : };
     170                 :                : 
     171                 :                : } // namespace detail
     172                 :                : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta