mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
implement writing of rich text phonetic properties and phonetic runs
This commit is contained in:
parent
7c9443dca9
commit
d5172d8bcd
|
@ -3026,7 +3026,7 @@ rich_text xlsx_consumer::read_rich_text(const xml::qname &parent)
|
|||
}
|
||||
else if (text_element == xml::qname(xmlns, "phoneticPr"))
|
||||
{
|
||||
phonetic_pr ph(parser().attribute<std::uint32_t>("fontId"));
|
||||
phonetic_pr ph(parser().attribute<phonetic_pr::font_id_t>("fontId"));
|
||||
if (parser().attribute_present("type"))
|
||||
{
|
||||
ph.type(phonetic_pr::type_from_string(parser().attribute("type")));
|
||||
|
|
|
@ -820,9 +820,9 @@ void xlsx_producer::write_rich_text(const std::string &ns, const xlnt::rich_text
|
|||
write_start_element(ns, "t");
|
||||
write_characters(text.plain_text(), text.runs().front().preserve_space);
|
||||
write_end_element(ns, "t");
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
for (const auto &run : text.runs())
|
||||
{
|
||||
write_start_element(ns, "r");
|
||||
|
@ -880,6 +880,40 @@ void xlsx_producer::write_rich_text(const std::string &ns, const xlnt::rich_text
|
|||
}
|
||||
}
|
||||
|
||||
for (const auto &run : text.phonetic_runs())
|
||||
{
|
||||
write_start_element(ns, "rPh");
|
||||
write_attribute("sb", run.start);
|
||||
write_attribute("eb", run.end);
|
||||
write_start_element(ns, "t");
|
||||
write_characters(run.text, run.preserve_space);
|
||||
write_end_element(ns, "t");
|
||||
write_end_element(ns, "rPh");
|
||||
}
|
||||
|
||||
if (text.has_phonetic_properties())
|
||||
{
|
||||
const auto &phonetic_properties = text.phonetic_properties();
|
||||
|
||||
write_start_element(ns, "phoneticPr");
|
||||
write_attribute("fontId", phonetic_properties.font_id());
|
||||
|
||||
if (text.phonetic_properties().has_type())
|
||||
{
|
||||
const auto type = phonetic_properties.type();
|
||||
write_attribute("type", phonetic_properties.type_as_string(type));
|
||||
}
|
||||
|
||||
if (text.phonetic_properties().has_alignment())
|
||||
{
|
||||
const auto alignment = phonetic_properties.alignment();
|
||||
write_attribute("alignment", phonetic_properties.alignment_as_string(alignment));
|
||||
}
|
||||
|
||||
write_end_element(ns, "phoneticPr");
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_producer::write_shared_string_table(const relationship & /*rel*/)
|
||||
{
|
||||
static const auto &xmlns = constants::ns("spreadsheetml");
|
||||
|
|
Loading…
Reference in New Issue
Block a user