Commit 2550167a authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - fix bugs after auto-testing (charts, shapes ...)

parent 529f028e
...@@ -542,21 +542,24 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr) ...@@ -542,21 +542,24 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
std::wstring res1 = boost::regex_replace( std::wstring res1 = boost::regex_replace(
workstr, workstr,
boost::wregex(L"('.*?')|(\".*?\")"), boost::wregex(L"('.*?')|(\".*?\")"),
&oox2odf_converter::Impl::convert_scobci,boost::match_default | boost::format_all); &oox2odf_converter::Impl::convert_scobci, boost::match_default | boost::format_all);
std::wstring res = boost::regex_replace( std::wstring res = boost::regex_replace(
res1, res1,
boost::wregex(L"(?:(?=[()])(.*?)(?=[)]))"), boost::wregex(L"(?:(?=[()])(.*?)(?=[)]))"),
&oox2odf_converter::Impl::replace_arguments,boost::match_default | boost::format_all); &oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
if (res1 == res) if (res1 == res)
{ {
boost::algorithm::replace_all(res1, L"KAVYCHKA", L"\""); //IMCONJUGATE_emb.xlsx
res = boost::regex_replace( res = boost::regex_replace(
res1, res1,
boost::wregex(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?"), boost::wregex(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?"),
&replace_cells_range_formater1, &replace_cells_range_formater1,
boost::match_default | boost::format_all); boost::match_default | boost::format_all);
replace_vertical(res); replace_vertical(res);
replace_semicolons(res); replace_semicolons(res);
} }
......
...@@ -57,7 +57,7 @@ std::wstring DetectTypeDocument(const std::wstring & pathOOX) ...@@ -57,7 +57,7 @@ std::wstring DetectTypeDocument(const std::wstring & pathOOX)
if (file.OpenFile(fileContentType) != S_OK) return sRes; if (file.OpenFile(fileContentType) != S_OK) return sRes;
int nBufferSize = min (file.GetFileSize(), 4096); int nBufferSize = min (file.GetFileSize(), 10000);
BYTE *pBuffer = new BYTE[nBufferSize]; BYTE *pBuffer = new BYTE[nBufferSize];
file.ReadFile(pBuffer, nBufferSize); file.ReadFile(pBuffer, nBufferSize);
......
...@@ -57,7 +57,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy ...@@ -57,7 +57,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"mso-spt200" , 7}, // shapetypeActionButtonMovie, { L"mso-spt200" , 7}, // shapetypeActionButtonMovie,
{ L"mso-spt197" , 7}, // shapetypeActionButtonReturn, { L"mso-spt197" , 7}, // shapetypeActionButtonReturn,
{ L"mso-spt199" , 7}, // shapetypeActionButtonSound, { L"mso-spt199" , 7}, // shapetypeActionButtonSound,
{ L"" , 7}, // shapetypeArc, { L"ooxml-arc" , 7}, // shapetypeArc,
{ L"mso-spt91" , 7}, // shapetypeBentArrow, { L"mso-spt91" , 7}, // shapetypeBentArrow,
{ L"mso-spt33" , 7}, // shapetypeBentConnector2, { L"mso-spt33" , 7}, // shapetypeBentConnector2,
{ L"mso-spt34" , 7}, // shapetypeBentConnector3, { L"mso-spt34" , 7}, // shapetypeBentConnector3,
......
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
styles_context_ = NULL; styles_context_ = NULL;
current_series_count_= 0; current_series_count_= 0;
if (odf_context->type == SpreadsheetDocument) if (odf_context_->type == SpreadsheetDocument)
{ {
local_table_enabled_ = false; local_table_enabled_ = false;
} }
...@@ -208,7 +208,15 @@ void odf_chart_context::Impl::clear_current() ...@@ -208,7 +208,15 @@ void odf_chart_context::Impl::clear_current()
cash_.clear(); cash_.clear();
current_series_count_ = 0; current_series_count_ = 0;
local_table_enabled_ = true; //false; пока тока кэш - demo.docx
if (odf_context_->type == SpreadsheetDocument)
{
local_table_enabled_ = false;
}
else
{
local_table_enabled_ = true;
}
} }
void odf_chart_context::Impl::set_default_series_color() void odf_chart_context::Impl::set_default_series_color()
{ {
......
...@@ -473,17 +473,22 @@ void odf_drawing_context::end_drawing() ...@@ -473,17 +473,22 @@ void odf_drawing_context::end_drawing()
if (impl_->current_drawing_state_.svg_x_ && impl_->current_drawing_state_.svg_y_) if (impl_->current_drawing_state_.svg_x_ && impl_->current_drawing_state_.svg_y_)
{ {
odf_types::length pos_x = (impl_->current_drawing_state_.svg_x_->get_value() + odf_types::length pos_x = odf_types::length(impl_->current_drawing_state_.svg_x_->get_value() +
(impl_->current_drawing_state_.svg_width_ ? (impl_->current_drawing_state_.svg_width_->get_value()/2.) : 0.), impl_->current_drawing_state_.svg_x_->get_unit()); (impl_->current_drawing_state_.svg_width_ ? (impl_->current_drawing_state_.svg_width_->get_value()/2.) : 0.), impl_->current_drawing_state_.svg_x_->get_unit());
odf_types::length pos_y = (impl_->current_drawing_state_.svg_y_->get_value() +
odf_types::length pos_y = odf_types::length(impl_->current_drawing_state_.svg_y_->get_value() +
(impl_->current_drawing_state_.svg_height_ ? (impl_->current_drawing_state_.svg_height_->get_value()/2.) : 0.), impl_->current_drawing_state_.svg_y_->get_unit()); (impl_->current_drawing_state_.svg_height_ ? (impl_->current_drawing_state_.svg_height_->get_value()/2.) : 0.), impl_->current_drawing_state_.svg_y_->get_unit());
if (pos_x.get_unit() != odf_types::length::none && pos_y.get_unit() != odf_types::length::none)
{
strTransform += std::wstring(L" translate(") + boost::lexical_cast<std::wstring>(pos_x) strTransform += std::wstring(L" translate(") + boost::lexical_cast<std::wstring>(pos_x)
+ std::wstring(L",") + boost::lexical_cast<std::wstring>(pos_y) + std::wstring(L",") + boost::lexical_cast<std::wstring>(pos_y)
+ std::wstring(L")") ; + std::wstring(L")") ;
impl_->current_drawing_state_.svg_x_ = boost::none; impl_->current_drawing_state_.svg_x_ = boost::none;
impl_->current_drawing_state_.svg_y_ = boost::none; impl_->current_drawing_state_.svg_y_ = boost::none;
} }
}
} }
...@@ -1554,7 +1559,6 @@ void odf_drawing_context::get_size( double & width_pt, double & height_pt) ...@@ -1554,7 +1559,6 @@ void odf_drawing_context::get_size( double & width_pt, double & height_pt)
} }
void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt) void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt)
{ {
if (impl_->current_drawing_state_.in_group) if (impl_->current_drawing_state_.in_group)
{ {
if (width_pt) if (width_pt)
...@@ -1569,8 +1573,11 @@ void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) ...@@ -1569,8 +1573,11 @@ void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double)
} }
}else }else
{ {
if (!impl_->current_drawing_state_.svg_width_ && width_pt) impl_->current_drawing_state_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm),length::cm); if (!impl_->current_drawing_state_.svg_width_ && width_pt)
if (!impl_->current_drawing_state_.svg_height_ && height_pt) impl_->current_drawing_state_.svg_height_= length(length(*height_pt,length::pt).get_value_unit(length::cm),length::cm); impl_->current_drawing_state_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm),length::cm);
if (!impl_->current_drawing_state_.svg_height_ && height_pt)
impl_->current_drawing_state_.svg_height_= length(length(*height_pt,length::pt).get_value_unit(length::cm),length::cm);
} }
} }
void odf_drawing_context::set_line_width(double pt) void odf_drawing_context::set_line_width(double pt)
......
...@@ -825,7 +825,8 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x, ...@@ -825,7 +825,8 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x,
{ {
double sz_col=0; double sz_col=0;
int curr_col = 0,i; int curr_col = 0,i;
for (i=0; i< columns_.size(); i++)
for (i = 0; i < columns_.size(); i++)
{ {
if (oox_pos.col > columns_[i].repeated + curr_col) if (oox_pos.col > columns_[i].repeated + curr_col)
{ {
...@@ -834,16 +835,22 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x, ...@@ -834,16 +835,22 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x,
else else
{ {
sz_col += (oox_pos.col - curr_col ) * columns_[i].size; sz_col += (oox_pos.col - curr_col ) * columns_[i].size;
curr_col += (oox_pos.col - curr_col );
break; break;
} }
curr_col += columns_[i].repeated; curr_col += columns_[i].repeated;
} }
x= sz_col + oox_pos.col_off; if (curr_col < oox_pos.col && columns_.size() > 0)
{
sz_col += (oox_pos.col - curr_col) * columns_[columns_.size() - 1].size;
}
x = sz_col + oox_pos.col_off;
double sz_row=0; double sz_row=0;
int curr_row =0; int curr_row =0;
for (i=0; i< rows_.size(); i++) for (i = 0; i < rows_.size(); i++)
{ {
if (oox_pos.row > rows_[i].repeated + curr_row) if (oox_pos.row > rows_[i].repeated + curr_row)
{ {
...@@ -852,12 +859,19 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x, ...@@ -852,12 +859,19 @@ void ods_table_state::convert_position(oox_table_position & oox_pos, double & x,
else else
{ {
sz_row += (oox_pos.row - curr_row) * rows_[i].size; sz_row += (oox_pos.row - curr_row) * rows_[i].size;
curr_row += (oox_pos.row - curr_row);
break; break;
} }
curr_row += rows_[i].repeated; curr_row += rows_[i].repeated;
} }
y= sz_row + oox_pos.row_off; if (curr_row < oox_pos.row && rows_.size() > 0)
{
sz_row += (oox_pos.row - curr_row ) * rows_[rows_.size() - 1].size;
}
y = sz_row + oox_pos.row_off;
} }
......
...@@ -633,13 +633,19 @@ void OoxConverter::convert(OOX::Drawing::CLineProperties *oox_line_prop, CString ...@@ -633,13 +633,19 @@ void OoxConverter::convert(OOX::Drawing::CLineProperties *oox_line_prop, CString
} }
if (oox_line_prop->m_oHeadEnd.IsInit()) if (oox_line_prop->m_oHeadEnd.IsInit())
{ {
int type =0, w=1, len =1;//medium arrow if (oox_line_prop->m_oHeadEnd->m_oLen.IsInit() || oox_line_prop->m_oHeadEnd->m_oType.IsInit() || oox_line_prop->m_oHeadEnd->m_oW.IsInit())
{
int type = 0, w=1, len =1;//medium arrow
if (oox_line_prop->m_oHeadEnd->m_oLen.IsInit()) len = oox_line_prop->m_oHeadEnd->m_oLen->GetValue(); if (oox_line_prop->m_oHeadEnd->m_oLen.IsInit()) len = oox_line_prop->m_oHeadEnd->m_oLen->GetValue();
if (oox_line_prop->m_oHeadEnd->m_oType.IsInit()) type = oox_line_prop->m_oHeadEnd->m_oType->GetValue(); if (oox_line_prop->m_oHeadEnd->m_oType.IsInit()) type = oox_line_prop->m_oHeadEnd->m_oType->GetValue();
if (oox_line_prop->m_oHeadEnd->m_oW.IsInit()) w=oox_line_prop->m_oHeadEnd->m_oW->GetValue(); if (oox_line_prop->m_oHeadEnd->m_oW.IsInit()) w=oox_line_prop->m_oHeadEnd->m_oW->GetValue();
odf_context()->drawing_context()->set_line_head(type, len, w); odf_context()->drawing_context()->set_line_head(type, len, w);
} }
}
if (oox_line_prop->m_oTailEnd.IsInit()) if (oox_line_prop->m_oTailEnd.IsInit())
{
if (oox_line_prop->m_oTailEnd->m_oLen.IsInit() || oox_line_prop->m_oTailEnd->m_oType.IsInit() || oox_line_prop->m_oTailEnd->m_oW.IsInit())
{ {
int type =0, w=1, len =1;//medium arrow int type =0, w=1, len =1;//medium arrow
if (oox_line_prop->m_oTailEnd->m_oLen.IsInit()) len = oox_line_prop->m_oTailEnd->m_oLen->GetValue(); if (oox_line_prop->m_oTailEnd->m_oLen.IsInit()) len = oox_line_prop->m_oTailEnd->m_oLen->GetValue();
...@@ -647,7 +653,7 @@ void OoxConverter::convert(OOX::Drawing::CLineProperties *oox_line_prop, CString ...@@ -647,7 +653,7 @@ void OoxConverter::convert(OOX::Drawing::CLineProperties *oox_line_prop, CString
if (oox_line_prop->m_oTailEnd->m_oW.IsInit()) w = oox_line_prop->m_oTailEnd->m_oW->GetValue(); if (oox_line_prop->m_oTailEnd->m_oW.IsInit()) w = oox_line_prop->m_oTailEnd->m_oW->GetValue();
odf_context()->drawing_context()->set_line_tail(type, len, w); odf_context()->drawing_context()->set_line_tail(type, len, w);
}
} }
if (oox_line_prop->m_oCustDash.IsInit()) if (oox_line_prop->m_oCustDash.IsInit())
......
...@@ -817,14 +817,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorkbookView *oox_book_views) ...@@ -817,14 +817,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorkbookView *oox_book_views)
if (oox_book_views->m_oActiveTab.IsInit()) if (oox_book_views->m_oActiveTab.IsInit())
{ {
int table_id = oox_book_views->m_oActiveTab->GetValue() + 1; int table_id = oox_book_views->m_oActiveTab->GetValue();
for (int i = 0; i < Workbook->m_oSheets->m_arrItems.size(); i++) if (table_id >=0 && table_id < Workbook->m_oSheets->m_arrItems.size())
{ {
OOX::Spreadsheet::CSheet* pSheet = Workbook->m_oSheets->m_arrItems[i]; OOX::Spreadsheet::CSheet* pSheet = Workbook->m_oSheets->m_arrItems[table_id];
if (!pSheet) continue;
if (pSheet->m_oSheetId.IsInit() && pSheet->m_oSheetId->GetValue() == table_id) if (pSheet)
{ {
ods_context->settings_context()->add_property(L"ActiveTable", L"string", string2std_string(pSheet->m_oName.get2())); ods_context->settings_context()->add_property(L"ActiveTable", L"string", string2std_string(pSheet->m_oName.get2()));
} }
...@@ -901,17 +900,19 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views) ...@@ -901,17 +900,19 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
{ {
ods_context->settings_context()->add_property(L"GridColor", L"int", oox_sheet_views->m_arrItems[i]->m_oColorId->ToString().GetBuffer()); ods_context->settings_context()->add_property(L"GridColor", L"int", oox_sheet_views->m_arrItems[i]->m_oColorId->ToString().GetBuffer());
} }
bool bPaneX = false;
bool bPaneY = false;
int ActiveCellX = -1, ActiveCellY = -1;
if (oox_sheet_views->m_arrItems[i]->m_oSelection.IsInit()) if (oox_sheet_views->m_arrItems[i]->m_oSelection.IsInit())
{ {
if (oox_sheet_views->m_arrItems[i]->m_oSelection->m_oActiveCell.IsInit()) if (oox_sheet_views->m_arrItems[i]->m_oSelection->m_oActiveCell.IsInit())
{ {
int col = -1, row = -1; odf_writer::utils::parsing_ref (oox_sheet_views->m_arrItems[i]->m_oSelection->m_oActiveCell->GetBuffer(), ActiveCellX, ActiveCellY);
odf_writer::utils::parsing_ref (oox_sheet_views->m_arrItems[i]->m_oSelection->m_oActiveCell->GetBuffer(), col, row);
if (col >= 0 && row >= 0) if (ActiveCellX >= 0 && ActiveCellY >= 0)
{ {
ods_context->settings_context()->add_property(L"CursorPositionX", L"int", boost::lexical_cast<std::wstring>(col)); ods_context->settings_context()->add_property(L"CursorPositionX", L"int", boost::lexical_cast<std::wstring>(ActiveCellX));
ods_context->settings_context()->add_property(L"CursorPositionY", L"int", boost::lexical_cast<std::wstring>(row)); ods_context->settings_context()->add_property(L"CursorPositionY", L"int", boost::lexical_cast<std::wstring>(ActiveCellY));
} }
} }
if (oox_sheet_views->m_arrItems[i]->m_oSelection->m_oSqref.IsInit()) if (oox_sheet_views->m_arrItems[i]->m_oSelection->m_oSqref.IsInit())
...@@ -931,6 +932,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views) ...@@ -931,6 +932,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
ods_context->settings_context()->add_property(L"HorizontalSplitPosition", L"int", sVal); ods_context->settings_context()->add_property(L"HorizontalSplitPosition", L"int", sVal);
ods_context->settings_context()->add_property(L"PositionLeft", L"int", L"0"); ods_context->settings_context()->add_property(L"PositionLeft", L"int", L"0");
ods_context->settings_context()->add_property(L"PositionRight", L"int", sVal); ods_context->settings_context()->add_property(L"PositionRight", L"int", sVal);
bPaneX = true;
} }
if (oox_sheet_views->m_arrItems[i]->m_oPane->m_oYSplit.IsInit()) if (oox_sheet_views->m_arrItems[i]->m_oPane->m_oYSplit.IsInit())
{ {
...@@ -939,8 +941,23 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views) ...@@ -939,8 +941,23 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
ods_context->settings_context()->add_property(L"VerticalSplitPosition", L"int", sVal); ods_context->settings_context()->add_property(L"VerticalSplitPosition", L"int", sVal);
ods_context->settings_context()->add_property(L"PositionTop", L"int", L"0"); ods_context->settings_context()->add_property(L"PositionTop", L"int", L"0");
ods_context->settings_context()->add_property(L"PositionBottom", L"int", sVal); ods_context->settings_context()->add_property(L"PositionBottom", L"int", sVal);
bPaneY = true;
} }
} }
//if (!bPaneX && ActiveCellX >= 0)
//{
// ods_context->settings_context()->add_property(L"HorizontalSplitMode", L"short", L"0");
// ods_context->settings_context()->add_property(L"HorizontalSplitPosition", L"int", L"0");
// ods_context->settings_context()->add_property(L"PositionLeft", L"int", L"0");
// ods_context->settings_context()->add_property(L"PositionRight", L"int", boost::lexical_cast<std::wstring>(ActiveCellX));
//}
//if (!bPaneY && ActiveCellY >= 0)
//{
// ods_context->settings_context()->add_property(L"VerticalSplitMode", L"short", L"0");
// ods_context->settings_context()->add_property(L"VerticalSplitPosition", L"int", L"0");
// ods_context->settings_context()->add_property(L"PositionTop", L"int", L"0");
// ods_context->settings_context()->add_property(L"PositionBottom", L"int", boost::lexical_cast<std::wstring>(ActiveCellY));
//}
if (oox_sheet_views->m_arrItems[i]->m_oShowRowColHeaders.IsInit()) if (oox_sheet_views->m_arrItems[i]->m_oShowRowColHeaders.IsInit())
{ {
ods_context->settings_context()->add_property(L"HasColumnRowHeaders", L"boolean", oox_sheet_views->m_arrItems[i]->m_oShowRowColHeaders->ToBool() ? L"true" : L"false"); ods_context->settings_context()->add_property(L"HasColumnRowHeaders", L"boolean", oox_sheet_views->m_arrItems[i]->m_oShowRowColHeaders->ToBool() ? L"true" : L"false");
......
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