Commit 82b3dbda authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - fix users files

parent 4d134387
...@@ -133,7 +133,8 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri ...@@ -133,7 +133,8 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_drawing_context_ (Context->get_drawing_context_handle()), xlsx_drawing_context_ (Context->get_drawing_context_handle()),
xlsx_comments_context_ (Context->get_comments_context_handle()), xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0), table_column_last_width_(0.0),
in_cell(false) in_cell(false),
bEndTable(false)
{ {
memset(&group_row_,0,sizeof(_group_row)); memset(&group_row_,0,sizeof(_group_row));
......
...@@ -91,6 +91,9 @@ public: ...@@ -91,6 +91,9 @@ public:
void end_row (); void end_row ();
void add_empty_row(int count); void add_empty_row(int count);
void set_end_table(){ bEndTable = true; }
bool get_end_table(){ return bEndTable; }
std::wstring current_row_style () const; std::wstring current_row_style () const;
std::wstring default_row_cell_style () const; std::wstring default_row_cell_style () const;
...@@ -153,6 +156,7 @@ public: ...@@ -153,6 +156,7 @@ public:
friend class xlsx_table_context; friend class xlsx_table_context;
private: private:
bool bEndTable;
xlsx_conversion_context * context_; xlsx_conversion_context * context_;
std::wstring tableName_; std::wstring tableName_;
......
...@@ -195,7 +195,14 @@ std::wstring cellType2Str(XlsxCellType::type type) ...@@ -195,7 +195,14 @@ std::wstring cellType2Str(XlsxCellType::type type)
boost::int64_t convertDate(int Year, int Month, int Day) boost::int64_t convertDate(int Year, int Month, int Day)
{ {
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1; if (Year < 1400 || Year >10000)
return - 1;
if (Month < 1 || Month > 12)
return - 1;
if (Day < 1 || Day > 31)
return - 1;
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1;
if (Year <= 1900 && if (Year <= 1900 &&
Month <= 2 && Month <= 2 &&
......
...@@ -78,13 +78,16 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex ...@@ -78,13 +78,16 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context) void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
bool bEndTable = Context.get_table_context().state()->get_end_table();
if (attlist_.table_number_rows_repeated_ > 1 && empty()) if (attlist_.table_number_rows_repeated_ > 1 && empty())
{ {
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_); Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
return; return;
} }
if (attlist_.table_number_rows_repeated_ > 0xf000 && empty_content_cells()) if (attlist_.table_number_rows_repeated_ > 0x0f00 && empty_content_cells() || bEndTable)//0xf000 - conv_KDZO3J3xLIbZ5fC0HR0__xlsx.ods
{ {
Context.get_table_context().state()->set_end_table();
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_); Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
return; //conv_hSX8n3lVbhALjt0aafg__xlsx.ods, conv_MA2CauoNfX_7ejKS5eg__xlsx.ods return; //conv_hSX8n3lVbhALjt0aafg__xlsx.ods, conv_MA2CauoNfX_7ejKS5eg__xlsx.ods
} }
...@@ -731,7 +734,15 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -731,7 +734,15 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
int y, m, d; int y, m, d;
if (oox::parseDate(attr.office_date_value_.get(), y, m, d)) if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
{ {
number_val = boost::lexical_cast<std::wstring>(oox::convertDate(y, m, d)); boost::int64_t intDate = oox::convertDate(y, m, d);
if (intDate > 0)
{
number_val = boost::lexical_cast<std::wstring>(intDate);
}
else
{
str_val = attr.office_date_value_.get();
}
} }
} }
} }
...@@ -742,11 +753,19 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -742,11 +753,19 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
if (attr.office_time_value_) if (attr.office_time_value_)
{ {
const std::wstring tv = attr.office_time_value_.get(); const std::wstring tv = attr.office_time_value_.get();
int h,m; int h, m;
double s; double s;
if (oox::parseTime(tv, h, m, s)) if (oox::parseTime(tv, h, m, s))
{ {
number_val = boost::lexical_cast<std::wstring>(oox::convertTime(h, m, s)); boost::int64_t intTime = oox::convertTime(h, m, s);
if (intTime > 0)
{
number_val = boost::lexical_cast<std::wstring>(intTime);
}
else
{
str_val = tv;
}
} }
} }
} }
...@@ -999,7 +1018,15 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte ...@@ -999,7 +1018,15 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
int y, m, d; int y, m, d;
if (oox::parseDate(attr.office_date_value_.get(), y, m, d)) if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
{ {
number_val = boost::lexical_cast<std::wstring>(oox::convertDate(y, m, d)); boost::int64_t intDate = oox::convertDate(y, m, d);
if (intDate > 0)
{
number_val = boost::lexical_cast<std::wstring>(intDate);
}
else
{
str_val = attr.office_date_value_.get();
}
} }
} }
} }
......
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