Compare commits

..

1 Commits

Author SHA1 Message Date
9b5f052c97 OdfFormatWriter - fix after testing 2018-10-11 17:57:45 +03:00
10 changed files with 76 additions and 24 deletions

View File

@ -465,6 +465,10 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
//SUBTOTAL(109,Expense31[Amount])
XmlUtils::replace_all( res, L"[", L"KVADRATIN");
XmlUtils::replace_all( res, L"]", L"KVADRATOUT");
if (res1 == res)
{
XmlUtils::replace_all( res1, L"KAVYCHKA", L"\""); //IMCONJUGATE_emb.xlsx

View File

@ -230,10 +230,11 @@ std::wstring odf_chart_context::Impl::convert_formula(std::wstring oox_formula)
else
{
//open office dont support defined names in chart formula
// 7501214.xlsx - частичное заполнение local-table
int col = -1, row = -1;
utils::parsing_ref( refs[0], col, row);
if (col < 0 && row < 0)
if (col < 0 && row < 0 && (odf_context_->type != SpreadsheetDocument))
{
local_table_enabled_ = true;
//find defined name ????
@ -1587,7 +1588,9 @@ void odf_chart_context::set_cash(std::wstring format, std::vector<std::wstring>
int col1 = -1, col2 = -1, row1 = -1, row2 = -1;
if (refs.size() < 1) return;
if (refs.size() < 1) return;
if (refs[0].empty()) return;
utils::parsing_ref( refs[0], col1, row1);
if (refs.size() > 1)
@ -1694,7 +1697,7 @@ int odf_chart_context::Impl::create_local_table_rows(int curr_row, ods_table_sta
add = false;
if (cells[i].row > curr_row + 1 && !header)
if (cells[i].row > curr_row + 1/* && !header*/)
{
office_element_ptr row_elm;

View File

@ -346,7 +346,7 @@ void odf_drawing_context::set_background_state(bool Val)
void odf_drawing_context::check_anchor()
{
return;
if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) && (impl_->anchor_settings_.run_through_) && (impl_->anchor_settings_.run_through_->get_type() == run_through::Background))
if ((/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_) && (impl_->anchor_settings_.run_through_) && (impl_->anchor_settings_.run_through_->get_type() == run_through::Background))
{
set_anchor(anchor_type::Char);
//подозрительно на подложку страницы
@ -1317,7 +1317,7 @@ void odf_drawing_context::set_no_fill()
switch(impl_->current_drawing_part_)
{
case Area:
if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) &&
if ((/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap))
{
@ -1367,7 +1367,7 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
//impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); - default transparent
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) &&
if ((/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_) &&
(impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap))
{
@ -2391,7 +2391,7 @@ void odf_drawing_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(d
//------------------------------------------------------------------------------------------------------------------
void odf_drawing_context::start_image(std::wstring odf_path)
{
if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_)
if (/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_)//AstraIntlCaseStudyFinal0.docx
{
start_shape(142/*SimpleTypes::shapetypeRect*/);
start_bitmap_style();
@ -2514,7 +2514,10 @@ void odf_drawing_context::set_text_box_min_size(bool val)
if (impl_->current_graphic_properties)
{
impl_->current_graphic_properties->draw_auto_grow_height_ = true;
impl_->current_graphic_properties->draw_auto_grow_width_ = true;
//impl_->current_graphic_properties->draw_auto_grow_width_ = true; //Example_2.xlsx
impl_->current_graphic_properties->draw_fit_to_size_ = false;
impl_->current_graphic_properties->style_shrink_to_fit_ = false;
}
if (impl_->current_drawing_state_.elements_.empty()) return;
@ -2675,7 +2678,7 @@ void odf_drawing_context::set_text_box_parent_style(std::wstring style_name)
void odf_drawing_context::end_image()
{
if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_)
if (/*impl_->is_footer_ || impl_->is_header_ ||*/ impl_->is_background_)
{
end_bitmap_style();
end_shape();

View File

@ -80,11 +80,20 @@ std::wstring convert_date(const std::wstring & oox_date)
boost::gregorian::date date_ = boost::gregorian::date(1900, 1, 1) + boost::gregorian::date_duration(iDate-2);
////to for example, "1899-12-31T05:37:46.66569
std::wstring date_str = boost::lexical_cast<std::wstring>(date_.year())
std::wstring date_str;
try
{
date_str = boost::lexical_cast<std::wstring>(date_.year())
+ L"-" +
(date_.month() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.month().as_number())
+ L"-" +
(date_.day() < 10 ? L"0": L"") + boost::lexical_cast<std::wstring>(date_.day());
}
catch(...)
{
date_str = oox_date;
}
return date_str;
}
@ -471,21 +480,21 @@ void ods_table_state::set_row_default_cell_style(std::wstring & style_name)
office_element_ptr & ods_table_state::current_row_element()
{
if (rows_.size()>0)
if (false == rows_.empty())
return rows_.back().elm;
else
throw;
}
office_element_ptr & ods_table_state::current_cell_element()
{
if (cells_size_ >0)
if (cells_size_ > 0)
return cells_.back().elm;
else
throw;
}
ods_hyperlink_state & ods_table_state::current_hyperlink()
{
if ((cells_size_ >0 && hyperlinks_.size()>0) && (cells_.back().hyperlink_idx>=0) )
if ((cells_size_ >0 && !hyperlinks_.empty()) && (cells_.back().hyperlink_idx >= 0) )
{
return hyperlinks_[cells_.back().hyperlink_idx];
}

View File

@ -658,6 +658,7 @@ std::map<std::wstring, std::wstring> odt_conversion_context::parse_instr_options
void odt_conversion_context::add_field_instr(const std::wstring &instr)
{
if (current_fields.empty()) return;
current_fields.back().instrText += instr;
}
void odt_conversion_context::set_field_instr()
@ -824,7 +825,7 @@ void odt_conversion_context::set_field_instr()
}
void odt_conversion_context::start_field(bool in_span)
{
if (false == current_fields.empty() && current_fields.back().status == 0)
if (false == current_fields.empty() && current_fields.back().status == 0 && current_fields.back().instrText.empty() )
return; //start_field из sdt
_field_state field;

View File

@ -125,6 +125,7 @@ void graphic_format_properties::serialize(std::wostream & _Wostream ,const wchar
CP_XML_ATTR_OPT(L"draw:fit-to-size", draw_fit_to_size_);
CP_XML_ATTR_OPT(L"draw:fit-to-contour", draw_fit_to_contour_);
CP_XML_ATTR_OPT(L"draw:ole-draw-aspect", draw_ole_draw_aspect_);
CP_XML_ATTR_OPT(L"style:shrink-to-fit", style_shrink_to_fit_);
CP_XML_ATTR_OPT(L"draw:stroke", draw_stroke_);
CP_XML_ATTR_OPT(L"draw:stroke-dash", draw_stroke_dash_);

View File

@ -93,6 +93,7 @@ public:
_CP_OPT(odf_types::Bool) draw_auto_grow_height_;
_CP_OPT(odf_types::Bool) draw_auto_grow_width_;
_CP_OPT(odf_types::Bool) style_shrink_to_fit_;
_CP_OPT(odf_types::Bool) draw_fit_to_size_;
_CP_OPT(odf_types::Bool) draw_fit_to_contour_;
_CP_OPT(std::wstring) draw_wrap_influence_on_position_;

View File

@ -483,9 +483,17 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill)
odf_context()->drawing_context()->set_gradient_start(*sRgbColor1, no_set);
if (sRgbColor2)
odf_context()->drawing_context()->set_gradient_end(*sRgbColor2, no_set);
else
odf_context()->drawing_context()->set_gradient_end(L"#ffffff", no_set);
if (vml_fill->m_oAngle.IsInit())
{
odf_context()->drawing_context()->set_gradient_angle(vml_fill->m_oAngle->GetValue() + 90);
}
if (vml_fill->m_oFocusPosition.IsInit())
{
odf_context()->drawing_context()->set_gradient_center(vml_fill->m_oFocusPosition->GetX(), vml_fill->m_oFocusPosition->GetY());
}
odf_context()->drawing_context()->end_gradient_style();
}break;

View File

@ -1205,7 +1205,8 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_NumDataSource* val)
}
else if (val->m_numRef)
{
if (val->m_numRef->m_f)odf_context()->chart_context()->set_series_value_formula(*val->m_numRef->m_f);
if (val->m_numRef->m_f)
odf_context()->chart_context()->set_series_value_formula(*val->m_numRef->m_f);
convert(val->m_numRef->m_numCache, false, false);
}

View File

@ -1115,10 +1115,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
std::wstring ref(selection->m_oActiveCell.get());
odf_writer::utils::parsing_ref (ref, ActiveCellX, ActiveCellY);
if (ActiveCellX >= 0 && ActiveCellY >= 0)
if (ActiveCellX > 0 && ActiveCellY > 0)
{
ods_context->settings_context()->add_property(L"CursorPositionX", L"int", std::to_wstring(ActiveCellX));
ods_context->settings_context()->add_property(L"CursorPositionY", L"int", std::to_wstring(ActiveCellY));
ods_context->settings_context()->add_property(L"CursorPositionX", L"int", std::to_wstring(ActiveCellX - 1));
ods_context->settings_context()->add_property(L"CursorPositionY", L"int", std::to_wstring(ActiveCellY - 1));
}
}
if (selection->m_oSqref.IsInit())
@ -1983,16 +1983,37 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor)
if (!oox_anchor) return;
//////////////////
if (oox_anchor->m_oFrom.IsInit() || oox_anchor->m_oTo.IsInit())
if (oox_anchor->m_oFrom.IsInit() || oox_anchor->m_oTo.IsInit() ||
oox_anchor->m_oPos.IsInit() || oox_anchor->m_oExt.IsInit())
{
oox_table_position from={}, to={};
convert(oox_anchor->m_oFrom.GetPointer(), &from);
convert(oox_anchor->m_oTo.GetPointer(), &to);
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
double x1=0, y1=0, x2=0, y2=0;
ods_context->current_table().convert_position(from, x1, y1);
ods_context->current_table().convert_position(to, x2, y2);
if (oox_anchor->m_oFrom.IsInit())
{
convert(oox_anchor->m_oFrom.GetPointer(), &from);
ods_context->current_table().convert_position(from, x1, y1);
}
else if (oox_anchor->m_oPos.IsInit())
{
if (oox_anchor->m_oPos->m_oX.IsInit())
x1 = oox_anchor->m_oPos->m_oX->GetValue();
if (oox_anchor->m_oPos->m_oY.IsInit())
y1 = oox_anchor->m_oPos->m_oY->GetValue();
}
if (oox_anchor->m_oTo.IsInit())
{
convert(oox_anchor->m_oTo.GetPointer(), &to);
ods_context->current_table().convert_position(to, x2, y2);
}
else if (oox_anchor->m_oExt.IsInit())
{
if (oox_anchor->m_oExt->m_oCx.IsInit())
x2 = x1 + oox_anchor->m_oExt->m_oCx->GetValue();
if (oox_anchor->m_oExt->m_oCy.IsInit())
y2 = y1 + oox_anchor->m_oExt->m_oCy->GetValue();
}
ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1);
}