differential code coverage report with master
Current view: top level - include/xlnt/styles - conditional_format.hpp (source / functions) Coverage Total Hit UBC
Current: coverage.info Lines: 0.0 % 2 0 2
Current Date: 2025-12-15 23:01:28 Functions: 0.0 % 1 0 1
Baseline: coverage_master.info
Baseline Date: 2025-12-15 23:01:27

           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                 : #pragma once
      27                 : 
      28                 : #include <string>
      29                 : 
      30                 : #include <xlnt/xlnt_config.hpp>
      31                 : #include <xlnt/utils/optional.hpp>
      32                 : 
      33                 : namespace xlnt {
      34                 : 
      35                 : class border;
      36                 : class fill;
      37                 : class font;
      38                 : 
      39                 : namespace detail {
      40                 : 
      41                 : struct conditional_format_impl;
      42                 : struct stylesheet;
      43                 : class xlsx_consumer;
      44                 : class xlsx_producer;
      45                 : 
      46                 : } // namespace detail
      47                 : 
      48                 : class XLNT_API condition
      49                 : {
      50                 : public:
      51                 :     static condition text_starts_with(const std::string &start);
      52                 :     static condition text_ends_with(const std::string &end);
      53                 :     static condition text_contains(const std::string &start);
      54                 :     static condition text_does_not_contain(const std::string &start);
      55                 : 
      56 UBC           0 :     bool operator==(const condition &rhs) const
      57                 :     {
      58               0 :         return text_comparand_ == rhs.text_comparand_;
      59                 :     }
      60                 : 
      61                 :     bool operator!=(const condition &rhs) const
      62                 :     {
      63                 :         return !(*this == rhs);
      64                 :     }
      65                 : 
      66                 : private:
      67                 :     friend class detail::xlsx_producer;
      68                 : 
      69                 :     enum class type
      70                 :     {
      71                 :         contains_text
      72                 :     } type_;
      73                 : 
      74                 :     enum class condition_operator
      75                 :     {
      76                 :         starts_with,
      77                 :         ends_with,
      78                 :         contains,
      79                 :         does_not_contain
      80                 :     } operator_;
      81                 : 
      82                 :     std::string text_comparand_;
      83                 : };
      84                 : 
      85                 : /// <summary>
      86                 : /// Describes a conditional format that will be applied to all cells in the
      87                 : /// associated range that satisfy the condition. This can only be constructed
      88                 : /// using methods on worksheet or range.
      89                 : /// </summary>
      90                 : class XLNT_API conditional_format
      91                 : {
      92                 : public:
      93                 :     /// <summary>
      94                 :     /// Delete zero-argument constructor
      95                 :     /// </summary>
      96                 :     conditional_format() = delete;
      97                 : 
      98                 :     /// <summary>
      99                 :     /// Default copy constructor. Constructs a format using the same PIMPL as other.
     100                 :     /// </summary>
     101                 :     conditional_format(const conditional_format &other) = default;
     102                 : 
     103                 :     // Formatting (xf) components
     104                 : 
     105                 :     /// <summary>
     106                 :     ///
     107                 :     /// </summary>
     108                 :     bool has_border() const;
     109                 : 
     110                 :     /// <summary>
     111                 :     ///
     112                 :     /// </summary>
     113                 :     class border border() const;
     114                 : 
     115                 :     /// <summary>
     116                 :     ///
     117                 :     /// </summary>
     118                 :     conditional_format border(const xlnt::border &new_border);
     119                 : 
     120                 :     /// <summary>
     121                 :     ///
     122                 :     /// </summary>
     123                 :     bool has_fill() const;
     124                 : 
     125                 :     /// <summary>
     126                 :     ///
     127                 :     /// </summary>
     128                 :     class fill fill() const;
     129                 : 
     130                 :     /// <summary>
     131                 :     ///
     132                 :     /// </summary>
     133                 :     conditional_format fill(const xlnt::fill &new_fill);
     134                 : 
     135                 :     /// <summary>
     136                 :     ///
     137                 :     /// </summary>
     138                 :     bool has_font() const;
     139                 : 
     140                 :     /// <summary>
     141                 :     ///
     142                 :     /// </summary>
     143                 :     class font font() const;
     144                 : 
     145                 :     /// <summary>
     146                 :     ///
     147                 :     /// </summary>
     148                 :     conditional_format font(const xlnt::font &new_font);
     149                 : 
     150                 :     /// <summary>
     151                 :     /// Returns true if this format is equivalent to other.
     152                 :     /// </summary>
     153                 :     bool operator==(const conditional_format &other) const;
     154                 : 
     155                 :     /// <summary>
     156                 :     /// Returns true if this format is not equivalent to other.
     157                 :     /// </summary>
     158                 :     bool operator!=(const conditional_format &other) const;
     159                 : 
     160                 : private:
     161                 :     friend struct detail::stylesheet;
     162                 :     friend class detail::xlsx_consumer;
     163                 : 
     164                 :     /// <summary>
     165                 :     ///
     166                 :     /// </summary>
     167                 :     conditional_format(detail::conditional_format_impl *d);
     168                 : 
     169                 :     /// <summary>
     170                 :     ///
     171                 :     /// </summary>
     172                 :     detail::conditional_format_impl *d_ = nullptr;
     173                 : };
     174                 : 
     175                 : } // namespace xlnt
        

Generated by: LCOV version 2.3.1-beta