Files
core/OdfFile/Reader/Converter/pptx_text_context.cpp
Alexander Trofimov 76ee07f61c [copyright] Update copyright header
Co-authored-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
Co-committed-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
2026-05-14 08:23:56 +00:00

1149 lines
31 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (C) Ascensio System SIA, 2009-2026
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation, together with the
* additional terms provided in the LICENSE file.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: https://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA by email at info@onlyoffice.com
* or by postal mail at 20A-6 Ernesta Birznieka-Upisha Street, Riga,
* LV-1050, Latvia, European Union.
*
* The interactive user interfaces in modified versions of the Program
* are required to display Appropriate Legal Notices in accordance with
* Section 5 of the GNU AGPL version 3.
*
* No trademark rights are granted under this License.
*
* All non-code elements of the Product, including illustrations,
* icon sets, and technical writing content, are licensed under the
* Creative Commons Attribution-ShareAlike 4.0 International License:
* https://creativecommons.org/licenses/by-sa/4.0/legalcode
*
* This license applies only to such non-code elements and does not
* modify or replace the licensing terms applicable to the Program's
* source code, which remains licensed under the GNU Affero General
* Public License v3.
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
#include "pptx_conversion_context.h"
#include "pptx_text_context.h"
#include <iostream>
#include <list>
#include <xml/simple_xml_writer.h>
#include <xml/utils.h>
#include "../Format/odf_document.h"
#include "../Format/odfcontext.h"
#include "../Format/calcs_styles.h"
#include "../Format/style_text_properties.h"
namespace cpdoccore {
namespace oox {
class pptx_text_context::Impl: boost::noncopyable
{
public:
Impl(odf_reader::odf_read_context & odf_context_, pptx_conversion_context & pptx_context_);
public:
styles_context & get_styles_context() { return styles_context_; }
void add_text(const std::wstring & text);
void add_paragraph(const std::wstring & para);
void start_paragraph(const std::wstring & styleName);
void end_paragraph ();
void start_span (const std::wstring & styleName);
void end_span ();
std::wstring end_span2 ();
void start_object();
std::wstring end_object ();
void start_base_style(const std::wstring baseStyleName, const odf_types::style_family::type baseStyleType);
void end_base_style();
void ApplyTextProperties (std::wstring style, std::wstring para_style, odf_reader::text_format_properties & propertiesOut, bool inStyle = false);
void ApplyParagraphProperties (std::wstring para_style, odf_reader::paragraph_format_properties & propertiesOut, bool inStyle = false);
void ApplyListProperties (odf_reader::paragraph_format_properties & propertiesOut, int Level);
odf_reader::style_list_level_properties* ApplyListProperties (odf_reader::paragraph_format_properties & propertiesOut, odf_reader::text_list_style* text_list_style, int Level);
void set_local_styles_container(odf_reader::styles_container* local_styles_);//this is if object styles are contained in another document
hyperlink_data get_hyperlink();
void start_hyperlink();
void set_rel_id(const std::wstring& rId);
void set_action(const std::wstring& action);
void end_hyperlink ();
void start_list (const std::wstring & StyleName, bool Continue = false);
void end_list ();
void start_list_item(bool restart = false);
void end_list_item ();
void start_field (field_type type, const std::wstring & styleName);
void end_field ();
void start_comment ();
std::wstring end_comment();
std::wstring get_last_paragraph_style_name();
void set_predump(const bool& bPredump);
bool get_lasttext();
void seroing_predump();
void set_line_break(bool& bLineBreak);
void set_svg_height_width(const _CP_OPT(odf_types::length)& svg_height,const _CP_OPT(odf_types::length)& svg_width);
_CP_OPT(odf_types::length) get_svg_width();
_CP_OPT(odf_types::length) get_svg_height();
void set_style_name(const bool& bStyleName);
bool get_has_style_name();
void set_header(const bool& bHeader);
bool in_list_;
bool process_layouts_;
private:
styles_context styles_context_;
odf_reader::odf_read_context & odf_context_ ;
std::wstring hyperlink_hId;
hyperlink_data hyperlink_;
bool in_span;
bool in_paragraph;
bool in_comment;
bool is_predump;
bool is_lasttext;
bool is_line_break;
bool has_style_name;
bool header;
odf_reader::styles_container * local_styles_ptr_;
void write_rPr (std::wostream & strm);
void write_pPr (std::wostream & strm);
void write_t (std::wostream & strm);
std::wstring dump_paragraph();
void dump_run();
void dump_field();
size_t paragraphs_cout_; //???? only because of counting start?
std::wstringstream text_; //incoming text
std::wstringstream paragraph_; //permanently dumped paragraphs
std::wstringstream run_; //permanently dumped chunks with possibly different properties
std::wstring last_paragraph_style_name_;
std::wstring paragraph_style_name_;
std::wstring span_style_name_;
std::wstring base_style_name_;
odf_types::style_family::type base_style_family_;//Presentation Or SpreadSheet
//-------------------------------------------------------------------------------
std::vector<std::wstring> list_style_stack_;
bool first_element_list_item_;
_CP_OPT(odf_types::length) last_run_font_size_;
_CP_OPT(odf_types::length) svg_heightVal;
_CP_OPT(odf_types::length) svg_widthVal;
int new_list_style_number_; // counter for numbering names created during style conversion
boost::unordered_map<std::wstring, std::wstring> list_style_renames_; // numbering rename chains
void write_list_styles(std::wostream & strm);
//void write_list_properties(std::wostream & strm);
std::wstring find_list_rename(const std::wstring & ListStyleName);
std::wstring current_list_style();
///////////////////////////
field_type field_type_;
std::wstringstream field_value_;
pptx_conversion_context & pptx_context_;
};
pptx_text_context::Impl::Impl(odf_reader::odf_read_context & odf_contxt_, pptx_conversion_context & pptx_contxt_):
odf_context_(odf_contxt_), pptx_context_(pptx_contxt_),
paragraphs_cout_(0), in_paragraph(false),in_span(false),is_predump(false),is_lasttext(false),is_line_break(false),has_style_name(false),header(false), in_comment(false), field_type_(none)
{
new_list_style_number_=0;
local_styles_ptr_ = NULL;
process_layouts_ = false;
}
void pptx_text_context::Impl::add_text(const std::wstring & text)
{
if (field_type_)
field_value_ << text;
else
{
if(!has_style_name)
is_lasttext = true;
text_ << text;
}
}
void pptx_text_context::Impl::add_paragraph(const std::wstring & para)
{
paragraph_ << para;
}
void pptx_text_context::Impl::set_local_styles_container(odf_reader::styles_container * local_styles_)
{
local_styles_ptr_= local_styles_;
}
void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
if (paragraphs_cout_++ > 0)
{
//if (in_list_ == false || in_comment == true)
//{
//// end of previous paragraph and start of next
////text_ << L"&#10;";
// text_ << L"\n";
//}
//else/* (paragraph_style_name_ != styleName)*/
{
if(is_lasttext)
is_predump = true;
dump_paragraph();
}
}else
{
text_.str(std::wstring());
field_value_.str(std::wstring());
}
last_paragraph_style_name_ = paragraph_style_name_;
paragraph_style_name_ = styleName;
in_paragraph = true;
is_predump = false;
}
void pptx_text_context::Impl::end_paragraph()
{
in_paragraph = false;
}
void pptx_text_context::Impl::start_span(const std::wstring & styleName)//text chunk in paragraph with its own properties - this can be even 1 letter
{
int text_size = text_.str().length();
if ((span_style_name_ != styleName && text_size > 0) || in_span)
{
dump_run();
}
span_style_name_ = styleName;
in_span = true;
}
void pptx_text_context::Impl::end_span()
{
dump_run();
span_style_name_ = L"";
in_span = false;
}
std::wstring pptx_text_context::Impl::end_span2()
{
dump_run();
span_style_name_ = L"";
in_span = false;
return run_.str();
}
void pptx_text_context::Impl::start_hyperlink()
{
dump_run();//check
}
void pptx_text_context::Impl::end_hyperlink()
{
dump_run();
hyperlink_ = { L"", L"" };
}
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name, std::wstring para_style_name, odf_reader::text_format_properties & propertiesOut, bool inStyle)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* para_style = NULL;
odf_reader::style_instance* text_style = NULL;
odf_reader::style_instance* baseStyle = NULL;
if (local_styles_ptr_)
{
para_style = local_styles_ptr_->style_by_name (para_style_name, odf_types::style_family::Paragraph, inStyle);
text_style = local_styles_ptr_->style_by_name (style_name, odf_types::style_family::Text, inStyle);
defaultStyle = local_styles_ptr_->style_default_by_type (odf_types::style_family::Text);
baseStyle = local_styles_ptr_->style_by_name (base_style_name_, base_style_family_, inStyle);
}
else
{
para_style = odf_context_.styleContainer().style_by_name (para_style_name, odf_types::style_family::Paragraph, inStyle);
text_style = odf_context_.styleContainer().style_by_name (style_name, odf_types::style_family::Text, inStyle);
defaultStyle = odf_context_.styleContainer().style_default_by_type (odf_types::style_family::Text);
baseStyle = odf_context_.styleContainer().style_by_name (base_style_name_, base_style_family_, inStyle);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (para_style) instances.push_back(para_style);
if (text_style) instances.push_back(text_style);
if (text_style) get_styles_context().start_process_style(text_style);
else if (para_style) get_styles_context().start_process_style(para_style);
else get_styles_context().start_process_style(baseStyle);
odf_reader::text_format_properties_ptr text_props = calc_text_properties_content(instances);
if (text_props)
{
propertiesOut.apply_from(*text_props.get());
}
}
odf_reader::style_list_level_properties* pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_properties & propertiesOut, odf_reader::text_list_style* text_list_style, int Level)
{
if (!text_list_style) return NULL;
if (Level >= (int)text_list_style->content_.size()) return NULL;
odf_reader::office_element_ptr elm = text_list_style->content_[Level];
odf_reader::office_element_ptr elm_list;
if (elm->get_type() == typeTextListLevelStyleBullet)
{
odf_reader::text_list_level_style_bullet* list_bullet = dynamic_cast<odf_reader::text_list_level_style_bullet *>(elm.get());
if (list_bullet)elm_list = list_bullet->list_level_properties_;
}
if (elm->get_type() == typeTextListLevelStyleNumber)
{
odf_reader::text_list_level_style_number* list_number = dynamic_cast<odf_reader::text_list_level_style_number *>(elm.get());
if (list_number)elm_list = list_number->list_level_properties_;
}
if (elm->get_type() == typeTextListLevelStyleImage)
{
odf_reader::text_list_level_style_image* list_image = dynamic_cast<odf_reader::text_list_level_style_image *>(elm.get());
if (list_image)elm_list = list_image->list_level_properties_;
}
////////////////////
odf_reader::style_list_level_properties* list_properties = NULL;
if (elm_list)
{
list_properties = dynamic_cast<odf_reader::style_list_level_properties *>(elm_list.get());
}
elm->pptx_convert(pptx_context_);
return list_properties;
}
void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_properties & propertiesOut, int Level)
{
if (Level < 0) return;
if (list_style_stack_.empty()) return;
odf_reader::text_list_style* text_list_style = odf_context_.listStyleContainer().list_style_by_name(list_style_stack_.back());
odf_reader::style_list_level_properties* list_properties = ApplyListProperties(propertiesOut, text_list_style, Level);
if (list_properties)
{
if(list_properties->text_min_label_width_.has_value() && list_properties->text_min_label_width_->get_value() > 0 && (!propertiesOut.fo_text_indent_.has_value() || (propertiesOut.fo_text_indent_.has_value() && (propertiesOut.fo_text_indent_->get_length().get_value() == 0 || (propertiesOut.fo_margin_left_.has_value() && propertiesOut.fo_margin_left_->get_length().get_value() == 0 && propertiesOut.fo_text_indent_->get_length().get_value() < 0)))))
propertiesOut.fo_text_indent_ = list_properties->text_min_label_width_;
if (list_properties->text_space_before_)
{
double spaceBeforeTwip;
odf_types::length::unit tempTypeUnit = list_properties->text_space_before_->get_unit();
if(propertiesOut.fo_margin_left_)
{
tempTypeUnit = propertiesOut.fo_margin_left_->get_length().get_unit();
spaceBeforeTwip = list_properties->text_space_before_->get_value_unit(tempTypeUnit);
spaceBeforeTwip += propertiesOut.fo_margin_left_->get_length().get_value();
}
else
spaceBeforeTwip = list_properties->text_space_before_->get_value_unit(tempTypeUnit);
if (spaceBeforeTwip > 0)
{
propertiesOut.fo_margin_left_ = odf_types::length(spaceBeforeTwip, tempTypeUnit);
}
}
else if(!propertiesOut.fo_margin_left_)
propertiesOut.fo_margin_left_ = odf_types::length(0, odf_types::length::pt);
if (list_properties->fo_width_)
{
}
}
}
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style_name, odf_reader::paragraph_format_properties & propertiesOut, bool inStyle)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* style = NULL;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* baseStyle = NULL;
if (local_styles_ptr_)
{
style = local_styles_ptr_->style_by_name (style_name, odf_types::style_family::Paragraph, inStyle);
defaultStyle = local_styles_ptr_->style_default_by_type (odf_types::style_family::Paragraph);
baseStyle = local_styles_ptr_->style_by_name (base_style_name_, base_style_family_, inStyle);
}
else
{
style = odf_context_.styleContainer().style_by_name (style_name, odf_types::style_family::Paragraph, inStyle);
defaultStyle = odf_context_.styleContainer().style_default_by_type (odf_types::style_family::Paragraph);
baseStyle = odf_context_.styleContainer().style_by_name (base_style_name_, base_style_family_, inStyle);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (style) instances.push_back(style);
if (style) get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
void pptx_text_context::Impl::write_pPr(std::wostream & strm)
{
get_styles_context().start();
int level = list_style_stack_.size() - 1;
if (is_predump || header)
{
seroing_predump();
level = -1;
}
else
seroing_predump();
odf_reader::paragraph_format_properties paragraph_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_, process_layouts_);
ApplyListProperties (paragraph_properties_, level);//apply list alignment to paragraph properties
paragraph_properties_.pptx_convert(pptx_context_);
const std::wstring& paragraphAttr = get_styles_context().paragraph_attr().str();
const std::wstring & paragraphNodes = get_styles_context().paragraph_nodes().str();
if (level < 0 && paragraphAttr.length() < 1 && paragraphNodes.empty()) return;
strm << L"<a:pPr ";
if (level >= 0)
{
if (level > 8) level = 0;
strm << L"lvl=\"" << level << L"\" ";
}
strm << paragraphAttr;
strm << ">";
strm << paragraphNodes;
if (process_layouts_)
{
odf_reader::text_format_properties text_properties_;
ApplyTextProperties(L"", paragraph_style_name_, text_properties_, process_layouts_);
text_properties_.oox_serialize(strm, true, odf_context_.fontContainer(), true);
}
if (level >= 0 )
{
strm << get_styles_context().list_style().str();
}
strm << L"</a:pPr>";
}
void pptx_text_context::Impl::write_t(std::wostream & strm)
{
}
void pptx_text_context::Impl::write_rPr(std::wostream & strm)
{
if (paragraph_style_name_.empty() && span_style_name_.empty() && !(!hyperlink_hId.empty()) && base_style_name_.empty())
return;
odf_reader::text_format_properties text_properties_;
ApplyTextProperties(span_style_name_, paragraph_style_name_, text_properties_, true);
get_styles_context().start();
get_styles_context().hlinkClick() = hyperlink_hId;
text_properties_.pptx_convert(pptx_context_);
if (text_properties_.fo_font_size_ && text_properties_.fo_font_size_->get_type() == odf_types::font_size::Length)
last_run_font_size_ = text_properties_.fo_font_size_->get_length();
strm << get_styles_context().text_style().str();
}
std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
{
if (in_comment) return L"";
end_span();
std::wstring str_run = run_.str();
if (false == str_run.empty() || false == paragraph_style_name_.empty() || (false == base_style_name_.empty() && process_layouts_))
{
CP_XML_WRITER(paragraph_)
{
CP_XML_NODE(L"a:p")
{
write_pPr(CP_XML_STREAM());
if (str_run.length() > 0)
{
CP_XML_STREAM() << run_.str();
}
CP_XML_NODE(L"a:endParaRPr")
{
odf_reader::paragraph_format_properties parap_props;
ApplyParagraphProperties(paragraph_style_name_, parap_props, false);
if (last_run_font_size_ && !parap_props.fo_margin_top_)
{
int sz = last_run_font_size_->get_value_unit(odf_types::length::pt) * 100;
CP_XML_ATTR(L"sz", sz);
}
last_run_font_size_ = boost::none;
}
}
}
run_.str(std::wstring());
}
return paragraph_.str();
}
#if defined (_WIN32) || defined (_WIN64)
#include <Objbase.h>
#endif
void pptx_text_context::Impl::dump_field()
{
if (field_type_ == none) return;
CP_XML_WRITER(run_)
{
CP_XML_NODE(L"a:fld")
{
std::wstring content = XmlUtils::EncodeXmlString(field_value_.str());
std::wstring string_id;
std::wstring string_type;
#if defined (_WIN32) || defined (_WIN64)
GUID new_id;
CoCreateGuid(&new_id);
wchar_t str[100]={};
StringFromGUID2(new_id,str,100);
string_id = str;
#endif
switch (field_type_)
{
case page_number:
{
string_type = L"slidenum";
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{5CC2A059-B141-45A7-B910-B096D6D06820}";
#endif
// content = L"#";
}
break;
case date:
{
string_type = L"datetime1";
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}";
#endif
if (content.length()<1)content = XmlUtils::EncodeXmlString(L"01.01.2000");
}
break;
case time:
{
string_type = L"datetime11";
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}";
#endif
if (content.length()<1)content = XmlUtils::EncodeXmlString(L"00:00:00");
}
break;
case datetime:
{
string_type = L"datetime1";
#if !defined (_WIN32) && !defined (_WIN64)
string_id = L"{A9EA0FE8-FEF9-4B2F-BC9D-19DDCDB4AB9B}";
#endif
}break;
}
if (string_type.length()>0)
{
CP_XML_ATTR(L"id", string_id);
CP_XML_ATTR(L"type", string_type);
CP_XML_NODE(L"a:t")
{
CP_XML_STREAM() << content;
}
}
else
{
//write as regular text
text_ << content;
}
}
}
field_value_.str(std::wstring());
field_type_ = none;
}
void pptx_text_context::Impl::dump_run()
{
if (in_comment) return;
dump_field();
//if (process_layouts_)
// return;
const std::wstring content = XmlUtils::EncodeXmlString(text_.str());
//if (content.length() <1 && span_style_name_.length()<1) return ; ... check if empty lines are needed ...
if (content.length() > 0)
{
if(is_line_break)
{
CP_XML_WRITER(run_)
{
CP_XML_NODE(L"a:br")
{
write_rPr(CP_XML_STREAM());
// CP_XML_NODE(L"a:t")
// {
// //CP_XML_ATTR(L"xml:space", L"preserve");
// CP_XML_STREAM() << content;
// }
}
text_.str(std::wstring());
}
is_line_break = false;
}
else
{
CP_XML_WRITER(run_)
{
CP_XML_NODE(L"a:r")
{
write_rPr(CP_XML_STREAM());
CP_XML_NODE(L"a:t")
{
//CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
text_.str(std::wstring());
}
}
}
else
{
odf_reader::text_format_properties text_properties_;
ApplyTextProperties(span_style_name_, paragraph_style_name_, text_properties_);
if (text_properties_.fo_font_size_ && text_properties_.fo_font_size_->get_type() == odf_types::font_size::Length)
last_run_font_size_ = text_properties_.fo_font_size_->get_length();
}
hyperlink_hId =L"";
}
void pptx_text_context::Impl::start_base_style(const std::wstring baseStyleName, const odf_types::style_family::type baseStyleType)
{
base_style_name_ = baseStyleName;
base_style_family_ = baseStyleType;
}
void pptx_text_context::Impl::end_base_style()
{
base_style_name_ = L"";
base_style_family_ = odf_types::style_family::None;
}
void pptx_text_context::Impl::start_object()
{
paragraphs_cout_ = 0;
run_.str(std::wstring());
paragraph_.str(std::wstring());
text_.str(std::wstring());
field_value_.str(std::wstring());
paragraph_style_name_ = L"";
span_style_name_ = L"";
}
std::wstring pptx_text_context::Impl::end_object()
{
dump_paragraph(/*true*/);
std::wstring str_paragraph = paragraph_.str();
std::wstringstream str_output;
if (str_paragraph.length() > 0)
{
write_list_styles(str_output);
str_output << str_paragraph;
}
paragraphs_cout_ = 0;
run_.str(std::wstring());
paragraph_.str(std::wstring());
text_.str(std::wstring());
field_value_.str(std::wstring());
paragraph_style_name_ = L"";
span_style_name_=L"";
return str_output.str();
}
void pptx_text_context::Impl::start_list_item(bool restart)
{
if (paragraphs_cout_ > 0 && restart)
{
dump_paragraph();
}
in_list_ = true;
first_element_list_item_ = true;
if (restart && !list_style_stack_.empty())
{
const std::wstring curStyleName = current_list_style();
const std::wstring newStyleName = curStyleName + std::to_wstring(new_list_style_number_++);
list_style_renames_[curStyleName] = newStyleName;
odf_reader::list_style_container & lists = odf_context_.listStyleContainer();
odf_reader::text_list_style * curStyle = lists.list_style_by_name(curStyleName);
lists.add_list_style(curStyle, newStyleName);
end_list();
start_list(newStyleName);
}
}
void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Continue)
{
if (paragraphs_cout_ > 0 && ( in_paragraph || !list_style_stack_.empty()))
{
dump_paragraph();
}
if (!StyleName.empty())
{
std::wstring name = StyleName;
if (Continue)
name = find_list_rename(name);
list_style_stack_.push_back(name);
}
else if (!list_style_stack_.empty())
list_style_stack_.push_back(list_style_stack_.back());
else
list_style_stack_.push_back(L"");
}
void pptx_text_context::Impl::end_list()
{
in_list_ = false;
list_style_stack_.pop_back();// don't erase yet.. will clear when saved to lstStyles
}
std::wstring pptx_text_context::Impl::current_list_style()
{
if (!list_style_stack_.empty())
return list_style_stack_.back();
else
return L"";
}
std::wstring pptx_text_context::Impl::find_list_rename(const std::wstring & ListStyleName)
{
std::wstring name = ListStyleName;
while (list_style_renames_.count(name) > 0)
name = list_style_renames_.at(name);
return name;
}
void pptx_text_context::Impl::end_list_item()
{
dump_paragraph();
if (paragraphs_cout_ != 0)
paragraphs_cout_--;
paragraph_style_name_ = L"";
in_list_ = false;
}
void pptx_text_context::Impl::start_field(field_type type, const std::wstring & styleName)
{
field_type_ = type;
}
void pptx_text_context::Impl::start_comment()
{
in_comment = true;//separate branch - since without formatting
}
std::wstring pptx_text_context::Impl::end_comment()
{
std::wstring str_comment = text_.str();
text_.str(std::wstring());
in_comment = false;
paragraphs_cout_ = 0;
paragraph_style_name_ = L"";
span_style_name_=L"";
return str_comment;
}
void pptx_text_context::Impl::end_field()
{
dump_run();
field_type_ = none;
}
void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults style paragraph & lists
{
odf_reader::list_style_container & list_styles = odf_context_.listStyleContainer();
if (list_styles.empty())
return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:lstStyle");
//{
// //defPPr
// //...
// //list levels 0 - 8
// BOOST_FOREACH(std::wstring & st_name, list_style_stack_ )
// {
// odf_reader::text_list_style * s = list_styles.list_style_by_name(st_name);
//
// BOOST_FOREACH(odf_reader::office_element_ptr & elm, s->get_content())
// {
// elm->pptx_convert(pptx_context_);
// }
// }
// CP_XML_STREAM() << get_styles_context().list_style().str();
//}
}
list_style_stack_.clear();
}
void pptx_text_context::Impl::set_rel_id(const std::wstring& rId)
{
hyperlink_.rId = rId;
}
void pptx_text_context::Impl::set_action(const std::wstring& action)
{
hyperlink_.action = action;
}
hyperlink_data pptx_text_context::Impl::get_hyperlink()
{
return hyperlink_;
}
std::wstring pptx_text_context::Impl::get_last_paragraph_style_name()
{
return last_paragraph_style_name_;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
pptx_text_context::pptx_text_context(odf_reader::odf_read_context & odf_context_, pptx_conversion_context & pptx_context_):
impl_(new pptx_text_context::Impl(odf_context_,pptx_context_))
{}
pptx_text_context::~pptx_text_context()
{
}
void pptx_text_context::set_local_styles_container(odf_reader::styles_container* local_styles_)
{
return impl_->set_local_styles_container(local_styles_);
}
void pptx_text_context::add_paragraph(const std::wstring & para)
{
return impl_->add_paragraph(para);
}
void pptx_text_context::add_text(const std::wstring & text)
{
return impl_->add_text(text);
}
bool pptx_text_context::in_list()
{
return impl_->in_list_;
}
void pptx_text_context::start_paragraph(const std::wstring & styleName)
{
return impl_->start_paragraph(styleName);
}
void pptx_text_context::end_paragraph()
{
return impl_->end_paragraph();
}
void pptx_text_context::start_span(const std::wstring & styleName)
{
return impl_->start_span(styleName);
}
void pptx_text_context::end_span()
{
return impl_->end_span();
}
std::wstring pptx_text_context::end_span2()
{
return impl_->end_span2();
}
void pptx_text_context::start_list_item(bool restart)
{
return impl_->start_list_item(restart);
}
void pptx_text_context::end_list_item()
{
return impl_->end_list_item();
}
void pptx_text_context::start_list(const std::wstring & StyleName, bool Continue)
{
return impl_->start_list(StyleName,Continue);
}
void pptx_text_context::end_list()
{
return impl_->end_list();
}
void pptx_text_context::start_base_style(const std::wstring baseStyleName, const odf_types::style_family::type baseStyleType)
{
return impl_->start_base_style(baseStyleName, baseStyleType);
}
void pptx_text_context::end_base_style()
{
return impl_->end_base_style();
}
void pptx_text_context::start_object()
{
return impl_->start_object();
}
void pptx_text_context::start_hyperlink()
{
return impl_->start_hyperlink();
}
void pptx_text_context::set_rel_id(const std::wstring& rId)
{
impl_->set_rel_id(rId);
}
void pptx_text_context::set_action(const std::wstring& action)
{
impl_->set_action(action);
}
void pptx_text_context::end_hyperlink()
{
return impl_->end_hyperlink();
}
std::wstring pptx_text_context::end_object()
{
return impl_->end_object();
}
hyperlink_data pptx_text_context::get_hyperlink()
{
return impl_->get_hyperlink();
}
styles_context & pptx_text_context::get_styles_context()
{
return impl_->get_styles_context() ;
}
void pptx_text_context::start_field(field_type type, const std::wstring & styleName)
{
impl_->start_field(type, styleName);
}
void pptx_text_context::end_field()
{
impl_->end_field();
}
void pptx_text_context::start_comment_content()
{
impl_->start_comment();
}
std::wstring pptx_text_context::end_comment_content()
{
return impl_->end_comment();
}
void pptx_text_context::set_process_layouts(bool val)
{
impl_->process_layouts_ = val;
}
std::wstring pptx_text_context::get_last_paragraph_style_name()
{
return impl_->get_last_paragraph_style_name();
}
void pptx_text_context::set_predump(const bool &bPreDump)
{
impl_->set_predump(bPreDump);
}
bool pptx_text_context::get_lasttext()
{
return impl_->get_lasttext();
}
void pptx_text_context::set_line_break(bool& bLineBreak)
{
impl_->set_line_break(bLineBreak);
}
void pptx_text_context::set_svg_height_width(const _CP_OPT(odf_types::length) &svg_height, const _CP_OPT(odf_types::length) &svg_width)
{
impl_->set_svg_height_width(svg_height, svg_width);
}
_CP_OPT(odf_types::length) pptx_text_context::get_svg_height()
{
return impl_->get_svg_height();
}
_CP_OPT(odf_types::length) pptx_text_context::get_svg_width()
{
return impl_->get_svg_width();
}
void pptx_text_context::set_style_name(const bool& bStyleName)
{
impl_->set_style_name(bStyleName);
}
bool pptx_text_context::get_has_style_name()
{
return impl_->get_has_style_name();
}
void pptx_text_context::set_header(const bool& bHeader)
{
impl_->set_header(bHeader);
}
void pptx_text_context::Impl::set_predump(const bool& bPredump)
{
is_predump = bPredump;
}
bool pptx_text_context::Impl::get_lasttext()
{
return is_lasttext;
}
void pptx_text_context::Impl::seroing_predump()
{
is_predump = false;
is_lasttext = false;
}
void pptx_text_context::Impl::set_line_break(bool& bLineBreak)
{
is_line_break = bLineBreak;
}
void pptx_text_context::Impl::set_svg_height_width(const _CP_OPT(odf_types::length) &svg_height, const _CP_OPT(odf_types::length) &svg_width)
{
svg_heightVal = svg_height;
svg_widthVal = svg_width;
}
_CP_OPT(odf_types::length) pptx_text_context::Impl::get_svg_height()
{
return svg_heightVal;
}
_CP_OPT(odf_types::length) pptx_text_context::Impl::get_svg_width()
{
return svg_widthVal;
}
void pptx_text_context::Impl::set_style_name(const bool& bStyleName)
{
has_style_name = bStyleName;
}
bool pptx_text_context::Impl::get_has_style_name()
{
return has_style_name;
}
void pptx_text_context::Impl::set_header(const bool& bHeader)
{
header = bHeader;
}
}
}