differential code coverage report with master
Current view: top level - source/detail/serialization - custom_value_traits.hpp (source / functions) Coverage Total Hit UBC CBC
Current: coverage.info Lines: 77.8 % 270 210 60 210
Current Date: 2025-12-07 02:01:22 Functions: 94.9 % 39 37 2 37
Baseline: coverage_master.info Branches: 69.7 % 314 219 190 438
Baseline Date: 2025-12-07 02:01:21

             Branch data    TLA  Line data    Source code
       1                 :                : // Copyright (c) 2016-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 <algorithm>
      28                 :                : #include <string>
      29                 :                : #include <unordered_map>
      30                 :                : 
      31                 :                : #include <detail/default_case.hpp>
      32                 :                : #include <detail/external/include_libstudxml.hpp>
      33                 :                : #include <xlnt/packaging/relationship.hpp>
      34                 :                : #include <xlnt/styles/alignment.hpp>
      35                 :                : #include <xlnt/styles/border.hpp>
      36                 :                : #include <xlnt/styles/font.hpp>
      37                 :                : #include <xlnt/styles/fill.hpp>
      38                 :                : #include <xlnt/utils/exceptions.hpp>
      39                 :                : #include <xlnt/utils/variant.hpp>
      40                 :                : #include <xlnt/worksheet/pane.hpp>
      41                 :                : #include <xlnt/worksheet/page_setup.hpp>
      42                 :                : #include <xlnt/workbook/metadata_property.hpp>
      43                 :                : 
      44                 :                : namespace xlnt {
      45                 :                : namespace detail {
      46                 :                : 
      47                 :                : /// <summary>
      48                 :                : /// Returns the string representation of the underline style.
      49                 :                : /// </summary>
      50                 :                : std::string to_string(font::underline_style underline_style);
      51                 :                : 
      52                 :                : /// <summary>
      53                 :                : /// Returns the string representation of the relationship type.
      54                 :                : /// </summary>
      55                 :                : std::string to_string(relationship_type t);
      56                 :                : 
      57                 :                : std::string to_string(pattern_fill_type fill_type);
      58                 :                : 
      59                 :                : std::string to_string(gradient_fill_type fill_type);
      60                 :                : 
      61                 :                : std::string to_string(border_style border_style);
      62                 :                : 
      63                 :                : std::string to_string(vertical_alignment vertical_alignment);
      64                 :                : 
      65                 :                : std::string to_string(horizontal_alignment horizontal_alignment);
      66                 :                : 
      67                 :                : std::string to_string(border_side side);
      68                 :                : 
      69                 :                : std::string to_string(core_property prop);
      70                 :                : 
      71                 :                : std::string to_string(extended_property prop);
      72                 :                : 
      73                 :                : std::string to_string(variant::type type);
      74                 :                : 
      75                 :                : std::string to_string(pane_corner corner);
      76                 :                : 
      77                 :                : std::string to_string(target_mode mode);
      78                 :                : 
      79                 :                : std::string to_string(pane_state state);
      80                 :                : 
      81                 :                : std::string to_string(orientation state);
      82                 :                : 
      83                 :                : template<typename T>
      84                 :                : static T from_string(const std::string &string_value);
      85                 :                : 
      86                 :                : template<>
      87                 :CBC          44 : font::underline_style from_string(const std::string &string)
      88                 :                : {
      89         [ +  + ]:             44 :     if (string == "double") return font::underline_style::double_;
      90         [ +  + ]:             35 :     if (string == "doubleAccounting") return font::underline_style::double_accounting;
      91         [ -  + ]:              9 :     if (string == "single") return font::underline_style::single;
      92         [ +  - ]:              9 :     if (string == "singleAccounting") return font::underline_style::single_accounting;
      93         [ #  # ]:UBC           0 :     if (string == "none") return font::underline_style::none;
      94                 :                : 
      95            [ # ]:              0 :     default_case(font::underline_style::none);
      96                 :                : }
      97                 :                : 
      98                 :                : template<>
      99                 :CBC         794 : relationship_type from_string(const std::string &string)
     100                 :                : {
     101         [ +  + ]:            794 :     if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument")
     102                 :             97 :         return relationship_type::office_document;
     103         [ +  + ]:            697 :     else if (string == "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail")
     104                 :             44 :         return relationship_type::thumbnail;
     105         [ +  + ]:            653 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain")
     106                 :             12 :         return relationship_type::calculation_chain;
     107         [ +  + ]:            641 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties")
     108                 :             85 :         return relationship_type::extended_properties;
     109                 :            556 :     else if (string == "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
     110   [ +  +  +  +  :            556 :         || string == "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties")
                   +  + ]
     111                 :             85 :         return relationship_type::core_properties;
     112         [ +  + ]:            471 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet")
     113                 :            128 :         return relationship_type::worksheet;
     114         [ +  + ]:            343 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings")
     115                 :             66 :         return relationship_type::shared_string_table;
     116         [ +  + ]:            277 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles")
     117                 :             85 :         return relationship_type::stylesheet;
     118         [ +  + ]:            192 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme")
     119                 :             74 :         return relationship_type::theme;
     120         [ +  + ]:            118 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")
     121                 :             29 :         return relationship_type::hyperlink;
     122         [ -  + ]:             89 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet")
     123                 :UBC           0 :         return relationship_type::chartsheet;
     124         [ +  + ]:CBC          89 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments")
     125                 :             14 :         return relationship_type::comments;
     126         [ +  + ]:             75 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing")
     127                 :             14 :         return relationship_type::vml_drawing;
     128         [ +  + ]:             61 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties")
     129                 :              6 :         return relationship_type::custom_properties;
     130         [ +  + ]:             55 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings")
     131                 :              5 :         return relationship_type::printer_settings;
     132         [ -  + ]:             50 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections")
     133                 :UBC           0 :         return relationship_type::connections;
     134         [ -  + ]:CBC          50 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty")
     135                 :UBC           0 :         return relationship_type::custom_property;
     136         [ -  + ]:CBC          50 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlMappings")
     137                 :UBC           0 :         return relationship_type::custom_xml_mappings;
     138         [ -  + ]:CBC          50 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet")
     139                 :UBC           0 :         return relationship_type::dialogsheet;
     140         [ +  + ]:CBC          50 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing")
     141                 :              4 :         return relationship_type::drawings;
     142         [ -  + ]:             46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath")
     143                 :UBC           0 :         return relationship_type::external_workbook_references;
     144         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable")
     145                 :UBC           0 :         return relationship_type::pivot_table;
     146         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition")
     147                 :UBC           0 :         return relationship_type::pivot_table_cache_definition;
     148         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords")
     149                 :UBC           0 :         return relationship_type::pivot_table_cache_records;
     150         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/queryTable")
     151                 :UBC           0 :         return relationship_type::query_table;
     152         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionHeaders")
     153                 :UBC           0 :         return relationship_type::shared_workbook_revision_headers;
     154         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedWorkbook")
     155                 :UBC           0 :         return relationship_type::shared_workbook;
     156         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionLog")
     157                 :UBC           0 :         return relationship_type::revision_log;
     158         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/usernames")
     159                 :UBC           0 :         return relationship_type::shared_workbook_user_data;
     160         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells")
     161                 :UBC           0 :         return relationship_type::single_cell_table_definitions;
     162         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table")
     163                 :UBC           0 :         return relationship_type::table_definition;
     164         [ -  + ]:CBC          46 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatileDependencies")
     165                 :UBC           0 :         return relationship_type::volatile_dependencies;
     166         [ +  + ]:CBC          46 :     else if (string == "http://schemas.microsoft.com/office/2006/relationships/vbaProject")
     167                 :              2 :         return relationship_type::vbaproject;
     168         [ +  + ]:             44 :     else if (string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")
     169                 :              4 :         return relationship_type::image;
     170                 :                : 
     171                 :                :     // ECMA 376-4 Part 1 Section 9.1.7 says consumers shall not fail to load
     172                 :                :     // a document with unknown relationships.
     173                 :             40 :     return relationship_type::unknown;
     174                 :                : }
     175                 :                : 
     176                 :                : template<>
     177                 :            484 : pattern_fill_type from_string(const std::string &string)
     178                 :                : {
     179                 :                : #pragma clang diagnostic push
     180                 :                : #pragma clang diagnostic ignored "-Wexit-time-destructors"
     181                 :                :     static std::unordered_map<std::string, pattern_fill_type> patternFill {
     182                 :UBC           0 :         {"darkdown", pattern_fill_type::darkdown },
     183                 :              0 :         { "darkgray", pattern_fill_type::darkgray },
     184                 :              0 :         { "darkgrid", pattern_fill_type::darkgrid },
     185                 :              0 :         { "darkhorizontal", pattern_fill_type::darkhorizontal },
     186                 :              0 :         { "darktrellis", pattern_fill_type::darktrellis },
     187                 :              0 :         { "darkup", pattern_fill_type::darkup },
     188                 :              0 :         { "darkvertical", pattern_fill_type::darkvertical },
     189                 :              0 :         { "gray0625", pattern_fill_type::gray0625 },
     190                 :              0 :         { "gray125", pattern_fill_type::gray125 },
     191                 :              0 :         { "lightdown", pattern_fill_type::lightdown },
     192                 :              0 :         { "lightgray", pattern_fill_type::lightgray },
     193                 :              0 :         { "lightgrid", pattern_fill_type::lightgrid },
     194                 :              0 :         { "lighthorizontal", pattern_fill_type::lighthorizontal },
     195                 :              0 :         { "lighttrellis", pattern_fill_type::lighttrellis },
     196                 :              0 :         { "lightup", pattern_fill_type::lightup },
     197                 :              0 :         { "lightvertical", pattern_fill_type::lightvertical },
     198                 :              0 :         { "mediumgray", pattern_fill_type::mediumgray },
     199                 :              0 :         { "none", pattern_fill_type::none },
     200                 :              0 :         { "solid", pattern_fill_type::solid }
     201   [ +  +  +  -  :CBC         505 :     };
          +  +  +  -  -  
                   -  - ]
     202                 :                : #pragma clang diagnostic pop
     203                 :                : 
     204                 :            484 :     auto toLower = [](std::string str) {
     205                 :            484 :         auto bg = std::begin (str);
     206                 :            484 :         auto en = std::end (str);
     207                 :            484 :         std::transform(bg, en, bg,
     208                 :           2509 :                        [](char c) {
     209                 :                :                         // static cast to avoid int -> char narrowing warning
     210                 :           2509 :                            return static_cast<char>(tolower(c));
     211                 :                :                        });
     212                 :                : 
     213                 :            484 :         return str;
     214                 :                :     };
     215                 :                : 
     216                 :            484 :     auto patternLookup = [](const std::string& key) {
     217            [ + ]:            484 :         auto entry = patternFill.find (key);
     218         [ +  - ]:            484 :         if (entry != std::end (patternFill)) {
     219                 :            484 :             return entry->second;
     220                 :                :         }
     221                 :                :         else {
     222                 :                :             // Note: there won't be an error if there is an unsupported pattern
     223                 :UBC           0 :             return pattern_fill_type::none;
     224                 :                :         }
     225                 :                :     };
     226                 :                : 
     227         [ +  + ]:CBC         484 :     std::string lowerString {toLower (string) };
     228                 :                : 
     229            [ + ]:            968 :     return patternLookup (lowerString);
     230   [ +  +  +  +  :            485 : }
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
             -  -  -  - ]
     231                 :                : 
     232                 :                : template<>
     233                 :UBC           0 : gradient_fill_type from_string(const std::string &string)
     234                 :                : {
     235         [ #  # ]:              0 :     if (string == "linear") return gradient_fill_type::linear;
     236         [ #  # ]:              0 :     else if (string == "path") return gradient_fill_type::path;
     237                 :                : 
     238            [ # ]:              0 :     default_case(gradient_fill_type::linear);
     239                 :                : }
     240                 :                : 
     241                 :                : template<>
     242                 :CBC         280 : border_style from_string(const std::string &string)
     243                 :                : {
     244         [ -  + ]:            280 :     if (string == "dashDot") return border_style::dashdot;
     245         [ -  + ]:            280 :     else if (string == "dashDotDot") return border_style::dashdotdot;
     246         [ -  + ]:            280 :     else if (string == "dashed") return border_style::dashed;
     247         [ -  + ]:            280 :     else if (string == "dotted") return border_style::dotted;
     248         [ +  + ]:            280 :     else if (string == "double") return border_style::double_;
     249         [ -  + ]:            220 :     else if (string == "hair") return border_style::hair;
     250         [ +  + ]:            220 :     else if (string == "medium") return border_style::medium;
     251         [ -  + ]:            209 :     else if (string == "mediumDashdot") return border_style::mediumdashdot;
     252         [ -  + ]:            209 :     else if (string == "mediumDashDotDot") return border_style::mediumdashdotdot;
     253         [ -  + ]:            209 :     else if (string == "mediumDashed") return border_style::mediumdashed;
     254         [ -  + ]:            209 :     else if (string == "none") return border_style::none;
     255         [ -  + ]:            209 :     else if (string == "slantDashDot") return border_style::slantdashdot;
     256         [ +  + ]:            209 :     else if (string == "thick") return border_style::thick;
     257         [ +  - ]:            190 :     else if (string == "thin") return border_style::thin;
     258                 :                : 
     259            [ # ]:UBC           0 :     default_case(border_style::dashdot);
     260                 :                : }
     261                 :                : 
     262                 :                : template<>
     263                 :CBC         457 : vertical_alignment from_string(const std::string &string)
     264                 :                : {
     265         [ +  + ]:            457 :     if (string == "bottom") return vertical_alignment::bottom;
     266         [ +  + ]:            411 :     else if (string == "center") return vertical_alignment::center;
     267         [ +  + ]:             50 :     else if (string == "distributed") return vertical_alignment::distributed;
     268         [ -  + ]:             41 :     else if (string == "justify") return vertical_alignment::justify;
     269         [ +  - ]:             41 :     else if (string == "top") return vertical_alignment::top;
     270                 :                : 
     271            [ # ]:UBC           0 :     default_case(vertical_alignment::top);
     272                 :                : }
     273                 :                : 
     274                 :                : template<>
     275                 :CBC         116 : horizontal_alignment from_string(const std::string &string)
     276                 :                : {
     277         [ +  + ]:            116 :     if (string == "center") return horizontal_alignment::center;
     278         [ -  + ]:            103 :     else if (string == "centerContinuous") return horizontal_alignment::center_continuous;
     279         [ -  + ]:            103 :     else if (string == "distributed") return horizontal_alignment::distributed;
     280         [ -  + ]:            103 :     else if (string == "fill") return horizontal_alignment::fill;
     281         [ +  + ]:            103 :     else if (string == "general") return horizontal_alignment::general;
     282         [ -  + ]:             79 :     else if (string == "justify") return horizontal_alignment::justify;
     283         [ +  + ]:             79 :     else if (string == "left") return horizontal_alignment::left;
     284         [ +  - ]:             24 :     else if (string == "right") return horizontal_alignment::right;
     285                 :                : 
     286            [ # ]:UBC           0 :     default_case(horizontal_alignment::general);
     287                 :                : }
     288                 :                : template<>
     289                 :CBC         946 : border_side from_string(const std::string &string)
     290                 :                : {
     291         [ +  + ]:            946 :     if (string == "bottom") return border_side::bottom;
     292         [ +  + ]:            756 :     else if (string == "diagonal") return border_side::diagonal;
     293         [ +  + ]:            567 :     else if (string == "right") return border_side::end;
     294         [ -  + ]:            378 :     else if (string == "horizontal") return border_side::horizontal;
     295         [ +  + ]:            378 :     else if (string == "left") return border_side::start;
     296         [ +  - ]:            189 :     else if (string == "top") return border_side::top;
     297         [ #  # ]:UBC           0 :     else if (string == "vertical") return border_side::vertical;
     298                 :                : 
     299            [ # ]:              0 :     default_case(border_side::bottom);
     300                 :                : }
     301                 :                : 
     302                 :                : template<>
     303                 :CBC         419 : core_property from_string(const std::string &string)
     304                 :                : {
     305         [ +  + ]:            419 :     if (string == "category") return core_property::category;
     306         [ -  + ]:            411 :     else if (string == "contentStatus") return core_property::content_status;
     307         [ +  + ]:            411 :     else if (string == "created") return core_property::created;
     308         [ +  + ]:            335 :     else if (string == "creator") return core_property::creator;
     309         [ +  + ]:            255 :     else if (string == "description") return core_property::description;
     310         [ -  + ]:            235 :     else if (string == "identifier") return core_property::identifier;
     311         [ +  + ]:            235 :     else if (string == "keywords") return core_property::keywords;
     312         [ +  + ]:            227 :     else if (string == "language") return core_property::language;
     313         [ +  + ]:            215 :     else if (string == "lastModifiedBy") return core_property::last_modified_by;
     314         [ -  + ]:            136 :     else if (string == "lastPrinted") return core_property::last_printed;
     315         [ +  + ]:            136 :     else if (string == "modified") return core_property::modified;
     316         [ +  + ]:             54 :     else if (string == "revision") return core_property::revision;
     317         [ +  + ]:             41 :     else if (string == "subject") return core_property::subject;
     318         [ +  - ]:             21 :     else if (string == "title") return core_property::title;
     319         [ #  # ]:UBC           0 :     else if (string == "version") return core_property::version;
     320                 :                : 
     321            [ # ]:              0 :     default_case(core_property::category);
     322                 :                : }
     323                 :                : 
     324                 :                : template<>
     325                 :CBC         725 : extended_property from_string(const std::string &string)
     326                 :                : {
     327         [ +  + ]:            725 :     if (string == "Application") return extended_property::application;
     328         [ +  + ]:            642 :     else if (string == "AppVersion") return extended_property::app_version;
     329         [ -  + ]:            572 :     else if (string == "Characters") return extended_property::characters;
     330         [ -  + ]:            572 :     else if (string == "CharactersWithSpaces") return extended_property::characters_with_spaces;
     331         [ +  + ]:            572 :     else if (string == "Company") return extended_property::company;
     332         [ -  + ]:            511 :     else if (string == "DigSig") return extended_property::dig_sig;
     333         [ +  + ]:            511 :     else if (string == "DocSecurity") return extended_property::doc_security;
     334         [ +  + ]:            446 :     else if (string == "HeadingPairs") return extended_property::heading_pairs;
     335         [ +  + ]:            379 :     else if (string == "HiddenSlides") return extended_property::hidden_slides;
     336         [ +  + ]:            378 :     else if (string == "HyperlinksChanged") return extended_property::hyperlinks_changed;
     337         [ +  + ]:            312 :     else if (string == "HyperlinkBase") return extended_property::hyperlink_base;
     338         [ -  + ]:            304 :     else if (string == "HLinks") return extended_property::h_links;
     339         [ -  + ]:            304 :     else if (string == "Lines") return extended_property::lines;
     340         [ +  + ]:            304 :     else if (string == "LinksUpToDate") return extended_property::links_up_to_date;
     341         [ +  + ]:            238 :     else if (string == "Manager") return extended_property::manager;
     342         [ +  + ]:            230 :     else if (string == "MMClips") return extended_property::m_m_clips;
     343         [ +  + ]:            229 :     else if (string == "Notes") return extended_property::notes;
     344         [ -  + ]:            228 :     else if (string == "Pages") return extended_property::pages;
     345         [ +  + ]:            228 :     else if (string == "Paragraphs") return extended_property::paragraphs;
     346         [ +  + ]:            227 :     else if (string == "PresentationFormat") return extended_property::presentation_format;
     347         [ +  + ]:            226 :     else if (string == "ScaleCrop") return extended_property::scale_crop;
     348         [ +  + ]:            160 :     else if (string == "SharedDoc") return extended_property::shared_doc;
     349         [ +  + ]:             94 :     else if (string == "Slides") return extended_property::slides;
     350         [ +  + ]:             93 :     else if (string == "Template") return extended_property::template_;
     351         [ +  + ]:             81 :     else if (string == "TitlesOfParts") return extended_property::titles_of_parts;
     352         [ +  + ]:             14 :     else if (string == "TotalTime") return extended_property::total_time;
     353         [ +  - ]:              1 :     else if (string == "Words") return extended_property::words;
     354                 :                : 
     355            [ # ]:UBC           0 :     default_case(extended_property::application);
     356                 :                : }
     357                 :                : 
     358                 :                : /*
     359                 :                : template<>
     360                 :                : variant::type from_string(const std::string &string)
     361                 :                : {
     362                 :                :     if (string == "bool") return variant::type::boolean;
     363                 :                :     else if (string == "date") return variant::type::date;
     364                 :                :     else if (string == "i4") return variant::type::i4;
     365                 :                :     else if (string == "lpstr") return variant::type::lpstr;
     366                 :                :     else if (string == "null") return variant::type::null;
     367                 :                :     else if (string == "vector") return variant::type::vector;
     368                 :                : 
     369                 :                :     default_case(variant::type::null);
     370                 :                : }
     371                 :                : */
     372                 :                : 
     373                 :                : template<>
     374                 :CBC           3 : xlnt::pane_state from_string(const std::string &string)
     375                 :                : {
     376         [ +  - ]:              3 :     if (string == "frozen") return xlnt::pane_state::frozen;
     377         [ #  # ]:UBC           0 :     else if (string == "frozenSplit") return xlnt::pane_state::frozen_split;
     378         [ #  # ]:              0 :     else if (string == "split") return xlnt::pane_state::split;
     379                 :                : 
     380            [ # ]:              0 :     default_case(xlnt::pane_state::frozen);
     381                 :                : }
     382                 :                : 
     383                 :                : template<>
     384                 :CBC          30 : target_mode from_string(const std::string &string)
     385                 :                : {
     386         [ -  + ]:             30 :     if (string == "Internal") return target_mode::internal;
     387         [ +  - ]:             30 :     else if (string == "External") return target_mode::external;
     388                 :                : 
     389            [ # ]:UBC           0 :     default_case(target_mode::internal);
     390                 :                : }
     391                 :                : 
     392                 :                : template<>
     393                 :CBC          24 : pane_corner from_string(const std::string &string)
     394                 :                : {
     395         [ +  + ]:             24 :     if (string == "bottomLeft") return pane_corner::bottom_left;
     396         [ +  + ]:             22 :     else if (string == "bottomRight") return pane_corner::bottom_right;
     397         [ +  - ]:             19 :     else if (string == "topLeft") return pane_corner::top_left;
     398         [ #  # ]:UBC           0 :     else if (string == "topRight") return pane_corner::top_right;
     399                 :                : 
     400            [ # ]:              0 :     default_case(pane_corner::bottom_left);
     401                 :                : }
     402                 :                : 
     403                 :                : template <>
     404                 :CBC          36 : orientation from_string(const std::string &string)
     405                 :                : {
     406         [ -  + ]:             36 :     if (string == "default") return orientation::default_orientation;
     407         [ -  + ]:             36 :     else if (string == "landscape") return orientation::landscape;
     408         [ +  - ]:             36 :     else if (string == "portrait") return orientation::portrait;
     409            [ # ]:UBC           0 :     default_case(orientation::default_orientation);
     410                 :                : }
     411                 :                : 
     412                 :                : } // namespace detail
     413                 :                : } // namespace xlnt
     414                 :                : 
     415                 :                : namespace xml {
     416                 :                : 
     417                 :                : template <>
     418                 :                : struct value_traits<xlnt::font::underline_style>
     419                 :                : {
     420                 :CBC          44 :     static xlnt::font::underline_style parse(std::string underline_string, const parser &)
     421                 :                :     {
     422                 :             44 :         return xlnt::detail::from_string<xlnt::font::underline_style>(underline_string);
     423                 :                :     }
     424                 :                : 
     425                 :             20 :     static std::string serialize(xlnt::font::underline_style underline_style, const serializer &)
     426                 :                :     {
     427                 :             20 :         return xlnt::detail::to_string(underline_style);
     428                 :                :     }
     429                 :                : };
     430                 :                : 
     431                 :                : template <>
     432                 :                : struct value_traits<xlnt::relationship_type>
     433                 :                : {
     434                 :            794 :     static xlnt::relationship_type parse(std::string relationship_type_string, const parser &)
     435                 :                :     {
     436                 :            794 :         return xlnt::detail::from_string<xlnt::relationship_type>(relationship_type_string);
     437                 :                :     }
     438                 :                : 
     439                 :            367 :     static std::string serialize(xlnt::relationship_type type, const serializer &)
     440                 :                :     {
     441                 :            367 :         return xlnt::detail::to_string(type);
     442                 :                :     }
     443                 :                : };
     444                 :                : 
     445                 :                : template <>
     446                 :                : struct value_traits<xlnt::pattern_fill_type>
     447                 :                : {
     448                 :            484 :     static xlnt::pattern_fill_type parse(std::string fill_type_string, const parser &)
     449                 :                :     {
     450                 :            484 :         return xlnt::detail::from_string<xlnt::pattern_fill_type>(fill_type_string);
     451                 :                :     }
     452                 :                : 
     453                 :            210 :     static std::string serialize(xlnt::pattern_fill_type fill_type, const serializer &)
     454                 :                :     {
     455                 :            210 :         return xlnt::detail::to_string(fill_type);
     456                 :                :     }
     457                 :                : };
     458                 :                : 
     459                 :                : template <>
     460                 :                : struct value_traits<xlnt::gradient_fill_type>
     461                 :                : {
     462                 :UBC           0 :     static xlnt::gradient_fill_type parse(std::string fill_type_string, const parser &)
     463                 :                :     {
     464                 :              0 :         return xlnt::detail::from_string<xlnt::gradient_fill_type>(fill_type_string);
     465                 :                :     }
     466                 :                : 
     467                 :CBC           1 :     static std::string serialize(xlnt::gradient_fill_type fill_type, const serializer &)
     468                 :                :     {
     469                 :              1 :         return xlnt::detail::to_string(fill_type);
     470                 :                :     }
     471                 :                : };
     472                 :                : 
     473                 :                : template <>
     474                 :                : struct value_traits<xlnt::border_style>
     475                 :                : {
     476                 :            280 :     static xlnt::border_style parse(std::string style_string, const parser &)
     477                 :                :     {
     478                 :            280 :         return xlnt::detail::from_string<xlnt::border_style>(style_string);
     479                 :                :     }
     480                 :                : 
     481                 :                :     static std::string
     482                 :            116 :     serialize (xlnt::border_style style, const serializer &)
     483                 :                :     {
     484                 :            116 :         return xlnt::detail::to_string(style);
     485                 :                :     }
     486                 :                : };
     487                 :                : 
     488                 :                : template <>
     489                 :                : struct value_traits<xlnt::vertical_alignment>
     490                 :                : {
     491                 :            457 :     static xlnt::vertical_alignment parse(std::string alignment_string, const parser &)
     492                 :                :     {
     493                 :            457 :         return xlnt::detail::from_string<xlnt::vertical_alignment>(alignment_string);
     494                 :                :     }
     495                 :                : 
     496                 :             74 :     static std::string serialize (xlnt::vertical_alignment alignment, const serializer &)
     497                 :                :     {
     498                 :             74 :         return xlnt::detail::to_string(alignment);
     499                 :                :     }
     500                 :                : };
     501                 :                : 
     502                 :                : template <>
     503                 :                : struct value_traits<xlnt::horizontal_alignment>
     504                 :                : {
     505                 :            116 :     static xlnt::horizontal_alignment parse(std::string alignment_string, const parser &)
     506                 :                :     {
     507                 :            116 :         return xlnt::detail::from_string<xlnt::horizontal_alignment>(alignment_string);
     508                 :                :     }
     509                 :                : 
     510                 :             24 :     static std::string serialize(xlnt::horizontal_alignment alignment, const serializer &)
     511                 :                :     {
     512                 :             24 :         return xlnt::detail::to_string(alignment);
     513                 :                :     }
     514                 :                : };
     515                 :                : 
     516                 :                : template <>
     517                 :                : struct value_traits<xlnt::border_side>
     518                 :                : {
     519                 :            946 :     static xlnt::border_side parse(std::string side_string, const parser &)
     520                 :                :     {
     521                 :            946 :         return xlnt::detail::from_string<xlnt::border_side>(side_string);
     522                 :                :     }
     523                 :                : 
     524                 :                :     static std::string serialize(xlnt::border_side side, const serializer &)
     525                 :                :     {
     526                 :                :         return xlnt::detail::to_string(side);
     527                 :                :     }
     528                 :                : };
     529                 :                : 
     530                 :                : template <>
     531                 :                : struct value_traits<xlnt::target_mode>
     532                 :                : {
     533                 :             30 :     static xlnt::target_mode parse(std::string mode_string, const parser &)
     534                 :                :     {
     535                 :             30 :         return xlnt::detail::from_string<xlnt::target_mode>(mode_string);
     536                 :                :     }
     537                 :                : 
     538                 :                :     static std::string serialize(xlnt::target_mode mode, const serializer &)
     539                 :                :     {
     540                 :                :         return xlnt::detail::to_string(mode);
     541                 :                :     }
     542                 :                : };
     543                 :                : 
     544                 :                : template <>
     545                 :                : struct value_traits<xlnt::pane_state>
     546                 :                : {
     547                 :              3 :     static xlnt::pane_state parse(std::string string, const parser &)
     548                 :                :     {
     549                 :              3 :         return xlnt::detail::from_string<xlnt::pane_state>(string);
     550                 :                :     }
     551                 :                : 
     552                 :              2 :     static std::string serialize(xlnt::pane_state state, const serializer &)
     553                 :                :     {
     554                 :              2 :         return xlnt::detail::to_string(state);
     555                 :                :     }
     556                 :                : };
     557                 :                : 
     558                 :                : template <>
     559                 :                : struct value_traits<xlnt::pane_corner>
     560                 :                : {
     561                 :             24 :     static xlnt::pane_corner parse(std::string string, const parser &)
     562                 :                :     {
     563                 :             24 :         return xlnt::detail::from_string<xlnt::pane_corner>(string);
     564                 :                :     }
     565                 :                : 
     566                 :              6 :     static std::string serialize(xlnt::pane_corner corner, const serializer &)
     567                 :                :     {
     568                 :              6 :         return xlnt::detail::to_string(corner);
     569                 :                :     }
     570                 :                : };
     571                 :                : 
     572                 :                : template <>
     573                 :                : struct value_traits<xlnt::core_property>
     574                 :                : {
     575                 :                :     static xlnt::core_property parse(std::string string, const parser &)
     576                 :                :     {
     577                 :                :         return xlnt::detail::from_string<xlnt::core_property>(string);
     578                 :                :     }
     579                 :                : 
     580                 :                :     static std::string serialize(xlnt::core_property corner, const serializer &)
     581                 :                :     {
     582                 :                :         return xlnt::detail::to_string(corner);
     583                 :                :     }
     584                 :                : };
     585                 :                : 
     586                 :                : template <>
     587                 :                : struct value_traits<xlnt::extended_property>
     588                 :                : {
     589                 :                :     static xlnt::extended_property parse(std::string string, const parser &)
     590                 :                :     {
     591                 :                :         return xlnt::detail::from_string<xlnt::extended_property>(string);
     592                 :                :     }
     593                 :                : 
     594                 :                :     static std::string serialize(xlnt::extended_property corner, const serializer &)
     595                 :                :     {
     596                 :                :         return xlnt::detail::to_string(corner);
     597                 :                :     }
     598                 :                : };
     599                 :                : 
     600                 :                : template <>
     601                 :                : struct value_traits<xlnt::orientation>
     602                 :                : {
     603                 :             36 :     static xlnt::orientation parse(std::string string, const parser &)
     604                 :                :     {
     605                 :             36 :         return xlnt::detail::from_string<xlnt::orientation>(string);
     606                 :                :     }
     607                 :                : 
     608                 :              8 :     static std::string serialize(xlnt::orientation orientation, const serializer &)
     609                 :                :     {
     610                 :              8 :         return xlnt::detail::to_string(orientation);
     611                 :                :     }
     612                 :                : };
     613                 :                : 
     614                 :                : } // namespace xml
        

Generated by: LCOV version 2.3.1-beta