import_shared_strings¶
Defined in header: <orcus/spreadsheet/import_interface.hpp>
-
class import_shared_strings¶
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:
import_shared_strings* iface = ...; // store a segment with specific font, size and boldness. iface->set_segment_font_name("FreeMono"); iface->set_segment_font_size(14); 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_size(7); 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.
Public Functions
-
virtual ~import_shared_strings()¶
-
virtual size_t append(std::string_view s) = 0¶
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:
s – string to append to the pool.
- Returns:
ID of the inserted string.
-
virtual size_t add(std::string_view s) = 0¶
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:
s – string to add to the pool.
- Returns:
ID of the inserted string.
-
virtual void set_segment_font(size_t font_index) = 0¶
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_index – positive integer representing the font to use.
-
virtual void set_segment_bold(bool b) = 0¶
Set whether or not to make the current segment bold.
- Parameters:
b – true if it’s bold, false otherwise.
-
virtual void set_segment_italic(bool b) = 0¶
Set whether or not to make the current segment italic.
- Parameters:
b – true if it’s italic, false otherwise.
-
virtual void set_segment_superscript(bool b) = 0¶
Set whether or not to apply superscript to the current segment.
- Parameters:
b – True if superscript needs to be applied, false otherwise.
-
virtual void set_segment_subscript(bool b) = 0¶
Set whether or not to apply subscript to the current segment.
- Parameters:
b – True if subscript needs to be applied, false otherwise.
-
virtual void set_segment_font_name(std::string_view s) = 0¶
Set the name of a font to the current segment.
- Parameters:
s – font name.
-
virtual void set_segment_font_size(double point) = 0¶
Set a font size to the current segment.
- Parameters:
point – font size in points.
-
virtual void set_segment_font_color(color_elem_t alpha, color_elem_t red, color_elem_t green, color_elem_t blue) = 0¶
Set the color of a font in ARGB format to the current segment.
- Parameters:
alpha – alpha component value (0-255).
red – red component value (0-255).
green – green component value (0-255).
blue – blue component value (0-255).
-
virtual import_underline *start_underline()¶
Get an interface for importing the underline attributes and applying them to the current segment.
- Returns:
Pointer to an interface for applying the underline-related attributes to the current segment. The implementer may return
nullptrif the implementation does not support it.
-
virtual import_strikethrough *start_strikethrough()¶
Get an interface for importing the strikethrough attributes and applying them to the current segment.
- Returns:
Pointer to an interface for applying the strikethrough-related attributes to the current segment. The implementer may return
nullptrif the implementation does not support it.
-
virtual void append_segment(std::string_view s) = 0¶
Push the current string segment to the buffer. Any formatting attributes set so far will be applied to this segment.
- Parameters:
s – string value for the segment.
-
virtual size_t commit_segments() = 0¶
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.