From 748f7d0a723ff9115c8d7f923e94779103ffdc08 Mon Sep 17 00:00:00 2001 From: Mikhail Lobotskiy Date: Fri, 18 Aug 2023 20:11:42 +0400 Subject: [PATCH 01/21] Removed default input handlers from vlc player --- Common/3dParty/libvlc/vlcplayer.cpp | 5 ++++- Common/3dParty/libvlc/vlcplayer.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/3dParty/libvlc/vlcplayer.cpp b/Common/3dParty/libvlc/vlcplayer.cpp index 935efbce06..b0a7c0d217 100644 --- a/Common/3dParty/libvlc/vlcplayer.cpp +++ b/Common/3dParty/libvlc/vlcplayer.cpp @@ -2,7 +2,7 @@ #include -CVlcPlayer::CVlcPlayer() +CVlcPlayer::CVlcPlayer(QWidget* parent) : QWidget(parent) { // initialize libVLC m_pVlcInstance = libvlc_new(0, NULL); @@ -14,6 +14,9 @@ CVlcPlayer::CVlcPlayer() } // initialize vlc media player m_pVlcPlayer = libvlc_media_player_new(m_pVlcInstance); + // disable event handling by vlc internals + libvlc_video_set_mouse_input(m_pVlcPlayer, false); + libvlc_video_set_key_input(m_pVlcPlayer, false); // get event manager m_pEventManager = libvlc_media_player_event_manager(m_pVlcPlayer); diff --git a/Common/3dParty/libvlc/vlcplayer.h b/Common/3dParty/libvlc/vlcplayer.h index bd33fd9c25..5bfa79741a 100644 --- a/Common/3dParty/libvlc/vlcplayer.h +++ b/Common/3dParty/libvlc/vlcplayer.h @@ -11,7 +11,7 @@ class CVlcPlayer : public QWidget Q_OBJECT public: - CVlcPlayer(); + CVlcPlayer(QWidget* parent = nullptr); virtual ~CVlcPlayer(); public: From 65ffbda3734e75f179ae51a3f09aab6a5d1be93f Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Mon, 21 Aug 2023 19:18:44 +0300 Subject: [PATCH 02/21] . --- OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp b/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp index c7abd56e77..4fd8c8a60c 100644 --- a/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp +++ b/OOXML/Binary/Sheets/Reader/ChartFromToBinary.cpp @@ -6646,15 +6646,15 @@ namespace BinXlsxRW pLegend->m_spPr->m_namespace = L"cx"; res = ReadCT_PptxElement(0, length, pLegend->m_spPr.GetPointer()); } - else if (c_oserct_chartExTitlePOS == type) + else if (c_oserct_chartExLegendPOS == type) { pLegend->m_pos = (SimpleTypes::Spreadsheet::ESidePos)m_oBufferedStream.GetUChar(); } - else if (c_oserct_chartExTitleALIGN == type) + else if (c_oserct_chartExLegendALIGN == type) { pLegend->m_align = (SimpleTypes::Spreadsheet::EPosAlign)m_oBufferedStream.GetUChar(); } - else if (c_oserct_chartExTitleOVERLAY == type) + else if (c_oserct_chartExLegendOVERLAY == type) { pLegend->m_overlay = m_oBufferedStream.GetBool(); } @@ -6877,7 +6877,7 @@ namespace BinXlsxRW pDataLabel->m_spPr->m_namespace = L"cx"; res = ReadCT_PptxElement(0, length, pDataLabel->m_spPr.GetPointer()); } - else if (c_oserct_chartExDataLabelsVISABILITIES == type) + else if (c_oserct_chartExDataLabelVISABILITIES == type) { pDataLabel->m_visibility.Init(); READ1_DEF(length, res, this->ReadCT_ChartExDataLabelVisibilities, pDataLabel->m_visibility.GetPointer()); @@ -6895,7 +6895,7 @@ namespace BinXlsxRW int res = c_oSerConstants::ReadOk; OOX::Spreadsheet::ChartEx::CDataLabelHidden *pDataLabelHidden = static_cast(poResult); - if (c_oserct_chartExDATA == type) + if (c_oserct_chartExDataLabelHiddenIDX == type) { pDataLabelHidden->m_idx = m_oBufferedStream.GetLong(); } @@ -7026,7 +7026,7 @@ namespace BinXlsxRW int res = c_oSerConstants::ReadOk; OOX::Spreadsheet::ChartEx::CStatistics *pStatistics = static_cast(poResult); - if (c_oserct_chartExDATA == type) + if (c_oserct_chartExStatisticsMETHOD == type) { pStatistics->m_quartileMethod = (SimpleTypes::Spreadsheet::EQuartileMethod)m_oBufferedStream.GetUChar(); } @@ -7132,7 +7132,7 @@ namespace BinXlsxRW pAxis->m_majorGridlines->m_name = L"cx:majorGridlines"; READ1_DEF(length, res, this->ReadCT_ChartExGridlines, pAxis->m_majorGridlines.GetPointer()); } - else if (c_oserct_chartExAxisMAJORGRID == type) + else if (c_oserct_chartExAxisMINORGRID == type) { pAxis->m_minorGridlines.Init(); pAxis->m_minorGridlines->m_name = L"cx:minorGridlines"; @@ -7148,7 +7148,7 @@ namespace BinXlsxRW pAxis->m_txPr->m_name = L"cx:txPr"; res = ReadCT_PptxElement(0, length, pAxis->m_txPr.GetPointer()); } - else if (c_oserct_chartExDataLabelSPPR == type) + else if (c_oserct_chartExAxisSPPR == type) { pAxis->m_spPr = new PPTX::Logic::SpPr; pAxis->m_spPr->m_namespace = L"cx"; From cac6536b71b48d2248ef25dd1ee7564892d71b5d Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Mon, 21 Aug 2023 22:35:49 +0300 Subject: [PATCH 03/21] fix bug #62515 --- OdfFile/Formulas/formulasconvert.h | 3 +- OdfFile/Formulas/formulasconvert_oox.cpp | 23 +++--- .../Converter/xlsx_conditionalFormatting.cpp | 45 ++++++++++++ .../Converter/xlsx_conditionalFormatting.h | 6 ++ OdfFile/Reader/Format/calcext_elements.cpp | 15 +++- OdfFile/Reader/Format/calcext_elements.h | 4 +- OdfFile/Writer/Converter/XlsxConverter.cpp | 32 +++++++-- OdfFile/Writer/Format/calcext_elements.cpp | 8 ++- OdfFile/Writer/Format/calcext_elements.h | 17 ++--- OdfFile/Writer/Format/odf_chart_context.cpp | 2 +- .../Writer/Format/ods_conversion_context.cpp | 4 ++ .../Writer/Format/ods_conversion_context.h | 2 +- OdfFile/Writer/Format/ods_table_state.cpp | 71 +++++++++++++++---- OdfFile/Writer/Format/ods_table_state.h | 20 ++++-- 14 files changed, 198 insertions(+), 54 deletions(-) diff --git a/OdfFile/Formulas/formulasconvert.h b/OdfFile/Formulas/formulasconvert.h index 86afb4f97e..6304298acc 100644 --- a/OdfFile/Formulas/formulasconvert.h +++ b/OdfFile/Formulas/formulasconvert.h @@ -99,9 +99,10 @@ public: bool is_simple_ref(std::wstring const & expr); std::wstring get_table_name(); + void set_table_name(std::wstring const& val); //Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19 - std::wstring convert_chart_distance(std::wstring const & expr); + std::wstring convert_ref_distances(std::wstring const & expr, std::wstring const& separator_in, std::wstring const& separator_out); std::wstring convert_ref(std::wstring const & expr); diff --git a/OdfFile/Formulas/formulasconvert_oox.cpp b/OdfFile/Formulas/formulasconvert_oox.cpp index 7962dccd6c..ab1bae259e 100644 --- a/OdfFile/Formulas/formulasconvert_oox.cpp +++ b/OdfFile/Formulas/formulasconvert_oox.cpp @@ -64,7 +64,7 @@ public: std::wstring convert_formula(const std::wstring& expr); std::wstring convert_conditional_formula(const std::wstring& expr); - std::wstring convert_chart_distance(const std::wstring& expr); + std::wstring convert_ref_distances(std::wstring const& expr, std::wstring const& separator_in, std::wstring const& separator_out); static void replace_cells_range(std::wstring& expr, bool bSelect = true); static void replace_semicolons(std::wstring& expr); @@ -844,21 +844,21 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst //в //Sheet2.C3:Sheet2.C19 Sheet2.L29:Sheet2.L36 //todooo -std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring& expr1) +std::wstring oox2odf_converter::Impl::convert_ref_distances(std::wstring const& expr1, std::wstring const& separator_in, std::wstring const& separator_out) { std::wstring expr = expr1; - int res = expr.find(L"("); - if (res ==0) expr = expr.substr(res + 1, expr.size()-1); + size_t res = expr.find(L"("); + if (res == 0) expr = expr.substr(res + 1, expr.size()-1); res= expr.rfind(L")"); if (res ==expr.size()-2) expr = expr.substr(0, res); - //распарсить по диапазонам - одф-пробел, ик-эль-запятая + //распарсить по диапазонам - пробел -> separator std::vector distance_inp; std::vector distance_out; - boost::algorithm::split(distance_inp,expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on); + boost::algorithm::split(distance_inp,expr, boost::algorithm::is_any_of(separator_in), boost::algorithm::token_compress_on); for (size_t i = 0; i < distance_inp.size(); i++) { @@ -902,7 +902,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring& for (size_t i = 0 ; i < distance_out.size(); i++) { result += distance_out[i]; - result += L" "; + result += separator_out; } return result.substr(0, result.size()-1); } @@ -926,9 +926,9 @@ std::wstring oox2odf_converter::convert_formula(const std::wstring& expr) { return impl_->convert_formula(expr); } -std::wstring oox2odf_converter::convert_chart_distance(const std::wstring& expr) +std::wstring oox2odf_converter::convert_ref_distances(std::wstring const& expr, std::wstring const& separator_in, std::wstring const& separator_out) { - return impl_->convert_chart_distance(expr); + return impl_->convert_ref_distances(expr, separator_in, separator_out); } std::wstring oox2odf_converter::convert_named_ref(const std::wstring& expr) { @@ -946,7 +946,10 @@ bool oox2odf_converter::is_simple_ref(std::wstring const & expr) { return impl_->is_simple_ref(expr); } - +void oox2odf_converter::set_table_name(std::wstring const& val) +{ + impl_->table_name_ = val; +} std::wstring oox2odf_converter::get_table_name() { return impl_->table_name_; diff --git a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp index c70317852d..8a1dada7ba 100644 --- a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp +++ b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.cpp @@ -99,7 +99,11 @@ namespace oox { //data bar _CP_OPT(int) minLength; _CP_OPT(int) maxLength; + _CP_OPT(std::wstring) axis_position; + _CP_OPT(std::wstring) axis_color; + _CP_OPT(std::wstring) negative_color; //icon set + _CP_OPT(int) icon_set_type; _CP_OPT(bool) reverse; _CP_OPT(bool) iconset_percent; _CP_OPT(int) iconset_type; @@ -214,6 +218,31 @@ public: CP_XML_ATTR(L"type", L"iconSet"); CP_XML_NODE(L"iconSet") { + if (c.rules[j].icon_set_type) + { + switch (*c.rules[j].icon_set_type) + { + case 1: CP_XML_ATTR(L"iconSet", L"3ArrowsGray"); break; + case 2: CP_XML_ATTR(L"iconSet", L"3Flags"); break; + case 3: CP_XML_ATTR(L"iconSet", L"3Signs"); break; + case 4: CP_XML_ATTR(L"iconSet", L"3Symbols"); break; + case 5: CP_XML_ATTR(L"iconSet", L"3Symbols2"); break; + case 6: CP_XML_ATTR(L"iconSet", L"3TrafficLights1"); break; + case 7: CP_XML_ATTR(L"iconSet", L"3TrafficLights2"); break; + case 8: CP_XML_ATTR(L"iconSet", L"4Arrows"); break; + case 9: CP_XML_ATTR(L"iconSet", L"4ArrowsGray"); break; + case 10: CP_XML_ATTR(L"iconSet", L"4Rating"); break; + case 11: CP_XML_ATTR(L"iconSet", L"4RedToBlack"); break; + case 12: CP_XML_ATTR(L"iconSet", L"4TrafficLights"); break; + case 13: CP_XML_ATTR(L"iconSet", L"5Arrows"); break; + case 14: CP_XML_ATTR(L"iconSet", L"5ArrowsGray"); break; + case 15: CP_XML_ATTR(L"iconSet", L"5Quarters"); break; + case 16: CP_XML_ATTR(L"iconSet", L"5Rating"); break; + case 0: + default: CP_XML_ATTR(L"iconSet", L"3Arrows"); break; + break; + } + } if (c.rules[j].showValue) CP_XML_ATTR(L"showValue", *c.rules[j].showValue); for (size_t k = 0; k < c.rules[j].cfvo.size(); k++) @@ -521,6 +550,22 @@ void xlsx_conditionalFormatting_context::add_color(std::wstring col) { impl_->conditionalFormattings_.back().rules.back().color.push_back(col); } +void xlsx_conditionalFormatting_context::set_negative_color(std::wstring col) +{ + impl_->conditionalFormattings_.back().rules.back().negative_color = col; +} +void xlsx_conditionalFormatting_context::set_axis_position(std::wstring val) +{ + impl_->conditionalFormattings_.back().rules.back().axis_position = val; +} +void xlsx_conditionalFormatting_context::set_axis_color(std::wstring val) +{ + impl_->conditionalFormattings_.back().rules.back().axis_color = val; +} +void xlsx_conditionalFormatting_context::set_icon_set_type(int type) +{ + impl_->conditionalFormattings_.back().rules.back().icon_set_type = type; +} void xlsx_conditionalFormatting_context::set_showVal(bool val) { impl_->conditionalFormattings_.back().rules.back().showValue = val; diff --git a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h index 6b37397a25..9176225541 100644 --- a/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h +++ b/OdfFile/Reader/Converter/xlsx_conditionalFormatting.h @@ -58,6 +58,12 @@ public: void add_sfv (int type, std::wstring value); void add_color (std::wstring col); + + void set_negative_color(std::wstring col); + + void set_axis_position(std::wstring val); + void set_axis_color(std::wstring val); + void set_icon_set_type(int type); void serialize(std::wostream & _Wostream); private: diff --git a/OdfFile/Reader/Format/calcext_elements.cpp b/OdfFile/Reader/Format/calcext_elements.cpp index 4e10490938..d8b152833f 100644 --- a/OdfFile/Reader/Format/calcext_elements.cpp +++ b/OdfFile/Reader/Format/calcext_elements.cpp @@ -59,6 +59,7 @@ void calcext_data_bar_attr::add_attributes( const xml::attributes_wc_ptr & Attri CP_APPLY_ATTR(L"calcext:negative-color", negative_color_); CP_APPLY_ATTR(L"calcext:min-length", min_length_); CP_APPLY_ATTR(L"calcext:max-length", max_length_); + CP_APPLY_ATTR(L"calcext:axis-position", axis_position_); } void calcext_icon_set_attr::add_attributes( const xml::attributes_wc_ptr & Attributes ) @@ -173,6 +174,11 @@ void calcext_data_bar::xlsx_convert(oox::xlsx_conversion_context & Context) if (attr_.positive_color_) Context.get_conditionalFormatting_context().add_color(L"ff" + attr_.positive_color_->get_hex_value()); + if (attr_.negative_color_) + Context.get_conditionalFormatting_context().set_negative_color(L"ff" + attr_.negative_color_->get_hex_value()); + + if (attr_.axis_position_) + Context.get_conditionalFormatting_context().set_axis_position(*attr_.axis_position_); Context.get_conditionalFormatting_context().set_dataBar(attr_.min_length_, attr_.max_length_); @@ -208,7 +214,6 @@ const wchar_t * calcext_icon_set::name = L"icon-set"; void calcext_icon_set::add_attributes( const xml::attributes_wc_ptr & Attributes ) { - CP_APPLY_ATTR(L"calcext:show-value", show_value_); attr_.add_attributes(Attributes); } void calcext_icon_set::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) @@ -219,8 +224,8 @@ void calcext_icon_set::xlsx_convert(oox::xlsx_conversion_context & Context) { Context.get_conditionalFormatting_context().add_rule(4); - if (show_value_) - Context.get_conditionalFormatting_context().set_showVal(*show_value_); + if (attr_.icon_set_type_) + Context.get_conditionalFormatting_context().set_icon_set_type(attr_.icon_set_type_->get_type()); for (size_t i = 0 ; i < content_.size(); i++) { @@ -237,6 +242,7 @@ void calcext_formatting_entry::add_attributes( const xml::attributes_wc_ptr & At { CP_APPLY_ATTR(L"calcext:value", value_); CP_APPLY_ATTR(L"calcext:type", type_); + CP_APPLY_ATTR(L"calcext:show-value", show_value_); } void calcext_formatting_entry::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { @@ -246,6 +252,9 @@ void calcext_formatting_entry::xlsx_convert(oox::xlsx_conversion_context & Conte { calcext_type::type t = type_.get_value_or(calcext_type::Number).get_type(); Context.get_conditionalFormatting_context().add_sfv((int)t, value_.get_value_or(L"")); + + if (show_value_) + Context.get_conditionalFormatting_context().set_showVal(*show_value_); } // calcext_color_scale_entry diff --git a/OdfFile/Reader/Format/calcext_elements.h b/OdfFile/Reader/Format/calcext_elements.h index 585b1b3e3d..987d9150f7 100644 --- a/OdfFile/Reader/Format/calcext_elements.h +++ b/OdfFile/Reader/Format/calcext_elements.h @@ -56,7 +56,8 @@ public: _CP_OPT(odf_types::color) axis_color_; _CP_OPT(odf_types::color) positive_color_; _CP_OPT(odf_types::color) negative_color_; - _CP_OPT(int) max_length_; + _CP_OPT(std::wstring) axis_position_; + _CP_OPT(int) max_length_; _CP_OPT(int) min_length_; }; @@ -165,6 +166,7 @@ public: _CP_OPT(std::wstring) value_; _CP_OPT(odf_types::calcext_type) type_; + _CP_OPT(bool) show_value_; }; CP_REGISTER_OFFICE_ELEMENT2(calcext_formatting_entry); diff --git a/OdfFile/Writer/Converter/XlsxConverter.cpp b/OdfFile/Writer/Converter/XlsxConverter.cpp index 33eeeb190c..3a576c6182 100644 --- a/OdfFile/Writer/Converter/XlsxConverter.cpp +++ b/OdfFile/Writer/Converter/XlsxConverter.cpp @@ -475,7 +475,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet) { for (size_t ext = 0; ext < oox_sheet->m_oExtLst->m_arrExt.size(); ext++) { - for (size_t fmt = 0; (oox_sheet->m_oExtLst->m_arrExt[ext]) && (fmt < oox_sheet->m_oExtLst->m_arrExt[ext]->m_arrConditionalFormatting.size()); fmt++) + if (!oox_sheet->m_oExtLst->m_arrExt[ext]) continue; + + for (size_t fmt = 0; fmt < oox_sheet->m_oExtLst->m_arrExt[ext]->m_arrConditionalFormatting.size(); fmt++) { OOX::Spreadsheet::CConditionalFormatting* cond_fmt = oox_sheet->m_oExtLst->m_arrExt[ext]->m_arrConditionalFormatting[fmt]; if (cond_fmt) @@ -3456,15 +3458,30 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co } void XlsxConverter::convert(OOX::Spreadsheet::CDataBar *oox_cond_databar) { - if (!oox_cond_databar)return; + if (!oox_cond_databar) return; _CP_OPT(odf_types::color) color; - convert(oox_cond_databar->m_oColor.GetPointer(), color); + + if (oox_cond_databar->m_oBorderColor.IsInit()) + convert(oox_cond_databar->m_oBorderColor.GetPointer(), color); + else + convert(oox_cond_databar->m_oColor.GetPointer(), color); ods_context->current_table()->set_conditional_databar_color(color); - //nullable> m_oMaxLength; + + convert(oox_cond_databar->m_oAxisColor.GetPointer(), color); + ods_context->current_table()->set_conditional_databar_axis_color(color); + + convert(oox_cond_databar->m_oNegativeBorderColor.GetPointer(), color); + ods_context->current_table()->set_conditional_databar_negative_color(color); + + if (oox_cond_databar->m_oAxisPosition.IsInit()) + ods_context->current_table()->set_conditional_databar_axis_position(oox_cond_databar->m_oAxisPosition->ToString()); + + if (oox_cond_databar->m_oShowValue.IsInit()) + ods_context->current_table()->set_conditional_show_value(oox_cond_databar->m_oShowValue->ToBool()); + //nullable> m_oMaxLength; //nullable> m_oMinLength; - //nullable> m_oShowValue; for (size_t i=0; i< oox_cond_databar->m_arrValues.size(); i++) convert(oox_cond_databar->m_arrValues[i].GetPointer()); } @@ -3494,7 +3511,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CIconSet *oox_cond_iconset) ods_context->current_table()->set_conditional_iconset(oox_cond_iconset->m_oIconSet->GetValue()); //nullable> m_oMaxLength; //nullable> m_oMinLength; - //nullable> m_oShowValue; + //nullable> m_oc; + if (oox_cond_iconset->m_oShowValue.IsInit()) + ods_context->current_table()->set_conditional_show_value(oox_cond_iconset->m_oShowValue->ToBool()); + for (size_t i=0; i< oox_cond_iconset->m_arrValues.size(); i++) { convert(oox_cond_iconset->m_arrValues[i].GetPointer()); diff --git a/OdfFile/Writer/Format/calcext_elements.cpp b/OdfFile/Writer/Format/calcext_elements.cpp index fc5ff76367..406b401543 100644 --- a/OdfFile/Writer/Format/calcext_elements.cpp +++ b/OdfFile/Writer/Format/calcext_elements.cpp @@ -47,6 +47,7 @@ void calcext_data_bar_attr::serialize(CP_ATTR_NODE) CP_XML_ATTR_OPT(L"calcext:axis-color", calcext_axis_color_); CP_XML_ATTR_OPT(L"calcext:positive-color", calcext_positive_color_); CP_XML_ATTR_OPT(L"calcext:negative-color", calcext_negative_color_); + CP_XML_ATTR_OPT(L"calcext:axis-position", calcext_axis_position_); } void calcext_icon_set_attr::serialize(CP_ATTR_NODE) @@ -72,6 +73,8 @@ void calcext_sparkline_group_attr::serialize(CP_ATTR_NODE) CP_XML_ATTR_OPT(L"calcext:line-width", line_width_); CP_XML_ATTR_OPT(L"calcext:first", first_); CP_XML_ATTR_OPT(L"calcext:last", last_); + CP_XML_ATTR_OPT(L"calcext:high", high_); + CP_XML_ATTR_OPT(L"calcext:low", low_); CP_XML_ATTR_OPT(L"calcext:markers", markers_); CP_XML_ATTR_OPT(L"calcext:display-hidden", display_hidden_); CP_XML_ATTR_OPT(L"calcext:right-to-left", right_to_left_); @@ -243,8 +246,9 @@ void calcext_formatting_entry::serialize(std::wostream & _Wostream) { CP_XML_NODE_SIMPLE() { - CP_XML_ATTR_OPT_ENCODE_STRING(L"calcext:value",calcext_value_); - CP_XML_ATTR_OPT(L"calcext:type", calcext_type_); + CP_XML_ATTR_OPT_ENCODE_STRING(L"calcext:value", value_); + CP_XML_ATTR_OPT(L"calcext:show-value", show_value_); + CP_XML_ATTR_OPT(L"calcext:type", type_); } } } diff --git a/OdfFile/Writer/Format/calcext_elements.h b/OdfFile/Writer/Format/calcext_elements.h index 9b1dab9614..593e0a6018 100644 --- a/OdfFile/Writer/Format/calcext_elements.h +++ b/OdfFile/Writer/Format/calcext_elements.h @@ -59,6 +59,7 @@ public: _CP_OPT(odf_types::color) calcext_axis_color_; _CP_OPT(odf_types::color) calcext_positive_color_; _CP_OPT(odf_types::color) calcext_negative_color_; + _CP_OPT(std::wstring) calcext_axis_position_; }; class calcext_condition_attr @@ -155,16 +156,16 @@ public: static const wchar_t * ns; static const wchar_t * name; - static const ElementType type = typeCalcextFormattingEntry; - + static const ElementType type = typeCalcextFormattingEntry; virtual void create_child_element( const std::wstring & Ns, const std::wstring & Name){} virtual void add_child_element( const office_element_ptr & child_element){} virtual void serialize(std::wostream & _Wostream); - _CP_OPT(std::wstring) calcext_value_; - _CP_OPT(odf_types::calcext_type) calcext_type_; + _CP_OPT(std::wstring) value_; + _CP_OPT(odf_types::calcext_type) type_; + _CP_OPT(odf_types::Bool) show_value_; }; CP_REGISTER_OFFICE_ELEMENT2(calcext_formatting_entry); @@ -176,8 +177,7 @@ public: static const wchar_t * ns; static const wchar_t * name; - static const ElementType type = typeCalcextIconSet; - + static const ElementType type = typeCalcextIconSet; virtual void create_child_element( const std::wstring & Ns, const std::wstring & Name); virtual void add_child_element( const office_element_ptr & child_element); @@ -185,6 +185,7 @@ public: virtual void serialize(std::wostream & _Wostream); calcext_icon_set_attr attr_; + _CP_OPT(odf_types::Bool) show_value_; office_element_ptr_array content_;//entries }; @@ -197,8 +198,7 @@ public: static const wchar_t * ns; static const wchar_t * name; - static const ElementType type = typeCalcextDataBar; - + static const ElementType type = typeCalcextDataBar; virtual void create_child_element( const std::wstring & Ns, const std::wstring & Name); virtual void add_child_element( const office_element_ptr & child_element); @@ -206,6 +206,7 @@ public: virtual void serialize(std::wostream & _Wostream); calcext_data_bar_attr attr_; + _CP_OPT(odf_types::Bool) show_value_; office_element_ptr_array content_;//entries }; CP_REGISTER_OFFICE_ELEMENT2(calcext_data_bar) diff --git a/OdfFile/Writer/Format/odf_chart_context.cpp b/OdfFile/Writer/Format/odf_chart_context.cpp index 68b82a6263..36bf78bc67 100644 --- a/OdfFile/Writer/Format/odf_chart_context.cpp +++ b/OdfFile/Writer/Format/odf_chart_context.cpp @@ -268,7 +268,7 @@ std::wstring odf_chart_context::Impl::convert_formula(std::wstring oox_ref) return L""; } } - std::wstring odf_ref = formulas_converter_chart.convert_chart_distance(oox_ref); + std::wstring odf_ref = formulas_converter_chart.convert_ref_distances(oox_ref, L",", L" "); //XmlUtils::replace_all( odf_ref, L"$", L""); return odf_ref; diff --git a/OdfFile/Writer/Format/ods_conversion_context.cpp b/OdfFile/Writer/Format/ods_conversion_context.cpp index 9342fd0a11..ac2bb0537c 100644 --- a/OdfFile/Writer/Format/ods_conversion_context.cpp +++ b/OdfFile/Writer/Format/ods_conversion_context.cpp @@ -93,6 +93,10 @@ void ods_conversion_context::start_conditional_formats() { current_table()->start_conditional_formats(); } +void ods_conversion_context::end_conditional_formats() +{ + current_table()->end_conditional_formats(); +} void ods_conversion_context::start_table_part(std::wstring name, std::wstring ref) { table_context_.start_table_part(name, ref); diff --git a/OdfFile/Writer/Format/ods_conversion_context.h b/OdfFile/Writer/Format/ods_conversion_context.h index edf0569899..7d22aaf2b4 100644 --- a/OdfFile/Writer/Format/ods_conversion_context.h +++ b/OdfFile/Writer/Format/ods_conversion_context.h @@ -129,7 +129,7 @@ public: void end_pivot_table(); void start_conditional_formats(); - void end_conditional_formats(){} + void end_conditional_formats(); void start_table_view(int view_id); void end_table_view(); diff --git a/OdfFile/Writer/Format/ods_table_state.cpp b/OdfFile/Writer/Format/ods_table_state.cpp index ed202a3d47..44e3fe1475 100644 --- a/OdfFile/Writer/Format/ods_table_state.cpp +++ b/OdfFile/Writer/Format/ods_table_state.cpp @@ -1913,7 +1913,7 @@ void ods_table_state::end_conditional_formats() { current_level_.pop_back(); } -void ods_table_state::start_conditional_format(std::wstring ref) +void ods_table_state::start_conditional_format(const std::wstring& ref) { office_element_ptr elm; create_element(L"calcext", L"conditional-format", elm, context_); @@ -1926,7 +1926,7 @@ void ods_table_state::start_conditional_format(std::wstring ref) if (cond_format) { formulasconvert::oox2odf_converter converter; - std::wstring out = converter.convert_ref(ref); + std::wstring out = converter.convert_ref_distances(ref, L" ", L" "); cond_format->calcext_target_range_address_ = out; //проверить конвертацию на диапазонах с именами листов в кавычках и с пробелами @@ -2020,7 +2020,7 @@ void ods_table_state::end_conditional_rule() current_level_.pop_back(); } -void ods_table_state::set_conditional_formula(std::wstring formula) +void ods_table_state::set_conditional_formula(const std::wstring& formula) { calcext_condition* condition = dynamic_cast (current_level_.back().get()); @@ -2134,7 +2134,7 @@ void ods_table_state::set_conditional_operator(int _operator) } } } -void ods_table_state::set_conditional_value(int type, std::wstring value ) +void ods_table_state::set_conditional_value(int type, const std::wstring& value ) { calcext_icon_set* icon_set = dynamic_cast (current_level_.back().get()); calcext_data_bar* data_bar = dynamic_cast (current_level_.back().get()); @@ -2150,19 +2150,20 @@ void ods_table_state::set_conditional_value(int type, std::wstring value ) calcext_formatting_entry * entry = dynamic_cast(elm.get()); if (entry) { + entry->show_value_ = icon_set ? icon_set->show_value_ : data_bar->show_value_; switch(type) { - case 1: entry->calcext_type_ = calcext_type(calcext_type::Maximum); break; - case 2: entry->calcext_type_ = calcext_type(calcext_type::Minimum); break; - case 4: entry->calcext_type_ = calcext_type(calcext_type::Percent); break; - case 5: entry->calcext_type_ = calcext_type(calcext_type::Percentile); break; - case 6: entry->calcext_type_ = calcext_type(calcext_type::AutoMinimum); break; - case 7: entry->calcext_type_ = calcext_type(calcext_type::AutoMaximum); break; + case 1: entry->type_ = calcext_type(calcext_type::Maximum); break; + case 2: entry->type_ = calcext_type(calcext_type::Minimum); break; + case 4: entry->type_ = calcext_type(calcext_type::Percent); break; + case 5: entry->type_ = calcext_type(calcext_type::Percentile); break; + case 6: entry->type_ = calcext_type(calcext_type::AutoMinimum); break; + case 7: entry->type_ = calcext_type(calcext_type::AutoMaximum); break; case 0: //Formula case 3: //Number - default: entry->calcext_type_ = calcext_type(calcext_type::Number); + default: entry->type_ = calcext_type(calcext_type::Number); } - entry->calcext_value_ = value; + entry->value_ = value; } } @@ -2190,7 +2191,19 @@ void ods_table_state::set_conditional_value(int type, std::wstring value ) } ///color???? - прихоодят выше уровнем !! } - +} +void ods_table_state::set_conditional_show_value(bool value) +{ + calcext_icon_set* cond_format = dynamic_cast(current_level_.back().get()); + if (cond_format) + { + cond_format->show_value_ = value; + } + calcext_data_bar* cond_format2 = dynamic_cast(current_level_.back().get()); + if (cond_format2) + { + cond_format2->show_value_ = value; + } } void ods_table_state::set_conditional_iconset(int type_iconset) { @@ -2201,7 +2214,7 @@ void ods_table_state::set_conditional_iconset(int type_iconset) cond_format->attr_.calcext_icon_set_type_ = iconset_type((iconset_type::type)type_iconset); } } -void ods_table_state::add_conditional_colorscale(int index, _CP_OPT(color) color) +void ods_table_state::add_conditional_colorscale(int index, _CP_OPT(color)& color) { calcext_color_scale *scale = dynamic_cast(current_level_.back().get()); @@ -2215,7 +2228,7 @@ void ods_table_state::add_conditional_colorscale(int index, _CP_OPT(color) color color_scale_entry->calcext_color_ = color; } } -void ods_table_state::set_conditional_databar_color(_CP_OPT(color) color) +void ods_table_state::set_conditional_databar_color(_CP_OPT(color)& color) { calcext_data_bar* cond_format = dynamic_cast(current_level_.back().get()); @@ -2224,6 +2237,34 @@ void ods_table_state::set_conditional_databar_color(_CP_OPT(color) color) cond_format->attr_.calcext_positive_color_ = color; } } +void ods_table_state::set_conditional_databar_axis_color(_CP_OPT(color)& color) +{ + calcext_data_bar* cond_format = dynamic_cast(current_level_.back().get()); + + if (cond_format) + { + cond_format->attr_.calcext_axis_color_ = color; + } +} +void ods_table_state::set_conditional_databar_negative_color(_CP_OPT(color)& color) +{ + calcext_data_bar* cond_format = dynamic_cast(current_level_.back().get()); + + if (cond_format) + { + cond_format->attr_.calcext_negative_color_ = color; + } +} +void ods_table_state::set_conditional_databar_axis_position(const std::wstring& type) +{ + calcext_data_bar* cond_format = dynamic_cast(current_level_.back().get()); + + if (cond_format) + { + cond_format->attr_.calcext_axis_position_ = type; + } + +} } } diff --git a/OdfFile/Writer/Format/ods_table_state.h b/OdfFile/Writer/Format/ods_table_state.h index 67b3eeecbb..775a2ec501 100644 --- a/OdfFile/Writer/Format/ods_table_state.h +++ b/OdfFile/Writer/Format/ods_table_state.h @@ -382,14 +382,22 @@ public: void add_child_element( const office_element_ptr & child_element); void start_conditional_formats(); - void start_conditional_format(std::wstring ref); + void start_conditional_format(const std::wstring& ref); void start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank, _CP_OPT(bool) bottom, _CP_OPT(bool) percent); - void set_conditional_formula(std::wstring formula); - void set_conditional_value(int type, std::wstring value ); - void set_conditional_iconset(int type_iconset); - void add_conditional_colorscale(int index, _CP_OPT(odf_types::color) color); - void set_conditional_databar_color(_CP_OPT(odf_types::color) color); + void set_conditional_formula(const std::wstring& formula); + void set_conditional_value(int type, const std::wstring& value ); + + void set_conditional_iconset(int type_iconset); + void set_conditional_show_value(bool value); + + void add_conditional_colorscale(int index, _CP_OPT(odf_types::color) & color); + + void set_conditional_databar_color(_CP_OPT(odf_types::color) & color); + void set_conditional_databar_negative_color(_CP_OPT(odf_types::color) & color); + void set_conditional_databar_axis_color(_CP_OPT(odf_types::color) & color); + void set_conditional_databar_axis_position(const std::wstring& value); + void set_conditional_style_name(const std::wstring &style_name); void set_conditional_operator(int _operator); From 629c679ee12b9de81453c526103e81aec3cb1e43 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 22 Aug 2023 15:48:05 +0300 Subject: [PATCH 04/21] Ad support docxf/oform to docbuilder class --- DesktopEditor/doctrenderer/docbuilder_p.cpp | 2 +- DesktopEditor/doctrenderer/docbuilder_p.h | 41 ++++----------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/DesktopEditor/doctrenderer/docbuilder_p.cpp b/DesktopEditor/doctrenderer/docbuilder_p.cpp index d5ab9f9aa2..1835d08215 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.cpp +++ b/DesktopEditor/doctrenderer/docbuilder_p.cpp @@ -1414,7 +1414,7 @@ namespace NSDoctRenderer bIsNoError = (0 == this->OpenFile(_builder_params[0].c_str(), _builder_params[1].c_str())); else if ("CreateFile" == sFuncNum) { - if (L"docx" == _builder_params[0]) + if (L"docx" == _builder_params[0] || L"docxf" == _builder_params[0] || L"oform" == _builder_params[0]) bIsNoError = this->CreateFile(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX); else if (L"pptx" == _builder_params[0]) bIsNoError = this->CreateFile(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX); diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index 7d2996dc6a..d955b3fb33 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -100,6 +100,12 @@ namespace NSDoctRenderer nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_JPG; else if (L"png" == sExt) nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_PNG; + else if (L"docxf" == sExt) + nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF; + else if (L"oform" == sExt) + nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM; + else if (L"html" == sExt) + nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER; return nFormat; } } @@ -1247,40 +1253,7 @@ namespace NSDoctRenderer int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL) { - int nType = -1; - if (L"docx" == ext) - nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX; - else if (L"doc" == ext) - nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC; - else if (L"odt" == ext) - nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT; - else if (L"rtf" == ext) - nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF; - else if (L"txt" == ext) - nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT; - else if (L"pptx" == ext) - nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX; - else if (L"odp" == ext) - nType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP; - else if (L"xlsx" == ext) - nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX; - else if (L"xls" == ext) - nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS; - else if (L"ods" == ext) - nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS; - else if (L"csv" == ext) - nType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV; - else if (L"pdf" == ext) - nType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF; - else if (L"image" == ext) - nType = AVS_OFFICESTUDIO_FILE_IMAGE; - else if (L"jpg" == ext) - nType = AVS_OFFICESTUDIO_FILE_IMAGE; - else if (L"png" == ext) - nType = AVS_OFFICESTUDIO_FILE_IMAGE; - else if (L"html" == ext) - nType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER; - + int nType = GetFormatByTexExtention(ext); return SaveFile(nType, path, params); } From e748918821ada005652eb081c34f148862acbbcd Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Tue, 22 Aug 2023 18:14:57 +0300 Subject: [PATCH 05/21] odf gradient extended --- OdfFile/Common/odf_elements_type.h | 3 + OdfFile/DataTypes/color.cpp | 33 ++- OdfFile/DataTypes/color.h | 65 ++++-- OdfFile/Reader/Format/draw_common.cpp | 203 ++++++++++-------- OdfFile/Reader/Format/styles.cpp | 26 ++- OdfFile/Reader/Format/styles.h | 64 ++++-- OdfFile/Writer/Converter/ConvertDrawing.cpp | 89 ++++---- OdfFile/Writer/Format/odf_drawing_context.cpp | 35 ++- OdfFile/Writer/Format/odf_drawing_context.h | 2 + OdfFile/Writer/Format/styles.cpp | 58 ++++- OdfFile/Writer/Format/styles.h | 186 ++++++++-------- 11 files changed, 500 insertions(+), 264 deletions(-) diff --git a/OdfFile/Common/odf_elements_type.h b/OdfFile/Common/odf_elements_type.h index 0f3931902d..fbbabc3a5a 100644 --- a/OdfFile/Common/odf_elements_type.h +++ b/OdfFile/Common/odf_elements_type.h @@ -285,6 +285,9 @@ enum ElementType typeStyleMap, typeStylePageMaster, // openoffice xml 1.0 + typeStyleGradientStop, + typeStyleOpacityStop, + typeTableTemplate, typeTableTemplateElement, typeTableBodyTemplate, diff --git a/OdfFile/DataTypes/color.cpp b/OdfFile/DataTypes/color.cpp index c5df6a5bfa..910a5723bd 100644 --- a/OdfFile/DataTypes/color.cpp +++ b/OdfFile/DataTypes/color.cpp @@ -97,7 +97,7 @@ const std::wstring color::get_hex_value(bool alfa) const unsigned int t = 0; if ((s << tmp) && (s >> std::hex >> t) && (s >> std::ws).eof()) { - result = XmlUtils::GetUpper(tmp); + result = tmp; } } catch(...) @@ -108,5 +108,36 @@ const std::wstring color::get_hex_value(bool alfa) const if (alfa) return L"FF" + result; else return result; } +//----------------------------------------------------------------------------------------------------------------- +std::wostream& operator << (std::wostream& _Wostream, const color_type& _Val) +{ + switch (_Val.get_type()) + { + case color_type::rgb: + _Wostream << L"rgb"; + break; + case color_type::theme: + _Wostream << L"theme"; + break; + default: + break; + } + return _Wostream; +} + +color_type color_type::parse(const std::wstring& Str) +{ + std::wstring tmp = Str; + boost::algorithm::to_lower(tmp); + + if (tmp == L"rgb") + return color_type(rgb); + else if (tmp == L"theme") + return color_type(theme); + else + { + return color_type(rgb); + } +} } } diff --git a/OdfFile/DataTypes/color.h b/OdfFile/DataTypes/color.h index 376dd21e49..9bf152095e 100644 --- a/OdfFile/DataTypes/color.h +++ b/OdfFile/DataTypes/color.h @@ -35,33 +35,58 @@ #include #include "odfattributes.h" +namespace cpdoccore { + namespace odf_types { -namespace cpdoccore { namespace odf_types { + class color + { + public: + color() {}; -class color -{ -public: - color() {}; - - color(const std::wstring & _Color) : color_(_Color) {}; - - const std::wstring & get_color() const - { - return color_; - }; + color(const std::wstring& _Color) : color_(_Color) {}; - const std::wstring get_hex_value(bool alfa = false) const; + const std::wstring& get_color() const + { + return color_; + }; - static color parse(const std::wstring & Str); + const std::wstring get_hex_value(bool alfa = false) const; -private: - std::wstring color_; -}; + static color parse(const std::wstring& Str); -std::wostream & operator << (std::wostream & _Wostream, const color & _Color); -bool operator== (const color & c1, const color & c2); -} + private: + std::wstring color_; + }; + std::wostream& operator << (std::wostream& _Wostream, const color& _Color); + bool operator== (const color& c1, const color& c2); + //---------------------------------------------------------------------------------------------------------- + class color_type + { + public: + enum type + { + rgb, + theme + }; + color_type() {} + + color_type(type _Type) : type_(_Type) + {} + + type get_type() const + { + return type_; + }; + + static color_type parse(const std::wstring& Str); + private: + type type_; + }; + std::wostream& operator << (std::wostream& _Wostream, const color_type& _Val); + } + +APPLY_PARSE_XML_ATTRIBUTES(odf_types::color_type); APPLY_PARSE_XML_ATTRIBUTES(odf_types::color); } diff --git a/OdfFile/Reader/Format/draw_common.cpp b/OdfFile/Reader/Format/draw_common.cpp index 1eade83c1d..7c91d47f4c 100644 --- a/OdfFile/Reader/Format/draw_common.cpp +++ b/OdfFile/Reader/Format/draw_common.cpp @@ -295,91 +295,107 @@ void Compute_HatchFill(draw_hatch * image_style,oox::oox_hatch_fill_ptr fill) break; } } -void Compute_GradientFill(draw_gradient *image_style, oox::oox_gradient_fill_ptr fill) +void Compute_GradientFill(draw_gradient* gradient_style, oox::oox_gradient_fill_ptr fill) { - int style =0; - if (image_style->draw_style_)style = image_style->draw_style_->get_type(); + int style = 0; + if (gradient_style->draw_style_) style = gradient_style->draw_style_->get_type(); - if (image_style->draw_angle_) fill->angle = 90 - image_style->draw_angle_->get_value(); - if (fill->angle < 0) fill->angle +=360; + if (gradient_style->draw_angle_) fill->angle = 90 - gradient_style->draw_angle_->get_value(); + if (fill->angle < 0) fill->angle += 360; - oox::oox_gradient_fill::_color_position point={}; - switch(style) + for (size_t i = 0; i < gradient_style->content_.size(); ++i) { - case gradient_style::linear: - { - fill->style = 0; - - point.pos = 0; - if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value(); - //if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value(); - - fill->colors.push_back(point); - - point.pos = 100; - if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); - if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); - - fill->colors.push_back(point); - }break; - case gradient_style::axial: + loext_gradient_stop* gradient_stop = dynamic_cast(gradient_style->content_[i].get()); + if (gradient_stop) { - fill->style = 0; - - point.pos = 0; - if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); - //if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); - - fill->colors.push_back(point); + if (fill->colors.size() <= i) fill->colors.emplace_back(); - point.pos = 50; - if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value(); - if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value(); + if (gradient_stop->color_value_) + fill->colors[i].color_ref = gradient_stop->color_value_->get_hex_value(); + if (gradient_stop->svg_offset_) + fill->colors[i].pos = 100 - *gradient_stop->svg_offset_ * 100; + } + } + fill->style = 0; + if (style == gradient_style::radial || + style == gradient_style::ellipsoid) fill->style = 2; + else if (style == gradient_style::square) fill->style = 1; + else if (style == gradient_style::rectangular) fill->style = 3; - fill->colors.push_back(point); - - point.pos = 100; - if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); - //if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); - - fill->colors.push_back(point); - }break; - case gradient_style::radial: - case gradient_style::ellipsoid: - case gradient_style::square: - case gradient_style::rectangular: + if (fill->colors.empty()) + { + oox::oox_gradient_fill::_color_position point = {}; + switch (style) { - if (style == gradient_style::radial || - style == gradient_style::ellipsoid) fill->style = 2; - if (style == gradient_style::square ) fill->style = 1; - if (style == gradient_style::rectangular) fill->style = 3; - - point.pos = 0; - if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value(); - //if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value(); + case gradient_style::linear: + { + point.pos = 0; + if (gradient_style->draw_start_color_) point.color_ref = gradient_style->draw_start_color_->get_hex_value(); + //if (gradient_style->draw_start_intensity_) point.opacity = gradient_style->draw_start_intensity_->get_value(); + + fill->colors.push_back(point); + + point.pos = 100; + if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value(); + if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value(); + + fill->colors.push_back(point); + }break; + case gradient_style::axial: + { + point.pos = 0; + if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value(); + //if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value(); + + fill->colors.push_back(point); + + point.pos = 50; + if (gradient_style->draw_start_color_) point.color_ref = gradient_style->draw_start_color_->get_hex_value(); + if (gradient_style->draw_start_intensity_) point.opacity = gradient_style->draw_start_intensity_->get_value(); + + fill->colors.push_back(point); + + point.pos = 100; + if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value(); + //if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value(); + + fill->colors.push_back(point); + }break; + case gradient_style::radial: + case gradient_style::ellipsoid: + case gradient_style::square: + case gradient_style::rectangular: + { + point.pos = 0; + if (gradient_style->draw_start_color_) point.color_ref = gradient_style->draw_start_color_->get_hex_value(); + //if (gradient_style->draw_start_intensity_) point.opacity = gradient_style->draw_start_intensity_->get_value(); + + fill->colors.push_back(point); + + point.pos = 100; + if (gradient_style->draw_end_color_) point.color_ref = gradient_style->draw_end_color_->get_hex_value(); + //if (gradient_style->draw_end_intensity_) point.opacity = gradient_style->draw_end_intensity_->get_value(); + + fill->colors.push_back(point); + }break; + } + } - fill->colors.push_back(point); + if (fill->style > 1) + { + fill->rect[0] = fill->rect[1] = 0; + fill->rect[2] = fill->rect[3] = 100; - point.pos = 100; - if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); - //if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); - - fill->colors.push_back(point); - - fill->rect[0] = fill->rect[1] = 0; - fill->rect[2] = fill->rect[3] = 100; - - if (image_style->draw_cx_) - { - fill->rect[0] = 100 - image_style->draw_cx_->get_value(); - fill->rect[2] = image_style->draw_cx_->get_value(); - } - if (image_style->draw_cy_) - { - fill->rect[1] = 100 - image_style->draw_cy_->get_value(); - fill->rect[3] = image_style->draw_cy_->get_value(); - } - }break; + if (gradient_style->draw_cx_) + { + fill->rect[0] = 100 - gradient_style->draw_cx_->get_value(); + fill->rect[2] = gradient_style->draw_cx_->get_value(); + } + if (gradient_style->draw_cy_) + { + fill->rect[1] = 100 - gradient_style->draw_cy_->get_value(); + fill->rect[3] = gradient_style->draw_cy_->get_value(); + } } } @@ -401,15 +417,23 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el if (office_element_ptr style = styles.find_by_style_name(style_name)) { - if (draw_opacity * image_style = dynamic_cast(style.get())) + if (draw_opacity * opacity_style = dynamic_cast(style.get())) { - //увы и ах но ms не поддерживает градиентную прозрачность - сделаем средненькую - if (image_style->draw_start_ && image_style->draw_end_) + if (opacity_style->draw_start_ && opacity_style->draw_end_ || opacity_style->content_.size() > 1) { - fill.opacity = (image_style->draw_start_->get_value() + image_style->draw_end_->get_value())/2.; + fill.gradient = oox::oox_gradient_fill::create(); + fill.type = 3; //?? градиентная прозрачность на картинку + + for (size_t i = 0; i < opacity_style->content_.size(); ++i) + { + loext_opacity_stop* opacity_stop = dynamic_cast(opacity_style->content_[i].get()); + fill.gradient->colors.emplace_back(); + fill.gradient->colors.back().opacity = 100 * opacity_stop->stop_opacity_.get_value_or(0); + fill.gradient->colors.back().pos = opacity_stop->svg_offset_.get_value_or(0) * 100; + } } - else if (image_style->draw_start_)fill.opacity = image_style->draw_start_->get_value(); - else if (image_style->draw_end_)fill.opacity = image_style->draw_end_->get_value(); + else if (opacity_style->draw_start_) fill.opacity = opacity_style->draw_start_->get_value(); + else if (opacity_style->draw_end_) fill.opacity = opacity_style->draw_end_->get_value(); } } } @@ -423,6 +447,14 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el fill.solid->color = props.draw_fill_color_->get_hex_value(); if (fill.type <= 0 && !txbx ) fill.type = 1; //в этом случае тип может и не быть задан явно + + if (fill.gradient) + { + for (size_t i = 0; i < fill.gradient->colors.size(); ++i) + { + fill.gradient->colors[i].color_ref = props.draw_fill_color_->get_hex_value(); + } + } } if (props.draw_fill_image_name_) @@ -526,12 +558,13 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el const std::wstring style_name = L"gradient:" + *props.draw_fill_gradient_name_; if (office_element_ptr style = styles.find_by_style_name(style_name)) { - if (draw_gradient * image_style = dynamic_cast(style.get())) + if (draw_gradient *gradient_style = dynamic_cast(style.get())) { - fill.type = 3; - fill.gradient = oox::oox_gradient_fill::create(); + fill.type = 3; + + if (!fill.gradient) fill.gradient = oox::oox_gradient_fill::create(); - Compute_GradientFill(image_style, fill.gradient); + Compute_GradientFill(gradient_style, fill.gradient); if (fill.opacity) { diff --git a/OdfFile/Reader/Format/styles.cpp b/OdfFile/Reader/Format/styles.cpp index cc59f7ac72..28beb0aa24 100644 --- a/OdfFile/Reader/Format/styles.cpp +++ b/OdfFile/Reader/Format/styles.cpp @@ -545,7 +545,7 @@ void draw_gradient::add_attributes( const xml::attributes_wc_ptr & Attributes ) void draw_gradient::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - CP_NOT_APPLICABLE_ELM(); + CP_CREATE_ELEMENT(content_); } ////////////////////////////////////////////////////////////////////////////////////////////////// const wchar_t * draw_hatch::ns = L"draw"; @@ -586,7 +586,7 @@ void draw_opacity::add_attributes( const xml::attributes_wc_ptr & Attributes ) void draw_opacity::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - CP_NOT_APPLICABLE_ELM(); + CP_CREATE_ELEMENT(content_); } // style:style ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2157,6 +2157,28 @@ void style_presentation_page_layout::pptx_convert(oox::pptx_conversion_context & content_[i]->pptx_convert(Context); } } +//-------------------------------------------------------------------------------------------------- +const wchar_t* loext_gradient_stop::ns = L"loext"; +const wchar_t* loext_gradient_stop::name = L"gradient-stop"; + +void loext_gradient_stop::add_attributes(const xml::attributes_wc_ptr& Attributes) +{ + CP_APPLY_ATTR(L"loext:color-type", color_type_); + CP_APPLY_ATTR(L"loext:color-value", color_value_); + CP_APPLY_ATTR(L"svg:offset", svg_offset_); +} +//-------------------------------------------------------------------------------------------------- +const wchar_t* loext_opacity_stop::ns = L"loext"; +const wchar_t* loext_opacity_stop::name = L"opacity-stop"; + +void loext_opacity_stop::add_attributes(const xml::attributes_wc_ptr& Attributes) +{ + CP_APPLY_ATTR(L"svg:stop-opacity", stop_opacity_); + CP_APPLY_ATTR(L"svg:offset", svg_offset_); + + //CP_APPLY_ATTR(L"loext:stop-opacity", stop_opacity_); //?? +} + } } diff --git a/OdfFile/Reader/Format/styles.h b/OdfFile/Reader/Format/styles.h index ace746b870..8b78ced093 100644 --- a/OdfFile/Reader/Format/styles.h +++ b/OdfFile/Reader/Format/styles.h @@ -174,7 +174,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - std::wstring get_style_name(){return draw_name_.get_value_or(L"");} + std::wstring get_style_name(){return draw_name_.get_value_or(L"");} _CP_OPT(odf_types::length_or_percent) draw_distance_; _CP_OPT(odf_types::length_or_percent) draw_dots1_length_; @@ -205,7 +205,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - std::wstring get_style_name(){return draw_name_.get_value_or(L"");} + std::wstring get_style_name(){return draw_name_.get_value_or(L"");} _CP_OPT(odf_types::color) draw_start_color_; _CP_OPT(odf_types::color) draw_end_color_; @@ -220,17 +220,17 @@ public: _CP_OPT(odf_types::draw_angle) draw_angle_; _CP_OPT(odf_types::gradient_style) draw_style_; - _CP_OPT(std::wstring) draw_name_; _CP_OPT(std::wstring) draw_display_name_; + office_element_ptr_array content_; private: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); }; CP_REGISTER_OFFICE_ELEMENT2(draw_gradient); -///////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------ // draw:hatch class draw_hatch : public office_element_impl { @@ -242,7 +242,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - std::wstring get_style_name(){return draw_name_.get_value_or(L"");} + std::wstring get_style_name(){return draw_name_.get_value_or(L"");} _CP_OPT(odf_types::hatch_style) draw_style_; _CP_OPT(int) draw_rotation_; @@ -254,11 +254,10 @@ public: private: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); - virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); - + virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); }; CP_REGISTER_OFFICE_ELEMENT2(draw_hatch); -///////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------ // style_draw_gradient class draw_opacity : public office_element_impl { @@ -275,20 +274,22 @@ public: _CP_OPT(odf_types::gradient_style) draw_style_;//linear, radial, .. _CP_OPT(odf_types::draw_angle) draw_angle_; - _CP_OPT(odf_types::percent) draw_start_; - _CP_OPT(odf_types::percent) draw_end_; + _CP_OPT(odf_types::percent) draw_start_; + _CP_OPT(odf_types::percent) draw_end_; - _CP_OPT(odf_types::percent) draw_border_; + _CP_OPT(odf_types::percent) draw_border_; _CP_OPT(std::wstring) draw_name_; _CP_OPT(std::wstring) draw_display_name_; + office_element_ptr_array content_; private: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); }; CP_REGISTER_OFFICE_ELEMENT2(draw_opacity); +//------------------------------------------------------------------------------------------------ // style_draw_fill_image class draw_fill_image : public office_element_impl @@ -312,7 +313,7 @@ private: virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); }; CP_REGISTER_OFFICE_ELEMENT2(draw_fill_image); -///////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------ class style; typedef shared_ptr