Orcus
Loading...
Searching...
No Matches
Public Member Functions | List of all members
orcus::spreadsheet::iface::import_shared_strings Class Referenceabstract

#include <import_interface.hpp>

Public Member Functions

virtual size_t append (std::string_view s)=0
 
virtual size_t add (std::string_view s)=0
 
virtual void set_segment_font (size_t font_index)=0
 
virtual void set_segment_bold (bool b)=0
 
virtual void set_segment_italic (bool b)=0
 
virtual void set_segment_font_name (std::string_view s)=0
 
virtual void set_segment_font_size (double point)=0
 
virtual void set_segment_font_color (color_elem_t alpha, color_elem_t red, color_elem_t green, color_elem_t blue)=0
 
virtual void append_segment (std::string_view s)=0
 
virtual size_t commit_segments ()=0
 

Detailed Description

Interface for importing raw string values shared in string cells. String values may be either with or without formatted segments.

To insert an unformatted string, simply use either append() or add() method. The string will then be immediately pushed to the pool.

To insert a string with mixed formatted segments, you need to first use one or more of:

to define the format attribute(s) of a string segment followed by a call to append_segment(). This may be repeated as many times as necessary. Then as the final step, call commit_segments() to insert the entire series of formatted segments to the pool as a single string entry. The following example demonstrates how the code may look like:

import_shared_strings* iface = ...;
// store a segment with specific font, size and boldness.
iface->set_segment_font_name("FreeMono");
iface->set_segment_font_bold(true);
iface->append_segment("a bold and big segment");
// store an unformatted segment.
iface->append_segment(" followed by ");
// store a segment with smaller, italic font.
iface->set_segment_font_italic(true);
iface->append_segment("a small and italic segment");
iface->commit_segments(); // commit the whole formatted string to the pool.
Definition import_interface.hpp:72
virtual void set_segment_font_size(double point)=0
virtual void append_segment(std::string_view s)=0
virtual void set_segment_font_name(std::string_view s)=0

Member Function Documentation

◆ add()

virtual size_t orcus::spreadsheet::iface::import_shared_strings::add ( std::string_view  s)
pure virtual

Similar to the append() method, it adds a new string to the string pool; however, this method checks if the string being added is already in the pool before each insertion, to avoid duplicated strings.

Parameters
sstring to add to the pool.
Returns
ID of the inserted string.

◆ append()

virtual size_t orcus::spreadsheet::iface::import_shared_strings::append ( std::string_view  s)
pure virtual

Append a new string to the sequence of strings. Order of insertion determines the numerical ID value of an inserted string. Note that this method assumes that the caller knows the string being appended is not yet in the pool; it does not check on duplicated strings.

Parameters
sstring to append to the pool.
Returns
ID of the inserted string.

◆ append_segment()

virtual void orcus::spreadsheet::iface::import_shared_strings::append_segment ( std::string_view  s)
pure virtual

Push the current string segment to the buffer. Any formatting attributes defined so far will be applied to this segment.

Parameters
sstring value for the segment.

◆ commit_segments()

virtual size_t orcus::spreadsheet::iface::import_shared_strings::commit_segments ( )
pure virtual

Store the entire formatted string in the current buffer to the shared strings pool. The implementor may choose to unconditionally append the string to the pool, or choose to find an existing duplicate and reuse it instead.

Returns
ID of the string just inserted, or the ID of an existing string with identical formatting.

◆ set_segment_bold()

virtual void orcus::spreadsheet::iface::import_shared_strings::set_segment_bold ( bool  b)
pure virtual

Set whether or not to make the current segment bold.

Parameters
btrue if it's bold, false otherwise.

◆ set_segment_font()

virtual void orcus::spreadsheet::iface::import_shared_strings::set_segment_font ( size_t  font_index)
pure virtual

Set the index of a font to apply to the current format attributes. Refer to the import_font_style interface on how to obtain a font index. Note that a single font index is associated with multiple font-related formatting attributes, such as font name, font color, boldness and italics.

Parameters
font_indexpositive integer representing the font to use.

◆ set_segment_font_color()

virtual void orcus::spreadsheet::iface::import_shared_strings::set_segment_font_color ( color_elem_t  alpha,
color_elem_t  red,
color_elem_t  green,
color_elem_t  blue 
)
pure virtual

Set the color of a font in ARGB format to the current segment.

Parameters
alphaalpha component value (0-255).
redred component value (0-255).
greengreen component value (0-255).
blueblue component value (0-255).

◆ set_segment_font_name()

virtual void orcus::spreadsheet::iface::import_shared_strings::set_segment_font_name ( std::string_view  s)
pure virtual

Set the name of a font to the current segment.

Parameters
sfont name.

◆ set_segment_font_size()

virtual void orcus::spreadsheet::iface::import_shared_strings::set_segment_font_size ( double  point)
pure virtual

Set a font size to the current segment.

Parameters
pointfont size in points.

◆ set_segment_italic()

virtual void orcus::spreadsheet::iface::import_shared_strings::set_segment_italic ( bool  b)
pure virtual

Set whether or not to make the current segment italic.

Parameters
btrue if it's italic, false otherwise.