differential code coverage report with master
Current view: top level - source/worksheet - range_iterator.cpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 91.7 % 108 99 9 99
Current Date: 2025-12-15 23:01:28 Functions: 94.1 % 17 16 1 16
Baseline: coverage_master.info Branches: 69.7 % 218 152 132 304
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                 :                : #include <xlnt/cell/cell.hpp>
      25                 :                : #include <xlnt/worksheet/range.hpp>
      26                 :                : #include <xlnt/worksheet/range_iterator.hpp>
      27                 :                : #include <xlnt/worksheet/range_reference.hpp>
      28                 :                : #include <xlnt/worksheet/worksheet.hpp>
      29                 :                : 
      30                 :                : namespace xlnt {
      31                 :                : 
      32                 :CBC         409 : range_iterator::reference range_iterator::operator*()
      33                 :                : {
      34         [ +  + ]:            409 :     return cell_vector(ws_, cursor_, bounds_, order_, skip_null_, false);
      35                 :                : }
      36                 :                : 
      37                 :UBC           0 : const range_iterator::reference range_iterator::operator*() const
      38                 :                : {
      39         [ #  # ]:              0 :     return cell_vector(ws_, cursor_, bounds_, order_, skip_null_, false);
      40                 :                : }
      41                 :                : 
      42                 :CBC         106 : range_iterator::range_iterator(worksheet &ws, const cell_reference &cursor,
      43                 :            106 :     const range_reference &bounds, major_order order, bool skip_null)
      44                 :            106 :     : skip_null_(skip_null),
      45                 :            106 :       order_(order),
      46                 :            106 :       ws_(ws),
      47                 :            106 :       cursor_(cursor),
      48                 :            106 :       bounds_(bounds)
      49                 :                : {
      50   [ +  +  +  +  :            106 :     if (skip_null_ && (**this).empty())
             +  +  +  + ]
      51                 :                :     {
      52                 :             25 :         ++(*this);
      53                 :                :     }
      54                 :            106 : }
      55                 :                : 
      56                 :            245 : bool range_iterator::operator==(const range_iterator &other) const
      57                 :                : {
      58                 :            245 :     return ws_ == other.ws_
      59         [ +  + ]:            245 :         && cursor_ == other.cursor_
      60         [ +  - ]:             45 :         && order_ == other.order_
      61   [ +  -  +  - ]:            490 :         && skip_null_ == other.skip_null_;
      62                 :                : }
      63                 :                : 
      64                 :            240 : bool range_iterator::operator!=(const range_iterator &other) const
      65                 :                : {
      66                 :            240 :     return !(*this == other);
      67                 :                : }
      68                 :                : 
      69                 :             14 : range_iterator &range_iterator::operator--()
      70                 :                : {
      71         [ +  + ]:             14 :     if (order_ == major_order::row)
      72                 :                :     {
      73   [ +  +  +  - ]:              3 :         if (cursor_.row() > bounds_.top_left().row())
      74                 :                :         {
      75                 :              3 :             cursor_.row(cursor_.row() - 1);
      76                 :                :         }
      77                 :                : 
      78         [ -  + ]:              3 :         if (skip_null_)
      79                 :                :         {
      80   [ #  #  #  #  :UBC           0 :             while ((**this).empty() && cursor_.row() > bounds_.top_left().row())
          #  #  #  #  #  
                   #  # ]
      81                 :                :             {
      82                 :              0 :                 cursor_.row(cursor_.row() - 1);
      83                 :                :             }
      84                 :                :         }
      85                 :                :     }
      86                 :                :     else
      87                 :                :     {
      88   [ +  +  +  +  :CBC          11 :         if (cursor_.column() > bounds_.top_left().column())
                   +  - ]
      89                 :                :         {
      90      [ +  +  + ]:             11 :             cursor_.column_index(cursor_.column_index() - 1);
      91                 :                :         }
      92                 :                : 
      93         [ +  + ]:             11 :         if (skip_null_)
      94                 :                :         {
      95   [ +  +  -  +  :              9 :             while ((**this).empty() && cursor_.column() > bounds_.top_left().column())
          -  -  -  -  -  
                -  -  + ]
      96                 :                :             {
      97      [ #  #  # ]:UBC           0 :                 cursor_.column_index(cursor_.column_index() - 1);
      98                 :                :             }
      99                 :                :         }
     100                 :                :     }
     101                 :                : 
     102                 :CBC          14 :     return *this;
     103                 :                : }
     104                 :                : 
     105                 :              1 : range_iterator range_iterator::operator--(int)
     106                 :                : {
     107                 :              1 :     range_iterator old = *this;
     108                 :              1 :     --*this;
     109                 :                : 
     110                 :              1 :     return old;
     111                 :                : }
     112                 :                : 
     113                 :            224 : range_iterator &range_iterator::operator++()
     114                 :                : {
     115         [ +  + ]:            224 :     if (order_ == major_order::row)
     116                 :                :     {
     117   [ +  +  +  + ]:            216 :         if (cursor_.row() <= bounds_.bottom_right().row())
     118                 :                :         {
     119                 :            195 :             cursor_.row(cursor_.row() + 1);
     120                 :                :         }
     121                 :                : 
     122         [ +  + ]:            216 :         if (skip_null_)
     123                 :                :         {
     124   [ +  +  +  +  :            123 :             while ((**this).empty() && cursor_.row() <= bounds_.bottom_right().row())
          +  +  +  +  +  
                   +  + ]
     125                 :                :             {
     126                 :              7 :                 cursor_.row(cursor_.row() + 1);
     127                 :                :             }
     128                 :                :         }
     129                 :                :     }
     130                 :                :     else
     131                 :                :     {
     132   [ +  +  +  +  :              8 :         if (cursor_.column() <= bounds_.bottom_right().column())
                   +  + ]
     133                 :                :         {
     134      [ +  +  + ]:              4 :             cursor_.column_index(cursor_.column_index() + 1);
     135                 :                :         }
     136                 :                : 
     137         [ +  - ]:              8 :         if (skip_null_)
     138                 :                :         {
     139   [ +  +  +  +  :              8 :             while ((**this).empty() && cursor_.column() <= bounds_.bottom_right().column())
          +  +  +  +  -  
                +  -  + ]
     140                 :                :             {
     141      [ #  #  # ]:UBC           0 :                 cursor_.column_index(cursor_.column_index() + 1);
     142                 :                :             }
     143                 :                :         }
     144                 :                :     }
     145                 :                : 
     146                 :CBC         224 :     return *this;
     147                 :                : }
     148                 :                : 
     149                 :              1 : range_iterator range_iterator::operator++(int)
     150                 :                : {
     151                 :              1 :     range_iterator old = *this;
     152                 :              1 :     ++*this;
     153                 :                : 
     154                 :              1 :     return old;
     155                 :                : }
     156                 :                : 
     157                 :             27 : const_range_iterator::const_range_iterator(const worksheet &ws, const cell_reference &cursor,
     158                 :             27 :     const range_reference &bounds, major_order order, bool skip_null)
     159                 :             27 :     : skip_null_(skip_null),
     160                 :             27 :       order_(order),
     161                 :             27 :       ws_(ws.d_),
     162                 :             27 :       cursor_(cursor),
     163                 :             27 :       bounds_(bounds)
     164                 :                : {
     165   [ +  +  +  +  :             27 :     if (skip_null_ && (**this).empty())
             +  +  +  + ]
     166                 :                :     {
     167                 :             10 :         ++(*this);
     168                 :                :     }
     169                 :             27 : }
     170                 :                : 
     171                 :             22 : bool const_range_iterator::operator==(const const_range_iterator &other) const
     172                 :                : {
     173                 :             22 :     return ws_ == other.ws_
     174         [ +  + ]:             22 :         && cursor_ == other.cursor_
     175         [ +  - ]:              8 :         && order_ == other.order_
     176   [ +  -  +  - ]:             44 :         && skip_null_ == other.skip_null_;
     177                 :                : }
     178                 :                : 
     179                 :             13 : bool const_range_iterator::operator!=(const const_range_iterator &other) const
     180                 :                : {
     181                 :             13 :     return !(*this == other);
     182                 :                : }
     183                 :                : 
     184                 :             17 : const_range_iterator &const_range_iterator::operator--()
     185                 :                : {
     186         [ +  + ]:             17 :     if (order_ == major_order::row)
     187                 :                :     {
     188   [ +  +  +  - ]:              8 :         if (cursor_.row() > bounds_.top_left().row())
     189                 :                :         {
     190                 :              8 :             cursor_.row(cursor_.row() - 1);
     191                 :                :         }
     192                 :                : 
     193         [ +  + ]:              8 :         if (skip_null_)
     194                 :                :         {
     195   [ +  +  -  +  :              7 :             while ((**this).empty() && cursor_.row() > bounds_.top_left().row())
          -  -  -  -  -  
                   -  + ]
     196                 :                :             {
     197                 :UBC           0 :                 cursor_.row(cursor_.row() - 1);
     198                 :                :             }
     199                 :                :         }
     200                 :                :     }
     201                 :                :     else
     202                 :                :     {
     203   [ +  +  +  +  :CBC           9 :         if (cursor_.column() > bounds_.top_left().column())
                   +  - ]
     204                 :                :         {
     205      [ +  +  + ]:              9 :             cursor_.column_index(cursor_.column_index() - 1);
     206                 :                :         }
     207                 :                : 
     208         [ +  - ]:              9 :         if (skip_null_)
     209                 :                :         {
     210   [ +  +  -  +  :              9 :             while ((**this).empty() && cursor_.row() > bounds_.top_left().column())
          -  -  -  -  -  
                -  -  + ]
     211                 :                :             {
     212      [ #  #  # ]:UBC           0 :                 cursor_.column_index(cursor_.column_index() - 1);
     213                 :                :             }
     214                 :                :         }
     215                 :                :     }
     216                 :                : 
     217                 :CBC          17 :     return *this;
     218                 :                : }
     219                 :                : 
     220                 :              1 : const_range_iterator const_range_iterator::operator--(int)
     221                 :                : {
     222                 :              1 :     const_range_iterator old = *this;
     223                 :              1 :     --*this;
     224                 :                : 
     225                 :              1 :     return old;
     226                 :                : }
     227                 :                : 
     228                 :             22 : const_range_iterator &const_range_iterator::operator++()
     229                 :                : {
     230         [ +  + ]:             22 :     if (order_ == major_order::row)
     231                 :                :     {
     232   [ +  +  +  + ]:             14 :         if (cursor_.row() <= bounds_.bottom_right().row())
     233                 :                :         {
     234                 :              8 :             cursor_.row(cursor_.row() + 1);
     235                 :                :         }
     236                 :                : 
     237         [ +  + ]:             14 :         if (skip_null_)
     238                 :                :         {
     239   [ +  +  +  +  :             20 :             while ((**this).empty() && cursor_.row() <= bounds_.bottom_right().row())
          +  +  +  +  +  
                   +  + ]
     240                 :                :             {
     241                 :              7 :                 cursor_.row(cursor_.row() + 1);
     242                 :                :             }
     243                 :                :         }
     244                 :                :     }
     245                 :                :     else
     246                 :                :     {
     247   [ +  +  +  +  :              8 :         if (cursor_.column() <= bounds_.bottom_right().column())
                   +  + ]
     248                 :                :         {
     249      [ +  +  + ]:              4 :             cursor_.column_index(cursor_.column_index() + 1);
     250                 :                :         }
     251                 :                : 
     252         [ +  - ]:              8 :         if (skip_null_)
     253                 :                :         {
     254   [ +  +  +  +  :              8 :             while ((**this).empty() && cursor_.column() <= bounds_.bottom_right().column())
          +  +  +  +  -  
                +  -  + ]
     255                 :                :             {
     256      [ #  #  # ]:UBC           0 :                 cursor_.column_index(cursor_.column_index() + 1);
     257                 :                :             }
     258                 :                :         }
     259                 :                :     }
     260                 :                : 
     261                 :CBC          22 :     return *this;
     262                 :                : }
     263                 :                : 
     264                 :              1 : const_range_iterator const_range_iterator::operator++(int)
     265                 :                : {
     266                 :              1 :     const_range_iterator old = *this;
     267                 :              1 :     ++*this;
     268                 :                : 
     269                 :              1 :     return old;
     270                 :                : }
     271                 :                : 
     272                 :             91 : const const_range_iterator::reference const_range_iterator::operator*() const
     273                 :                : {
     274         [ +  + ]:             91 :     return cell_vector(ws_, cursor_, bounds_, order_, skip_null_, false);
     275                 :                : }
     276                 :                : 
     277                 :                : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta