Commit f613a8dd authored by Alexey Golubev's avatar Alexey Golubev

Merge branch 'develop' of github.com:ONLYOFFICE/core into develop

parents dd3a4e23 6361ee6f
......@@ -242,6 +242,10 @@ namespace formulasconvert {
if (boost::regex_search(expr, res, boost::wregex(L"(?:[\\w]+:)?=(.+)"), boost::match_default))
{
expr = res[1].str();
while (expr.find(L"=") == 0)
{
expr.erase(expr.begin(), expr.begin() + 1);
}
return true;
}
else
......@@ -305,6 +309,37 @@ namespace formulasconvert {
else if (what[3].matched)
return what[3].str();
}
std::wstring convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"'", L"APOSTROF");
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"\"", L"KAVYCHKA");
return inner;
}
else if (what[3].matched)
return what[3].str();
}
std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
......@@ -380,12 +415,19 @@ namespace formulasconvert {
&replace_point_space,
boost::match_default | boost::format_all);
boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
check_formula(workstr);
replace_cells_range(workstr, true);
replace_semicolons(workstr);
replace_vertical(workstr);
workstr = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
//boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
replace_cells_range (workstr, true);
replace_semicolons (workstr);
replace_vertical (workstr);
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
......@@ -397,6 +439,15 @@ namespace formulasconvert {
boost::algorithm::replace_all(workstr, L"PROBEL" , L" ");
boost::algorithm::replace_all(workstr, L"APOSTROF" , L"'");
boost::algorithm::replace_all(workstr, L"TOCHKA" , L".");
boost::algorithm::replace_all(workstr, L"SCOBCAIN", L"(");
boost::algorithm::replace_all(workstr, L"SCOBCAOUT", L")");
boost::algorithm::replace_all(workstr, L"KVADRATIN", L"[");
boost::algorithm::replace_all(workstr, L"KVADRATOUT", L"]");
boost::algorithm::replace_all(workstr, L"PROBEL", L" ");
boost::algorithm::replace_all(workstr, L"KAVYCHKA", L"\"");
return workstr;
}
......@@ -495,6 +546,7 @@ namespace formulasconvert {
boost::match_default | boost::format_all);
boost::algorithm::replace_all(workstr, L"'", L"APOSTROF");
//boost::algorithm::replace_all(workstr, L"", L"APOSTROF");
impl_->replace_named_ref(workstr, withTableName);
......
......@@ -468,7 +468,10 @@ std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"'", L"APOSTROF");
return inner;
}
......@@ -478,7 +481,10 @@ std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what
boost::algorithm::replace_all(inner, L"(", L"SCOBCAIN");
boost::algorithm::replace_all(inner, L")", L"SCOBCAOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"[", L"KVADRATIN");
boost::algorithm::replace_all(inner, L"]", L"KVADRATOUT");
boost::algorithm::replace_all(inner, L" ", L"PROBEL");
boost::algorithm::replace_all(inner, L"\"", L"KAVYCHKA");
return inner;
}
......@@ -567,7 +573,10 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::algorithm::replace_all(res, L"SCOBCAIN", L"(");
boost::algorithm::replace_all(res, L"SCOBCAOUT", L")");
boost::algorithm::replace_all(res, L"PROBEL", L" ");
boost::algorithm::replace_all(res, L"KVADRATIN", L"[");
boost::algorithm::replace_all(res, L"KVADRATOUT", L"]");
boost::algorithm::replace_all(res, L"PROBEL", L" ");
boost::algorithm::replace_all(res, L"APOSTROF", L"'");
......
......@@ -64,6 +64,8 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
{
if (bySort.empty()) return;
if (byRow) return;
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"sortState")
......
......@@ -133,7 +133,7 @@ public:
virtual void visit(const table_table_column& val)
{
const unsigned int columnsRepeated = val.table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring defaultCellStyleName = val.table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name();
const std::wstring defaultCellStyleName = val.table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
visit_column(columnsRepeated, defaultCellStyleName);
}
virtual void visit(const table_calculation_settings & val)
......@@ -202,9 +202,7 @@ public:
virtual void visit(const table_table_row& val)
{
unsigned int repeated = val.table_table_row_attlist_.table_number_rows_repeated_;
std::wstring defaultCellStyle = val.
table_table_row_attlist_.
table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name();
std::wstring defaultCellStyle = val.table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
if (visit_rows(repeated, defaultCellStyle))
{
......
......@@ -583,9 +583,24 @@ void table_rows_and_groups::add_child_element( xml::sax * Reader, const std::wst
}
else if (L"table" == Ns && (L"table-rows" == Name || L"table-row" == Name || L"table-header-rows" == Name) )
{
_CP_PTR(table_rows_no_group) elm = table_rows_no_group::create();
elm->add_child_element(Reader, Ns, Name, Context);
content_.push_back(elm);
bool add_new_no_group = false;
if (content_.empty()) add_new_no_group = true;
else
{
if (content_.back()->get_type() != typeTableTableRowNoGroup)
add_new_no_group = true;
}
if (add_new_no_group)
{
_CP_PTR(table_rows_no_group) elm = table_rows_no_group::create();
elm->add_child_element(Reader, Ns, Name, Context);
content_.push_back(elm);
}
else
{
table_rows_no_group* rows_no_group = static_cast<table_rows_no_group*>(content_.back().get());
rows_no_group->add_child_element(Reader, Ns, Name, Context);
}
}
else
not_applicable_element(L"table-rows-and-groups", Reader, Ns, Name);
......
......@@ -44,8 +44,8 @@
#include "datatypes/tablemode.h"
#include "datatypes/common_attlists.h"
#include "datatypes/style_ref.h"
#include "datatypes/tablevisibility.h"
namespace cpdoccore {
namespace odf_reader {
......@@ -56,20 +56,20 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(bool) table_is_sub_table_;
_CP_OPT(std::wstring) table_name_;
_CP_OPT(odf_types::style_ref) table_style_name_;
_CP_OPT(std::wstring) table_template_name_;
_CP_OPT(bool) table_is_sub_table_;
_CP_OPT(std::wstring) table_name_;
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_template_name_;
bool table_protected_; // default false
_CP_OPT(std::wstring) table_protection_key_;
bool table_print_; // default true
_CP_OPT(std::wstring) table_print_ranges_;
bool table_protected_; // default false
_CP_OPT(std::wstring) table_protection_key_;
bool table_print_; // default true
_CP_OPT(std::wstring) table_print_ranges_;
bool table_use_first_row_styles_; // default false;
bool table_use_banding_rows_styles_; //defualt false;
bool table_use_first_column_styles_; //defualt false;
bool table_use_banding_columns_styles_; //defualt false;
bool table_use_first_row_styles_; // default false;
bool table_use_banding_rows_styles_; //defualt false;
bool table_use_first_column_styles_; //defualt false;
bool table_use_banding_columns_styles_; //defualt false;
friend class table_table;
};
......@@ -82,9 +82,9 @@ public:
public:
unsigned int table_number_rows_repeated_; // default 1
_CP_OPT(odf_types::style_ref) table_style_name_;
_CP_OPT(odf_types::style_ref) table_default_cell_style_name_;
odf_types::table_visibility table_visibility_; // default Visible
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_default_cell_style_name_;
odf_types::table_visibility table_visibility_; // default Visible
};
......@@ -95,10 +95,10 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(odf_types::style_ref) table_style_name_;
_CP_OPT(std::wstring) table_content_validation_name_;
_CP_OPT(std::wstring) table_formula_;
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_content_validation_name_;
_CP_OPT(std::wstring) table_formula_;
odf_types::common_value_and_type_attlist common_value_and_type_attlist_;
......@@ -247,10 +247,10 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(odf_types::style_ref) table_style_name_;
odf_types::table_visibility table_visibility_; // default Visible
_CP_OPT(odf_types::style_ref) table_default_cell_style_name_;
unsigned int table_number_columns_repeated_; // default 1
_CP_OPT(std::wstring) table_style_name_;
odf_types::table_visibility table_visibility_; // default Visible
_CP_OPT(std::wstring) table_default_cell_style_name_;
};
......
......@@ -67,8 +67,8 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & _Wostream = Context.output_stream();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or( style_ref(L"") ).style_name();
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( style_ref(L"") ).style_name();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i)
{
......@@ -148,9 +148,7 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
bool sub_table = table_table_attlist_.table_is_sub_table_.get_value_or(false);
//todooo придумать как сделать внешние границы sub-таблицы границами внешней ячейки (чтоб слияние произошло)
std::wstring tableStyleName = L"";
if (table_table_attlist_.table_style_name_)
tableStyleName = table_table_attlist_.table_style_name_->style_name() ;
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
_Wostream << L"<w:tbl>";
......@@ -249,14 +247,14 @@ void table_table_column::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & _Wostream = Context.output_stream();
const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name();
const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
Context.get_table_context().start_column(columnsRepeated, defaultCellStyle);
for (unsigned int i = 0; i < columnsRepeated; ++i)
{
if (table_table_column_attlist_.table_style_name_)
{
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_->style_name();
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get();
if (style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn,Context.process_headers_footers_ ))
{
......@@ -281,8 +279,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
_Wostream << L"<w:tc>";
_Wostream << L"<w:tcPr>";
const std::wstring styleName = table_table_cell_attlist_.table_style_name_ ?
table_table_cell_attlist_.table_style_name_->style_name() : L"";
const std::wstring styleName = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
//_Wostream << L"<w:tcW w:w=\"0\" w:type=\"auto\" />";
......
......@@ -70,8 +70,8 @@ void table_table_row::pptx_convert(oox::pptx_conversion_context & Context)
{
std::wostream & _Wostream = Context.get_table_context().tableData();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or( style_ref(L"") ).style_name();
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( style_ref(L"") ).style_name();
const std::wstring styleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = table_table_row_attlist_.table_default_cell_style_name_.get_value_or(L"");
for (unsigned int i = 0; i < table_table_row_attlist_.table_number_rows_repeated_; ++i)
{
......@@ -160,9 +160,7 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_table();
//////////////////////////////////////////////////////////////////
std::wstring tableStyleName = L"";
if (table_table_attlist_.table_style_name_)
tableStyleName = table_table_attlist_.table_style_name_->style_name() ;
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
Context.get_table_context().start_table(tableStyleName);
......@@ -295,7 +293,7 @@ void table_table_column::pptx_convert(oox::pptx_conversion_context & Context)
std::wostream & _Wostream = Context.get_table_context().tableData();
const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name();
const std::wstring defaultCellStyle = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
Context.get_table_context().start_column(columnsRepeated, defaultCellStyle);
......@@ -303,7 +301,7 @@ void table_table_column::pptx_convert(oox::pptx_conversion_context & Context)
{
if (table_table_column_attlist_.table_style_name_)
{
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_->style_name();
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get();
style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn,false );
if ((inst) && (inst->content()))
......@@ -353,7 +351,7 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context)
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
style_name = table_table_cell_attlist_.table_style_name_ ? table_table_cell_attlist_.table_style_name_->style_name() : L"";
style_name = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
if (!style_name.empty())
{
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
......
......@@ -80,8 +80,8 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
///обработка чтилей для роу -
size_t Default_Cell_style_in_row_ = 0;
const std::wstring rowStyleName = table_table_row_attlist_.table_style_name_.get_value_or( style_ref(L"") ).style_name();
const std::wstring defaultCellStyleName = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( style_ref(L"") ).style_name();
const std::wstring rowStyleName = table_table_row_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyleName = table_table_row_attlist_.table_default_cell_style_name_.get_value_or( L"");
style_instance * instStyle_CellDefault =
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyleName, style_family::TableCell,false/*false*/);
......@@ -109,8 +109,8 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool skip_next_row = false;
std::wstring ht = L"";
double row_height = 0.0;
std::wstring ht = L"";
double row_height = 0.0;
odf_read_context & odfContext = Context.root()->odf_context();
......@@ -211,10 +211,10 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
if (Context.is_empty_row())
{
skip_next_row = true;
if (table_table_row_attlist_.table_number_rows_repeated_ > 0xff00)
if (table_table_row_attlist_.table_number_rows_repeated_ > 0xf000)
break;//Уведомление_о_вручении.ods (1 лист)
}
if (content_.size() > 0 && table_table_row_attlist_.table_number_rows_repeated_ > 0xff00)
if (content_.size() > 0 && table_table_row_attlist_.table_number_rows_repeated_ > 1000)
{
table_table_cell * table_cell = dynamic_cast<table_table_cell *>(content_[0].get());
if ((table_cell) && (table_cell->table_table_cell_attlist_.table_number_columns_repeated_ > 1000))
......@@ -250,6 +250,27 @@ void table_rows::xlsx_convert(oox::xlsx_conversion_context & Context)
table_table_rows_->xlsx_convert(Context);
else
{
if (table_table_row_.size() > 1)
{
//check 2 last rows for repeate > 65000 & 1024
table_table_row* row_last = dynamic_cast<table_table_row*>(table_table_row_[table_table_row_.size() - 1].get());
table_table_row* row_last_1 = dynamic_cast<table_table_row*>(table_table_row_[table_table_row_.size() - 2].get());
if (row_last->table_table_row_attlist_.table_number_rows_repeated_ > 1000 &&
row_last_1->table_table_row_attlist_.table_number_rows_repeated_ > 1000 ||
row_last_1->table_table_row_attlist_.table_number_rows_repeated_ > 0xf000)
{
std::wstring style = row_last->table_table_row_attlist_.table_style_name_.get_value_or(L"");
std::wstring style_1 = row_last->table_table_row_attlist_.table_style_name_.get_value_or(L"");
if (style == style_1)//check for empty also ????
{
row_last_1->table_table_row_attlist_.table_number_rows_repeated_ = 1024;
table_table_row_.pop_back();
}
}
}
for (int i = 0; i < table_table_row_.size(); i++)
{
table_table_row_[i]->xlsx_convert(Context);
......@@ -287,7 +308,7 @@ void table_table_row_group::xlsx_convert(oox::xlsx_conversion_context & Context)
void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
{
const std::wstring tableStyleName = table_table_attlist_.table_style_name_ ? table_table_attlist_.table_style_name_->style_name() : L"";
const std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = table_table_attlist_.table_name_.get_value_or(L"");
_CP_LOG << L"[info][xlsx] process table \"" << tableName << L"\"\n" << std::endl;
......@@ -389,8 +410,8 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wostream & strm = Context.current_sheet().cols();
const unsigned int columnsRepeated = table_table_column_attlist_.table_number_columns_repeated_;
const std::wstring styleName = table_table_column_attlist_.table_style_name_.get_value_or(style_ref(L"")).style_name();
const std::wstring defaultCellStyleName = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(style_ref(L"")).style_name();
const std::wstring styleName = table_table_column_attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyleName = table_table_column_attlist_.table_default_cell_style_name_.get_value_or(L"");
int cMin = 0, cMax = 0;
......@@ -447,7 +468,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
}
}
_CP_OPT(double) width;
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_->style_name();
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get_value_or(L"");
if (style_instance * inst = Context.root()->odf_context().styleContainer().style_by_name(colStyleName, style_family::TableColumn,false))
{
if (inst->content())
......@@ -471,7 +492,9 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
//const double width = cmToChars(prop->style_table_column_properties_attlist_.style_column_width_->get_value_unit(length::cm));
// see ECMA-376 page 1768
CP_XML_ATTR(L"width", *width);
if (in_width > 0)
CP_XML_ATTR(L"width", *width);
CP_XML_ATTR(L"customWidth", true);
Context.table_column_last_width(*width);
}
......@@ -582,7 +605,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wostream & strm = Context.current_sheet().sheetData();
const std::wstring formula = table_table_cell_attlist_.table_formula_.get_value_or(L"");
const std::wstring styleName = table_table_cell_attlist_.table_style_name_.get_value_or(style_ref(L"")).style_name();
const std::wstring styleName = table_table_cell_attlist_.table_style_name_.get_value_or(L"");
const common_value_and_type_attlist & attr = table_table_cell_attlist_.common_value_and_type_attlist_;
office_value_type::type odf_value_type = office_value_type::Custom;
......
......@@ -45,8 +45,9 @@ SOURCES += \
../source/RtfDocument.cpp \
../source/RtfGlobalTables.cpp \
../source/RtfOldList.cpp \
../source/RtfOle.cpp \
../source/RtfPicture.cpp \
../source/RtfOle.cpp \
../source/RtfField.cpp \
../source/RtfProperty.cpp \
../source/RtfReader.cpp \
../source/RtfSection.cpp \
......
......@@ -687,6 +687,10 @@
RelativePath="..\source\RtfDocument.h"
>
</File>
<File
RelativePath="..\source\RtfField.cpp"
>
</File>
<File
RelativePath="..\source\RtfField.h"
>
......
......@@ -120,6 +120,8 @@ public:
}
int Find( T piRend )
{
//todooo - add map for seach
for( int i = 0; i < (int)m_aArray.size(); i++ )
if( m_aArray[i] == piRend )
return i;
......
......@@ -76,7 +76,7 @@ public:
if( true == oLevelReader.Parse( oParam, oNewLevel) )
oNewList.AddItem( oNewLevel );
}
oParam.oRtf->m_oListTabel.AddItem( oNewList );
oParam.oRtf->m_oListTable.AddItem( oNewList );
return true;
}
......
......@@ -90,7 +90,7 @@ public:
}
}
}
//----------------------------------------------------------------------------------------------------------
_section last_section;
m_poDocument->GetItem(last_section);
......
......@@ -78,7 +78,7 @@ public:
oNewOverride.m_oOverrideLevels.m_aOverrideLevels.push_back( oOverrideLevel );
}
oParam.oRtf->m_oListOverrideTabel.AddItem( oNewOverride );
oParam.oRtf->m_oListOverrideTable.AddItem( oNewOverride );
return true;
}
......
......@@ -64,9 +64,9 @@ public:
oNewShape->m_nPositionHRelative = 3;
oNewShape->m_nPositionVRelative = 3;
int nIndex = oParam.oRtf->m_oListTabel.m_aPictureList.GetCount();
int nIndex = oParam.oRtf->m_oListTable.m_aPictureList.GetCount();
oParam.oReader->m_mapPictureBullet[nID] = nIndex;
oParam.oRtf->m_oListTabel.m_aPictureList.AddItem( oNewShape );
oParam.oRtf->m_oListTable.m_aPictureList.AddItem( oNewShape );
}
}
if (m_ooxNumbering->m_arrNumPicBullet[i]->m_oDrawing.IsInit())
......
......@@ -57,8 +57,8 @@ public:
RtfRevisionTable m_oRevisionTable;
RtfInformation m_oInformation;
RtfListTable m_oListTabel;
RtfListOverrideTable m_oListOverrideTabel;
RtfListTable m_oListTable;
RtfListOverrideTable m_oListOverrideTable;
RtfParagraphProperty m_oDefaultParagraphProp;
RtfCharProperty m_oDefaultCharProp;
......
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* 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. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* 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: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "RtfField.h"
#include "Writer/OOXWriter.h"
#include "Writer/OOXRelsWriter.h"
CString OOXFieldBegin::RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult += L"{\\field ";
RENDER_RTF_BOOL( m_bDirty, sResult, L"flddirty" )
RENDER_RTF_BOOL( m_bLock, sResult, L"fldlock" )
sResult += L"{\\*\\fldinst";
sResult += m_oCharProperty.RenderToRtf(oRenderParameter);
return sResult;
}
CString OOXFieldBegin::RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
sResult += L"<w:r>";
CString props = m_oCharProperty.RenderToOOX(oRenderParameter);
if (props.IsEmpty())
{
sResult += L"<w:rPr>";
sResult += props;
sResult += L"</w:rPr>";
}
sResult += L"<w:fldChar w:fldCharType=\"separate\"";
RENDER_OOX_INT_ATTRIBUTE( m_bDirty, sResult, L"dirty" )
RENDER_OOX_INT_ATTRIBUTE( m_bLock, sResult, L"fldLock" )
sResult += L"/>";
sResult += L"</w:r>";
return sResult;
}
CString OOXFieldInsertText::RenderToOOX(RenderParameter oRenderParameter)
{
if( NULL != m_oText )
{
CString sResult;
sResult += L"<w:r>";
sResult += L"<w:instrText>";
oRenderParameter.nType = RENDER_TO_RTF_PARAM_CHAR;
oRenderParameter.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
sResult += m_oText->RenderToOOX( oRenderParameter );
sResult += L"</w:instrText>";
sResult += L"</w:r>";
return sResult;
}
else
return L"";
}
CString RtfFieldInst::RenderToRtf(RenderParameter oRenderParameter)
{
return L"";
}
CString RtfFieldInst::RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
return L"";
}
CString RtfField::RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult += L"{\\field ";
if( fm_none != m_eMode )
{
switch( m_eMode )
{
case fm_flddirty: sResult += L"{\\flddirty "; break;
case fm_fldedit: sResult += L"{\\fldedit "; break;
case fm_fldlock: sResult += L"{\\fldlock "; break;
case fm_fldpriv: sResult += L"{\\fldpriv "; break;
}
}
sResult += L"{\\*\\fldinst ";
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_RTF_PARAM_PLAIN;//RENDER_TO_RTF_PARAM_CHAR;
oNewParam.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
sResult += m_pInsert->m_pTextItems->RenderToRtf( oNewParam );
if( true == m_bReferenceToEndnote )
sResult += L"\\fldalt";
if( !m_sData.IsEmpty() )
sResult += L"{\\*\\datafield " + m_sData + L"}";
sResult += L"}";
CString str = m_pResult->m_pTextItems->RenderToRtf( oRenderParameter ) ;
sResult += L"{\\fldrslt " + str + L"}";
sResult += L"}";
return sResult;
}
CString RtfField::RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
CString sResult;
if( true == m_bTextOnly )
{
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_pResult->m_pTextItems->RenderToOOX(oNewParam);
}
else
{
bool bInsert = false;
bool bDelete = false;
CString sAuthor, sDate;
if (m_pInsert->m_oCharProperty.m_nRevised != PROP_DEF)
{
bInsert = true;
sAuthor = m_pInsert->m_oCharProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_pInsert->m_oCharProperty.m_nRevauth] : L"";
sDate = CString(RtfUtility::convertDateTime(m_pInsert->m_oCharProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_pInsert->m_oCharProperty.m_nRevised = PROP_DEF;
}
if (m_pInsert->m_oCharProperty.m_nDeleted != PROP_DEF)
{
bDelete = true;
sAuthor = m_pInsert->m_oCharProperty.m_nRevauthDel != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_pInsert->m_oCharProperty.m_nRevauthDel ] : L"";
sDate = CString(RtfUtility::convertDateTime(m_pInsert->m_oCharProperty.m_nRevdttmDel).c_str());
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_pInsert->m_oCharProperty.m_nDeleted = PROP_DEF;
}
//поверяем на наличие гиперссылки
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_PLAIN;
CString sInsertText = m_pInsert->m_pTextItems->RenderToOOX( oNewParam );
int nIndex = sInsertText.Find( L"HYPERLINK" );
if( -1 != nIndex )
{
CString sHyperlink = sInsertText;
sHyperlink.Delete( nIndex, 9/*(int)_tcslen( L"HYPERLINK" )*/ );
int nSplash = sHyperlink.Find( L"\\" );
if (nSplash > 0)
{
sHyperlink = sHyperlink.Left(nSplash);
}
//оставляем только одну ссылку
sHyperlink.Remove( '\"' );
sHyperlink.Trim();
//заменяем пробелы на %20
sHyperlink.Replace( L" ", L"%20" );
//добавляем в rels
OOXRelsWriter* poRelsWriter = static_cast<OOXRelsWriter*>( oRenderParameter.poRels );
CString sId = poRelsWriter->AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", Utils::PrepareToXML( sHyperlink ), false );
//добавляем гиперссылку в документ
sResult += L"<w:hyperlink r:id=\"" + sId + L"\" >";
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_pResult->RenderToOOX(oNewParam);
sResult += L"</w:hyperlink>";
}
else
{
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
CString props = m_pResult->m_oCharProperty.RenderToOOX(oRenderParameter);
if (!props.IsEmpty()) props = L"<w:rPr>" + props + L"</w:rPr>";
//начинаем Field
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += L"<w:fldChar w:fldCharType=\"begin\"/>";
sResult += L"</w:r>";
CString str = Utils::PrepareToXML( m_pInsert->m_pTextItems->RenderToOOX(oNewParametr) );
sResult += L"<w:r>";
sResult += L"<w:instrText xml:space=\"preserve\">";
sResult += str;
sResult += L"</w:instrText></w:r>";
// разделитель
sResult += L"<w:r>";
sResult += L"<w:fldChar w:fldCharType=\"separate\"/></w:r>";
//пишем содержание-кэш
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += m_pResult->m_pTextItems->RenderToOOX(oNewParametr);
sResult += L"</w:r>";
//заканчиваем Field
sResult += L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
if (bDelete) sResult += L"</w:del>";
if (bInsert) sResult += L"</w:ins>";
}
return sResult;
}
......@@ -31,8 +31,6 @@
*/
#pragma once
#include "RtfParagraph.h"
#include "Writer/OOXWriter.h"
#include "Writer/OOXRelsWriter.h"
class OOXFieldBegin : public IDocumentElement
{
......@@ -56,39 +54,8 @@ public:
m_oCharProperty.SetDefault();
}
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult += L"{\\field ";
RENDER_RTF_BOOL( m_bDirty, sResult, L"flddirty" )
RENDER_RTF_BOOL( m_bLock, sResult, L"fldlock" )
sResult += L"{\\*\\fldinst";
sResult += m_oCharProperty.RenderToRtf(oRenderParameter);
return sResult;
}
CString RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
sResult += L"<w:r>";
CString props = m_oCharProperty.RenderToOOX(oRenderParameter);
if (props.IsEmpty())
{
sResult += L"<w:rPr>";
sResult += props;
sResult += L"</w:rPr>";
}
sResult += L"<w:fldChar w:fldCharType=\"separate\"";
RENDER_OOX_INT_ATTRIBUTE( m_bDirty, sResult, L"dirty" )
RENDER_OOX_INT_ATTRIBUTE( m_bLock, sResult, L"fldLock" )
sResult += L"/>";
sResult += L"</w:r>";
return sResult;
}
CString RenderToRtf(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
};
class OOXFieldInsertText : public IDocumentElement
{
......@@ -106,26 +73,7 @@ public:
else
return L"";
}
CString RenderToOOX(RenderParameter oRenderParameter)
{
if( NULL != m_oText )
{
CString sResult;
sResult += L"<w:r>";
sResult += L"<w:instrText>";
oRenderParameter.nType = RENDER_TO_RTF_PARAM_CHAR;
oRenderParameter.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
sResult += m_oText->RenderToOOX( oRenderParameter );
sResult += L"</w:instrText>";
sResult += L"</w:r>";
return sResult;
}
else
return L"";
}
CString RenderToOOX(RenderParameter oRenderParameter);
};
class OOXFieldSeparate : public IDocumentElement
......@@ -165,6 +113,32 @@ public:
};
class RtfFieldInst : public IDocumentElement
{
public:
void SetDefaultRtf()
{
SetDefault();
}
void SetDefaultOOX()
{
SetDefault();
}
void SetDefault()
{
m_pTextItems = TextItemContainerPtr( new TextItemContainer() );
}
CString RenderToRtf(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
RtfCharProperty m_oCharProperty;
TextItemContainerPtr m_pTextItems;
};
typedef boost::shared_ptr<RtfFieldInst> RtfFieldInstPtr;
class RtfField : public IDocumentElement
{
public:
......@@ -178,10 +152,12 @@ public:
};
_FieldMode m_eMode;
TextItemContainerPtr m_oInsert;
bool m_bReferenceToEndnote;
CString m_sData;
TextItemContainerPtr m_oResult;
RtfFieldInstPtr m_pInsert;
RtfFieldInstPtr m_pResult;
bool m_bTextOnly;
RtfCharProperty m_oCharProperty;
......@@ -215,190 +191,16 @@ public:
m_bTextOnly = false;
m_sData = L"";
m_oInsert = TextItemContainerPtr( new TextItemContainer() );
m_oResult = TextItemContainerPtr( new TextItemContainer() );
m_oCharProperty.SetDefault();
}
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
sResult += L"{\\field ";
if( fm_none != m_eMode )
{
switch( m_eMode )
{
case fm_flddirty: sResult += L"{\\flddirty "; break;
case fm_fldedit: sResult += L"{\\fldedit "; break;
case fm_fldlock: sResult += L"{\\fldlock "; break;
case fm_fldpriv: sResult += L"{\\fldpriv "; break;
}
}
sResult += L"{\\*\\fldinst ";
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_RTF_PARAM_PLAIN;//RENDER_TO_RTF_PARAM_CHAR;
oNewParam.nValue = RENDER_TO_RTF_PARAM_NO_PAR;
sResult += m_oInsert->RenderToRtf( oNewParam );
if( true == m_bReferenceToEndnote )
sResult += L"\\fldalt";
if( !m_sData.IsEmpty() )
sResult += L"{\\*\\datafield " + m_sData + L"}";
m_pResult = RtfFieldInstPtr(new RtfFieldInst());
m_pInsert = RtfFieldInstPtr(new RtfFieldInst());
sResult += L"}";
CString str = m_oResult->RenderToRtf( oRenderParameter ) ;
sResult += L"{\\fldrslt " + str + L"}";
sResult += L"}";
return sResult;
m_oCharProperty.SetDefault();
}
CString RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
CString sResult;
if( true == m_bTextOnly )
{
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_oResult->RenderToOOX(oNewParam);
}
else
{
bool bInsert = false;
bool bDelete = false;
if (m_oCharProperty.m_nRevised != PROP_DEF)
{
bInsert = true;
CString sAuthor = m_oCharProperty.m_nRevauth != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oCharProperty.m_nRevauth] : L"";
CString sDate(RtfUtility::convertDateTime(m_oCharProperty.m_nRevdttm).c_str());
sResult += L"<w:ins w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oCharProperty.m_nRevised = PROP_DEF;
}
if (m_oCharProperty.m_nDeleted != PROP_DEF)
{
bDelete = true;
CString sAuthor = m_oCharProperty.m_nRevauthDel != PROP_DEF ? poRtfDocument->m_oRevisionTable[ m_oCharProperty.m_nRevauthDel ] : L"";
CString sDate(RtfUtility::convertDateTime(m_oCharProperty.m_nRevdttmDel).c_str());
sResult += L"<w:del w:date=\"" + sDate + L"\" w:author=\"" + sAuthor + L"\" w:id=\"" + std::to_wstring(poOOXWriter->m_nCurTrackChangesId++).c_str() + L"\">";
m_oCharProperty.m_nDeleted = PROP_DEF;
}
//поверяем на наличие гиперссылки
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_PLAIN;
CString sInsertText = m_oInsert->RenderToOOX( oNewParam );
int nIndex = sInsertText.Find( L"HYPERLINK" );
if( -1 != nIndex )
{
CString sHyperlink = sInsertText;
sHyperlink.Delete( nIndex, 9/*(int)_tcslen( L"HYPERLINK" )*/ );
int nSplash = sHyperlink.Find( L"\\" );
if (nSplash > 0)
{
sHyperlink = sHyperlink.Left(nSplash);
}
//оставляем только одну ссылку
sHyperlink.Remove( '\"' );
sHyperlink.Trim();
//заменяем пробелы на %20
sHyperlink.Replace( L" ", L"%20" );
//добавляем в rels
OOXRelsWriter* poRelsWriter = static_cast<OOXRelsWriter*>( oRenderParameter.poRels );
CString sId = poRelsWriter->AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", Utils::PrepareToXML( sHyperlink ), false );
//добавляем гиперссылку в документ
sResult += L"<w:hyperlink r:id=\"" + sId + L"\" >";
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_oResult->RenderToOOX(oNewParam);
sResult += L"</w:hyperlink>";
}
else
{
nIndex = sInsertText.Find( L"PRIVATE" );
if( m_oResult->GetCount() <= 1 && nIndex < 0)
{
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
//sResult += L"<w:r>");
CString str = Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) ).Trim();
sResult += L"<w:fldSimple w:instr=\"";
sResult += str;
sResult += L"\">";
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
sResult += m_oResult->RenderToOOX(oNewParam);
sResult.AppendFormat(L"</w:fldSimple>");
//sResult += L"</w:r>");
}
else
{
//так добавляются лишние параграфы
RenderParameter oNewParametr = oRenderParameter;
oNewParametr.nType = RENDER_TO_OOX_PARAM_PLAIN;
CString props = m_oCharProperty.RenderToOOX(oRenderParameter);
if (!props.IsEmpty()) props = L"<w:rPr>" + props + L"</w:rPr>";
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += L"<w:fldChar w:fldCharType=\"begin\"/>";
sResult += L"</w:r>";
CString str = Utils::PrepareToXML( m_oInsert->RenderToOOX(oNewParametr) );
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += L"<w:instrText xml:space=\"preserve\">";
sResult += str;
sResult += L"</w:instrText></w:r>";
sResult += L"<w:r>";
if (!props.IsEmpty())
sResult += props;
sResult += L"<w:fldChar w:fldCharType=\"separate\"/></w:r>";
//заканчиваем этот параграф
sResult += L"</w:p>";
//пишем параграфы содержания
oNewParametr.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
sResult += m_oResult->RenderToOOX(oNewParametr);
//заканчиваем Field
sResult += L"<w:p>";
sResult += L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
}
if (bDelete)sResult += L"</w:del>";
if (bInsert)sResult += L"</w:ins>";
}
return sResult;
}
CString RenderToRtf(RenderParameter oRenderParameter);
CString RenderToOOX(RenderParameter oRenderParameter);
};
typedef boost::shared_ptr<RtfField> RtfFieldPtr;
typedef boost::shared_ptr<OOXFieldBegin> OOXFieldBeginPtr;
typedef boost::shared_ptr<OOXFieldInsertText> OOXFieldInsertTextPtr;
......
......@@ -435,35 +435,42 @@ public:
class RtfRevisionTable : public IDocumentElement, public ItemContainer<CString>
{
public:
ItemContainer<CString> m_aAuthorsList;
CString RenderToRtf(RenderParameter oRenderParameter)
{
if (m_aArray.empty()) return L"";
CString sResult;
if( m_aArray.size() > 0 )
{
sResult += _T("{\\*\\revtbl ");
for( int i = 0; i < (int)m_aArray.size(); i++)
{
sResult += _T("{");
sResult += m_aAuthorsList[i];
sResult += _T("}");
}
sResult += _T("{\\*\\revtbl ");
sResult += L"{Unknown;}";
for( int i = 0; i < (int)m_aArray.size(); i++)
{
sResult += _T("{");
sResult += m_aArray[i] + L";";
sResult += _T("}");
}
}
sResult += _T("}");
return sResult;
}
CString RenderToOOX(RenderParameter oRenderParameter)
{
return L"";
}
int AddAuthor(CString author)
{
int i = Find(author);
if (i < 0)
i = AddItem(author);
return i;
}
};
//class RtfRSIDTable : public IDocumentElement, public ItemContainer<rsidString>
//{
//public:
// ItemContainer<CString> m_aAuthorsList;
//
// CString RenderToRtf(RenderParameter oRenderParameter)
// {
......@@ -475,7 +482,7 @@ public:
// for( int i = 0; i < (int)m_aArray.size(); i++)
// {
// sResult += _T("{");
// sResult += m_aAuthorsList[i];
// sResult += m_aArray[i];
// sResult += _T("}");
// }
// sResult += _T("}");
......
......@@ -630,13 +630,13 @@ CString RtfBorder::RenderToOOX(RenderParameter oRenderParameter)
CString RtfCharProperty::RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
RENDER_RTF_INT( m_nAnimated, sResult, L"animtext" )
RENDER_RTF_BOOL( m_bBold, sResult, L"b" )
RENDER_RTF_BOOL( m_bCaps, sResult, L"caps" )
RENDER_RTF_INT( m_nScalex, sResult, L"charscalex" )
RENDER_RTF_INT( m_nAnimated, sResult, L"animtext" )
RENDER_RTF_BOOL( m_bBold, sResult, L"b" )
RENDER_RTF_BOOL( m_bCaps, sResult, L"caps" )
RENDER_RTF_INT( m_nScalex, sResult, L"charscalex" )
//RENDER_RTF_INT( m_nCharStyle, sResult, L"cs" )
RENDER_RTF_INT( m_nDown, sResult, L"dn" )
RENDER_RTF_BOOL( m_bEmbo, sResult, L"embo" )
RENDER_RTF_INT( m_nDown, sResult, L"dn" )
RENDER_RTF_BOOL( m_bEmbo, sResult, L"embo" )
RENDER_RTF_INT( m_nCharacterSpacing, sResult, L"expndtw" )
if( PROP_DEF != m_nCharacterSpacing )
sResult.AppendFormat( L"\\expnd%d", m_nCharacterSpacing / 5 );
......@@ -645,10 +645,10 @@ CString RtfCharProperty::RenderToRtf(RenderParameter oRenderParameter)
RENDER_RTF_INT( m_nFont, sResult, L"f" )
//RENDER_RTF_INT( m_nFont2, sResult, L"fittext" )
//RENDER_RTF_INT( m_nFont3, sResult, L"fittext" )
RENDER_RTF_INT( m_nFontSize, sResult, L"fs" )
RENDER_RTF_BOOL( m_bItalic, sResult, L"i" )
RENDER_RTF_BOOL( m_bImprint, sResult, L"impr" )
RENDER_RTF_INT( m_nKerning, sResult, L"kerning" )
RENDER_RTF_INT( m_nFontSize, sResult, L"fs" )
RENDER_RTF_BOOL( m_bItalic, sResult, L"i" )
RENDER_RTF_BOOL( m_bImprint, sResult, L"impr" )
RENDER_RTF_INT( m_nKerning, sResult, L"kerning" )
if (m_bRightToLeft != PROP_DEF )
{
......@@ -702,6 +702,24 @@ CString RtfCharProperty::RenderToRtf(RenderParameter oRenderParameter)
if( m_poShading.IsValid() == true )
sResult += m_poShading.RenderToRtf( oRenderParameter );
RENDER_RTF_INT( m_nCrAuth, sResult, L"crauth" )
RENDER_RTF_INT( m_nCrDate, sResult, L"crdate" )
if ( m_nRevised != PROP_DEF) sResult += L"\\revised";
RENDER_RTF_INT( m_nRevauth, sResult, L"revauth" )
RENDER_RTF_INT( m_nRevdttm, sResult, L"revdttm" )
if ( m_nDeleted != PROP_DEF) sResult += L"\\deleted";
RENDER_RTF_INT( m_nRevauthDel, sResult, L"revauthdel" )
RENDER_RTF_INT( m_nRevdttmDel, sResult, L"revdttmdel" )
if (m_pOldCharProp)
{
sResult += "{\\*\\oldcprops";
sResult += m_pOldCharProp->RenderToRtf(oRenderParameter);
sResult += L"}";
}
return sResult;
}
......@@ -1891,10 +1909,10 @@ CString RtfParagraphProperty::RenderToRtf(RenderParameter oRenderParameter)
RtfDocument* poRtfDocument = static_cast<RtfDocument*>( oRenderParameter.poDocument );
RtfListOverrideProperty oListOverrideProperty;
//ищем по override table
if( true == poRtfDocument->m_oListOverrideTabel.GetList( m_nListId, oListOverrideProperty ) )
if( true == poRtfDocument->m_oListOverrideTable.GetList( m_nListId, oListOverrideProperty ) )
{
//Ищем по List Table
if( true == poRtfDocument->m_oListTabel.GetList( oListOverrideProperty.m_nListID, oListProperty) )
if( true == poRtfDocument->m_oListTable.GetList( oListOverrideProperty.m_nListID, oListProperty) )
{
//дописываем свойства параграфа firstIndent Indent
RtfListLevelProperty poLevelProp ;
......@@ -1911,8 +1929,8 @@ CString RtfParagraphProperty::RenderToRtf(RenderParameter oRenderParameter)
{
int nIndex = poLevelProp.m_nPictureIndex;
if( 0 < nIndex && nIndex < poRtfDocument->m_oListTabel.m_aPictureList.GetCount() )
sResult += poRtfDocument->m_oListTabel.m_aPictureList[nIndex]->RenderToRtf( oRenderParameter );
if( 0 < nIndex && nIndex < poRtfDocument->m_oListTable.m_aPictureList.GetCount() )
sResult += poRtfDocument->m_oListTable.m_aPictureList[nIndex]->RenderToRtf( oRenderParameter );
}
//ставим tab
if( PROP_DEF != poLevelProp.m_nFollow )
......@@ -1930,6 +1948,16 @@ CString RtfParagraphProperty::RenderToRtf(RenderParameter oRenderParameter)
}
}
}
RENDER_RTF_INT( m_nPrAuth, sResult, L"prauth" )
RENDER_RTF_INT( m_nPrDate, sResult, L"prdate" )
if (m_pOldParagraphProp)
{
sResult += "{\\*\\oldpprops\\pard";
sResult += m_pOldParagraphProp->RenderToRtf(oRenderParameter);
sResult += L"}";
}
return sResult;
}
CString RtfParagraphProperty::RenderToOOX(RenderParameter oRenderParameter)
......
......@@ -292,9 +292,10 @@ CString RtfWriter::CreateRtfStart()
sResult += _T("{\\*\\defpap ") + sDefParProp+ _T("}");
sResult += m_oDocument.m_oStyleTable.RenderToRtf( oRenderParameter );
//---------- test
sResult += m_oDocument.m_oListTabel.RenderToRtf( oRenderParameter );
sResult += m_oDocument.m_oListOverrideTabel.RenderToRtf( oRenderParameter );
sResult += m_oDocument.m_oInformation.RenderToRtf( oRenderParameter );
sResult += m_oDocument.m_oListTable.RenderToRtf ( oRenderParameter );
sResult += m_oDocument.m_oListOverrideTable.RenderToRtf ( oRenderParameter );
sResult += m_oDocument.m_oRevisionTable.RenderToRtf ( oRenderParameter );
sResult += m_oDocument.m_oInformation.RenderToRtf ( oRenderParameter );
sResult += _T("\\fet2");//0 Footnotes only or nothing at all (the default). 1 Endnotes only. 2 Both footnotes and endnotes
CString sFootnote;
......
......@@ -45,6 +45,8 @@
#include "iconv.h"
#endif
#include <boost/date_time.hpp>
#define BUF_SIZE 2048
#define ONE_INCH 2.54
......@@ -60,7 +62,8 @@
#define CP_SYMBOL 42
#endif
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
#define SETBITS(to , numL, numH, val) {to &= ~(((1 << (numH - numL + 1)) - 1) << numL); to |= ((val & ((1 << (numH - numL + 1)) - 1)) << numL);}
namespace Strings
{
......@@ -387,7 +390,7 @@ public:
short Month = GETBITS(dt, 16, 19);
int Year = GETBITS(dt, 20, 28) + 1900;
//to 1899-12-31T05:37:46.66569
//to 1899-12-31T05:37:46.66569 - iso_extended_string
std::wstring date_str = std::to_wstring(Year)
+ L"-"
+ (Month < 10 ? L"0": L"") + std::to_wstring(Month)
......@@ -401,6 +404,35 @@ public:
return date_str;
}
static int convertDateTime (std::wstring & dt_)
{
if ( dt_.empty() ) return PROP_DEF;
std::string dt(dt_.begin(), dt_.end());
boost::posix_time::ptime date_time_;
boost::posix_time::time_input_facet *tif = new boost::posix_time::time_input_facet;
tif->set_iso_extended_format();
std::istringstream strm(dt);
strm.imbue(std::locale(std::locale::classic(), tif));
strm >> date_time_;
short Min = date_time_.time_of_day().minutes();
short Hour = date_time_.time_of_day().hours();
short Day = date_time_.date().day();
short Month = date_time_.date().month().as_number();
int Year = date_time_.date().year() - 1900;
int result = 0;
SETBITS(result, 0 , 5, Min);
SETBITS(result, 6 , 10, Hour);
SETBITS(result, 11, 15, Day);
SETBITS(result, 16, 19, Month);
SETBITS(result, 20, 28, Year);
return result;
}
//------------------------------------------------------------------------------------------------------
class RtfInternalEncoder
{
......
......@@ -128,8 +128,8 @@ CString OOXDocumentWriter::CreateXmlEnd( )
oNewParam.poRels = poNumberingWriter->m_oRelsWriter.get();
oNewParam.nType = RENDER_TO_OOX_PARAM_NUMBERING;
poNumberingWriter->AddNumbering( m_oDocument.m_oListTabel.RenderToOOX(oNewParam) );
poNumberingWriter->AddNumbering( m_oDocument.m_oListOverrideTabel.RenderToOOX(oNewParam) );
poNumberingWriter->AddNumbering( m_oDocument.m_oListTable.RenderToOOX(oNewParam) );
poNumberingWriter->AddNumbering( m_oDocument.m_oListOverrideTable.RenderToOOX(oNewParam) );
//style.xml
OOXStylesWriter* poStylesWriter = static_cast<OOXStylesWriter*>( m_oWriter.m_poStylesWriter );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment