_CP_OPT(std::wstring) settings_container::find_view_by_name(const std::wstring & name, int ind) { _CP_OPT(std::wstring) value; if (ind < 0 || ind >= impl_->views.size()) { boost::unordered_map<std::wstring, int>::const_iterator i = impl_->common_view.map_.find(name); if (i != impl_->common_view.map_.end()) { value = impl_->common_view.array_[i->second].value; } } else { boost::unordered_map<std::wstring, int>::const_iterator i = impl_->views[ind].map_.find(name); if (i != impl_->views[ind].map_.end()) { value = impl_->views[ind].array_[i->second].value; } else { return find_view_by_name(name); } } return value; }
_CP_OPT(length) GetConsistentBorderValue(const graphic_format_properties & graphicProperties, const border_style & borderStyle, BorderSide borderSide) { if ((borderStyle.get_style() == border_style::double_)) { _CP_OPT(border_widths) borderWidths = GetBorderLineWidths(graphicProperties, borderSide); if (borderWidths) return length(borderWidths->get_summ_unit( length::pt), length::pt); } else { if (borderStyle.initialized()) { if (borderStyle.is_none()) return _CP_OPT(length)(); else return borderStyle.get_length(); } } return _CP_OPT(length)(); }
int Compute_BorderWidth(const graphic_format_properties & graphicProperties, BorderSide borderSide) { _CP_OPT(border_style) borderValue; _CP_OPT(length) lengthValue; switch(borderSide) { case sideTop: borderValue = graphicProperties.common_border_attlist_.fo_border_top_; break; case sideBottom: borderValue = graphicProperties.common_border_attlist_.fo_border_bottom_; break; case sideLeft: borderValue = graphicProperties.common_border_attlist_.fo_border_left_; break; case sideRight: borderValue = graphicProperties.common_border_attlist_.fo_border_right_; break; } if (!borderValue) borderValue = graphicProperties.common_border_attlist_.fo_border_; if (borderValue) lengthValue = GetConsistentBorderValue(graphicProperties, *borderValue, borderSide); return get_value_emu(lengthValue); }
_CP_OPT(std::wstring) settings_container::find_by_name(const std::wstring & name) { _CP_OPT(std::wstring) value; boost::unordered_map<std::wstring, int>::const_iterator i = impl_->common.map_.find(name); if (i != impl_->common.map_.end()) { value = impl_->common.array_[i->second].value; } return value; }
void style_background_image::add_attributes( const xml::attributes_wc_ptr & Attributes ) { CP_APPLY_ATTR(L"style:repeat", style_repeat_); CP_APPLY_ATTR(L"style:position", style_position_); CP_APPLY_ATTR(L"filter:name", filter_name_); CP_APPLY_ATTR(L"draw:opacity", draw_opacity_); common_xlink_attlist tmp; if (tmp.add_attributes(Attributes)) { common_xlink_attlist_ = _CP_OPT(common_xlink_attlist)(tmp); } }
int GetMargin(const graphic_format_properties & graphicProperties, BorderSide borderSide)//emu { int margin = 0; _CP_OPT(length_or_percent) marginVal; switch(borderSide) { case sideTop: marginVal = graphicProperties.common_vertical_margin_attlist_.fo_margin_top_; break; case sideBottom: marginVal = graphicProperties.common_vertical_margin_attlist_.fo_margin_bottom_; break; case sideLeft: marginVal = graphicProperties.common_horizontal_margin_attlist_.fo_margin_left_; break; case sideRight: marginVal = graphicProperties.common_horizontal_margin_attlist_.fo_margin_right_; break; } if (marginVal && marginVal->get_type() == length_or_percent::Length) { margin = get_value_emu(marginVal->get_length()); } return margin; }
std::wstring odf_ref_name ; mediaitems()->add_or_find(file_name,_mediaitems::typeObjectReplacement, odf_ref_name); return odf_ref_name; } std::wstring odf_conversion_context::add_oleobject(const std::wstring & file_name) { if (file_name.empty()) return L""; std::wstring odf_ref_name ; mediaitems()->add_or_find(file_name,_mediaitems::typeOleObject, odf_ref_name); return odf_ref_name; } void odf_conversion_context::add_tab(_CP_OPT(int) type, _CP_OPT(length) _length, _CP_OPT(int) leader) { if (!temporary_.elm) return; office_element_ptr elm; create_element(L"style", L"tab-stop", elm, this, true); style_tab_stop* tab = dynamic_cast<style_tab_stop*>(elm.get()); if (tab) { if (_length) tab->style_position_ = length(_length->get_value_unit(length::cm), length::cm); if (type) { switch(*type)
style_table_properties *table_properties = office_table_style_->style_content_.get_style_table_properties(); if (table_properties == NULL)return; table_properties->table_format_properties_.common_writing_mode_attlist_.style_writing_mode_ = writing_mode(writing_mode::RlTb); } void ods_table_state::set_print_range(std::wstring range) { table_table* table = dynamic_cast<table_table*>(office_table_.get()); if (table == NULL)return; table->table_table_attlist_.table_print_ranges_ = range; } void ods_table_state::set_table_tab_color(_CP_OPT(color) & _color) { if (!office_table_style_)return; style_table_properties *table_properties = office_table_style_->style_content_.get_style_table_properties(); if (table_properties == NULL)return; table_properties->table_format_properties_.tableooo_tab_color_ = _color; } void ods_table_state::set_table_style(office_element_ptr & elm) { office_table_style_ = dynamic_cast<style*>(elm.get()); if (!office_table_style_)return;
size_t borderId(const odf_reader::style_table_cell_properties_attlist * cellProp, bool & is_default_val) { xlsx_border border; border.left = xlsx_border_edge(); border.right = xlsx_border_edge(); border.top = xlsx_border_edge(); border.bottom = xlsx_border_edge(); if (cellProp) { const common_border_attlist & odfBordersAttr = cellProp->common_border_attlist_; process_border(*border.left, odfBordersAttr.fo_border_); process_border(*border.right, odfBordersAttr.fo_border_); process_border(*border.top, odfBordersAttr.fo_border_); process_border(*border.bottom, odfBordersAttr.fo_border_); process_border(*border.left, odfBordersAttr.fo_border_left_); process_border(*border.right, odfBordersAttr.fo_border_right_); process_border(*border.top, odfBordersAttr.fo_border_top_); process_border(*border.bottom, odfBordersAttr.fo_border_bottom_); if (check_border(cellProp->style_diagonal_bl_tr_)) { border.diagonal = xlsx_border_edge(); _CP_OPT(border_style) borderStyle(*cellProp->style_diagonal_bl_tr_); process_border(*border.diagonal, borderStyle); border.diagonalUp = true; } if (check_border(cellProp->style_diagonal_tl_br_)) { if (!border.diagonal) border.diagonal = xlsx_border_edge(); _CP_OPT(border_style) borderStyle (*cellProp->style_diagonal_tl_br_); process_border(*border.diagonal, borderStyle); border.diagonalDown = true; } } if (is_default(border)) { is_default_val = true; return 0; } else { is_default_val = false; xlsx_borders_array::const_iterator i = borders_.find(border); if (i != borders_.end()) { return i->index; } else { border.index = borders_.size(); borders_.insert(border); //borders_.push_back(border); return border.index; } } }
//------------------------------------------------------------------------------------------- const wchar_t * draw_handle::ns = L"draw"; const wchar_t * draw_handle::name = L"handle"; void draw_handle::add_attributes( const xml::attributes_wc_ptr & Attributes ) { draw_handle_attlist_.add_attributes(Attributes); } const wchar_t * draw_equation::ns = L"draw"; const wchar_t * draw_equation::name = L"equation"; void draw_equation::add_attributes( const xml::attributes_wc_ptr & Attributes ) { draw_equation_attlist_.add_attributes(Attributes); } int draw_enhanced_geometry::parsing(_CP_OPT(std::wstring) val) { int pos = 0, res = -1; if (!val) return res; for (size_t i = 0; i < val->length(); i++) { if (val->at(i) < L'0' && val->at(i) > L'9') return res; } if ((pos = val->find(L"$"))>=0)return res; res = boost::lexical_cast<int>(val.get()); return res; }
void chart_build::oox_convert(oox::oox_chart_context & chart_context) { chart_context.set_title (title_); chart_context.set_wall (wall_); chart_context.set_floor (floor_); chart_context.set_legend (legend_); chart_context.set_plot_area_properties (plot_area_.properties_ , plot_area_.fill_); chart_context.set_chart_graphic_properties (chart_graphic_properties_ , chart_fill_); //chart_context.set_footer(footer_); //chart_context.set_chart_properties(chart_graphic_properties_); class_type last_set_type = chart_unknown; int series_id =0; if (series_.empty()) { chart_context.add_chart(class_); } BOOST_FOREACH(series & s, series_) { if (s.class_ != last_set_type) //разные типы серий в диаграмме - например бар и линия. { chart_context.add_chart(s.class_); last_set_type = s.class_; } oox::oox_chart_ptr current = chart_context.get_current_chart(); if (!current) continue; current->set_properties(plot_area_.properties_); current->set_additional_properties(chart_graphic_properties_); current->add_series(series_id++); if (s.cell_range_address_.empty() ) s.cell_range_address_ = plot_area_.cell_range_address_; //SplitByColumn (ind_ser,range); //SplitByRow (ind_ser,range); if (s.cell_range_address_.empty()) s.cell_range_address_ = domain_cell_range_adress2_; //тут данные нужно поделить по столбцам или строкам - так как в плот-ареа общий диапазон //первый столбец-строка МОЖЕт использоваться для подписей //каждая серия берет каждый последующий диапазрн //такое определение - редкость = todooo std::vector<std::wstring> domain_cash; std::vector<std::wstring> cell_cash; std::vector<std::wstring> cat_cash; calc_cache_series (domain_cell_range_adress_, domain_cash); calc_cache_series (s.cell_range_address_, cell_cash); if (categories_.size() >0) calc_cache_series (categories_[0], cat_cash); std::wstring formatCode = L"General"; _CP_OPT(std::wstring) strVal; _CP_OPT(bool) boolVal; odf_reader::GetProperty(s.properties_, L"num_format", strVal); odf_reader::GetProperty(s.properties_, L"link-data-style-to-source", boolVal); if ((strVal) && (strVal->length() > 1)) { formatCode = *strVal; } if (domain_cell_range_adress_.empty() == false) { if (last_set_type == chart_bubble) { //bubble(x) current->set_formula_series(4, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true)); current->set_values_series (4, domain_cash); //y current->set_formula_series(3, s.cell_range_address_, formatCode, boolVal.get_value_or(true)); current->set_values_series (3, cell_cash); } else { //x current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true)); current->set_values_series (2, domain_cash); //y current->set_formula_series(3, s.cell_range_address_, formatCode, boolVal.get_value_or(true)); current->set_values_series (3, cell_cash); } } else { //common current->set_formula_series(1, s.cell_range_address_, formatCode, boolVal.get_value_or(true)); current->set_values_series(1, cell_cash); } if (categories_.empty() == false)//названия { current->set_formula_series(0, categories_[0], L"General", true); current->set_values_series(0, cat_cash); } current->set_name(s.name_); current->set_content_series(s); } std::sort(axises_.begin(), axises_.end(), axises_sort());//file_1_ (1).odp bool x_enabled = false; bool y_enabled = false; bool z_enabled = false; for (int i = 0; i < axises_.size(); i++) { axis & a = axises_[i]; if (a.dimension_ == L"x" && x_enabled)continue; if (a.dimension_ == L"y" && y_enabled)continue; if (a.dimension_ == L"z" && z_enabled)continue; if (a.dimension_ == L"x")//могут быть типы 1, 2, 3, 4 { if (last_set_type == chart_scatter || last_set_type == chart_bubble) a.type_ = 2; if (class_ == chart_stock && a.type_ == 3 ) a.type_ = 4; //шкала дат. x_enabled = true; } else if (a.dimension_ == L"y") { a.type_ = 2; if (last_set_type == chart_bar) { //вот нахрена свойства относящиеся к серии и самому чарту воткнули в оси ???? (ооо писали идиеты???) //или это банальная ошибка которую так никогда и не исправили??? //overlap & gap-width oox::oox_chart_ptr current = chart_context.get_current_chart(); current->set_additional_properties(a.properties_); } y_enabled = true; } else if (a.dimension_ == L"z") { chart_context.set_3D_chart (true); continue; a.type_ = 2; z_enabled = true; } chart_context.add_axis(a.type_, a); } }
void paragraph_format_properties::add_attributes( const xml::attributes_wc_ptr & Attributes ) { // 15.5.1 CP_APPLY_ATTR(L"fo:line-height", fo_line_height_); // 15.5.2 CP_APPLY_ATTR(L"style:line-height-at-least", style_line_height_at_least_); // 15.5.3 CP_APPLY_ATTR(L"style:line-spacing", style_line_spacing_); // 15.5.4 CP_APPLY_ATTR(L"style:font-independent-line-spacing", style_font_independent_line_spacing_); // 15.5.5 CP_APPLY_ATTR(L"fo:text-align", fo_text_align_); // 15.5.6 CP_APPLY_ATTR(L"fo:text-align-last", fo_text_align_last_); // 15.5.7 CP_APPLY_ATTR(L"style:justify-single-word", style_justify_single_word_); // 15.5.8 CP_APPLY_ATTR(L"fo:keep-together", fo_keep_together_); // 15.5.9 CP_APPLY_ATTR(L"fo:widows", fo_widows_); // 15.5.10 CP_APPLY_ATTR(L"fo:orphans", fo_orphans_); // 15.5.11 - Element // 15.5.12 CP_APPLY_ATTR(L"style:tab-stop-distance", style_tab_stop_distance_); // 15.5.13 CP_APPLY_ATTR(L"fo:hyphenation-keep", fo_hyphenation_keep_); // 15.5.14 CP_APPLY_ATTR(L"fo:hyphenation-ladder-count", fo_hyphenation_ladder_count_); // 15.5.15 - Element // 15.5.16 CP_APPLY_ATTR(L"style:register-true", style_register_true_); // 15.5.17 CP_APPLY_ATTR(L"fo:margin-left", fo_margin_left_); // CP_APPLY_ATTR(L"fo:margin-right", fo_margin_right_); // 15.5.18 CP_APPLY_ATTR(L"fo:text-indent", fo_text_indent_); // 15.5.19 CP_APPLY_ATTR(L"style:auto-text-indent", style_auto_text_indent_); // 15.5.20 CP_APPLY_ATTR(L"fo:margin-top", fo_margin_top_); // CP_APPLY_ATTR(L"fo:margin-bottom", fo_margin_bottom_); // 15.5.21 CP_APPLY_ATTR(L"fo:margin", fo_margin_); // 15.5.22 CP_APPLY_ATTR(L"fo:break-before", fo_break_before_); // CP_APPLY_ATTR(L"fo:break-after", fo_break_after_); // 15.5.23 CP_APPLY_ATTR(L"fo:background-color", fo_background_color_); // 15.5.24 - Element // 15.5.25 CP_APPLY_ATTR(L"fo:border", fo_border_); // CP_APPLY_ATTR(L"fo:border-top", fo_border_top_); // CP_APPLY_ATTR(L"fo:border-bottom", fo_border_bottom_); // CP_APPLY_ATTR(L"fo:border-left", fo_border_left_); // CP_APPLY_ATTR(L"fo:border-right", fo_border_right_); // 15.5.26 // CP_APPLY_ATTR(L"style:border-line-width", style_border_line_width_); // CP_APPLY_ATTR(L"style:border-line-width-top", style_border_line_width_top_); // CP_APPLY_ATTR(L"style:border-line-width-bottom", style_border_line_width_bottom_); // CP_APPLY_ATTR(L"style:border-line-width-left", style_border_line_width_left_); // CP_APPLY_ATTR(L"style:border-line-width-right", style_border_line_width_right_); // 15.5.27 // CP_APPLY_ATTR(L"fo:padding", fo_padding_); // CP_APPLY_ATTR(L"fo:padding-top", fo_padding_top_); // CP_APPLY_ATTR(L"fo:padding-bottom", fo_padding_bottom_); // CP_APPLY_ATTR(L"fo:padding-left", fo_padding_left_); // CP_APPLY_ATTR(L"fo:padding-right", fo_padding_right_); // 15.5.28 CP_APPLY_ATTR(L"style:shadow", style_shadow_); // 15.5.29 CP_APPLY_ATTR(L"fo:keep-with-next", fo_keep_with_next_); // 15.5.30 CP_APPLY_ATTR(L"text:number-lines", text_number_lines_); // 15.5.31 CP_APPLY_ATTR(L"text:line-number", text_line_number_); // 15.5.32 CP_APPLY_ATTR(L"style:text-autospace", style_text_autospace_); // 15.5.33 CP_APPLY_ATTR(L"style:punctuation-wrap", style_punctuation_wrap_); // 15.5.34 CP_APPLY_ATTR(L"style:line-break", style_line_break_); // 15.5.35 CP_APPLY_ATTR(L"style:vertical-align", style_vertical_align_); // 15.5.36 CP_APPLY_ATTR(L"style:writing-mode", style_writing_mode_); // 15.5.37 CP_APPLY_ATTR(L"style:writing-mode-automatic", style_writing_mode_automatic_); // 15.5.38 CP_APPLY_ATTR(L"style:snap-to-layout-grid", style_snap_to_layout_grid_); // 15.5.39 _CP_OPT(std::wstring) style_page_number_str_; CP_APPLY_ATTR(L"style:page-number", style_page_number_str_); if (style_page_number_str_) { int res =0; if ((res=style_page_number_str_.get().find(L"auto"))<0) style_page_number_= boost::lexical_cast<int>(style_page_number_str_.get()); } // 15.5.40 CP_APPLY_ATTR(L"style:background-transparency", style_background_transparency_); CP_APPLY_ATTR(L"style:join_border", style_join_border_); }