odf_style_state::odf_style_state(office_element_ptr & elm, style_family::type family ) { odf_style_ = elm; automatic_ = false; default_ = false; conditional_ = false; num_fmt_id_ = 0; style_family_ = family; writable_ = true; style* style_ = dynamic_cast<style*>(elm.get()); if (style_) { style_->style_family_ = style_family(style_family_); style_->content_.style_family_ = style_family_; } default_style* default_style_ = dynamic_cast<default_style*>(elm.get()); if (default_style_) { default_style_->style_family_ = style_family(style_family_); default_style_->content_.style_family_ = style_family_; } list_style_exist = false; list_style_level = -1; list_style_id = -1; }
void odf_notes_context::start_note(office_element_ptr &elm, int oox_id, int type) { odf_note_state state; impl_->notes_.push_back(state); impl_->notes_.back().element = elm; impl_->notes_.back().oox_id = oox_id; impl_->notes_.back().odf_name = L"note_" + boost::lexical_cast<std::wstring>(oox_id); impl_->notes_.back().is_started = false; impl_->notes_.back().state = 1; impl_->notes_.back().type = type; text_note* note = dynamic_cast<text_note*>(elm.get()); if (!note)return; if (type == 1) note->text_note_class_ = odf_types::noteclass::Footnote; if (type == 2) note->text_note_class_ = odf_types::noteclass::Endnote; note->text_id_ = impl_->notes_.back().odf_name; note->create_child_element(L"text", L"note-citation"); text_note_citation* note_citation = dynamic_cast<text_note_citation*>(note->text_note_citation_.get()); if (note_citation) note_citation->add_text(boost::lexical_cast<std::wstring>(oox_id)); }
void odf_comment_context::end_comment(office_element_ptr &elm, int oox_id) { for (size_t i = 0; i < impl_->comments_.size(); i++) { if (impl_->comments_[i].oox_id == oox_id) { office_annotation_end* comm = dynamic_cast<office_annotation_end*>(elm.get()); if (!comm)return; comm->office_annotation_attr_.name_ = impl_->comments_[i].odf_name; impl_->comments_[i].state = 2;//stoped impl_->comments_[i].elements_.push_back(elm); return; } } }
void odf_comment_context::start_comment(office_element_ptr &elm, int oox_id) { odf_comment_state state; impl_->comments_.push_back(state); impl_->comments_.back().elements_.push_back(elm);//"0" - root comment eleemnt impl_->comments_.back().oox_id = oox_id < 0 ? impl_->comments_.back().elements_.size() : oox_id; impl_->comments_.back().odf_name = L"comment_" + boost::lexical_cast<std::wstring>(oox_id); impl_->comments_.back().is_started = false; impl_->comments_.back().state = 1; office_annotation* comm = dynamic_cast<office_annotation*>(elm.get()); if (!comm)return; comm->office_annotation_attr_.name_ = impl_->comments_.back().odf_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) { case 0: tab->style_type_ = style_type::Left; break;//tabjcBar = 0, case 1: tab->style_type_ = style_type::Center; break;//tabjcCenter = 1, case 2: tab->style_type_ = style_type::Left; break;//tabjcClear = 2, case 3: tab->style_type_ = style_type::Left; break;//tabjcDecimal = 3, case 4: tab->style_type_ = style_type::Right; break;//tabjcEnd = 4, case 5: tab->style_type_ = style_type::Left; break;//tabjcNum = 5,
void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_element_ptr & style_image, styles_lite_container &styles, oox::_oox_fill & fill, bool txbx) { if (fill.type < 1) fill.type = 0; if (props.draw_opacity_) { fill.opacity = props.draw_opacity_->get_value(); } if (props.draw_opacity_name_) { const std::wstring style_name = L"opacity:" + *props.draw_opacity_name_; if (office_element_ptr style = styles.find_by_style_name(style_name)) { if (draw_opacity * image_style = dynamic_cast<draw_opacity *>(style.get())) { //увы и ах но ms не поддерживает градиентную прозрачность - сделаем средненькую if (image_style->draw_start_ && image_style->draw_end_) { fill.opacity = (image_style->draw_start_->get_value() + image_style->draw_end_->get_value())/2.; } 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(); } } } if (props.draw_image_opacity_) fill.opacity = props.draw_image_opacity_->get_value(); //////////////////////////////////////////////////////////// if (props.draw_fill_color_) { fill.solid = oox::oox_solid_fill::create(); fill.solid->color = props.draw_fill_color_->get_hex_value(); if (fill.type == 0 && !txbx )fill.type = 1; //в этом случае тип может и не быть задан явно } if (props.draw_fill_image_name_) { const std::wstring style_name = L"bitmap:" + *props.draw_fill_image_name_; if (office_element_ptr style = styles.find_by_style_name(style_name)) { if (draw_fill_image * fill_image = dynamic_cast<draw_fill_image *>(style.get())) { fill.bitmap = oox::oox_bitmap_fill::create(); fill.bitmap->bTile = true; fill.bitmap->xlink_href_ = fill_image->xlink_attlist_.href_.get_value_or(L""); } } } if (style_image) { if (style_background_image * image = dynamic_cast<style_background_image *>(style_image.get())) { if ((image) && (image->common_xlink_attlist_)) { fill.type = 2; fill.bitmap = oox::oox_bitmap_fill::create(); fill.bitmap->xlink_href_ = image->common_xlink_attlist_->href_.get_value_or(L""); if (image->style_repeat_) { switch(image->style_repeat_->get_type()) { case style_repeat::Repeat : fill.bitmap->bTile = true; fill.bitmap->bStretch = false; break; case style_repeat::Stretch : fill.bitmap->bStretch = true; fill.bitmap->bTile = false; //?? для background точно выключать break; } } if (image->draw_opacity_) { fill.opacity = image->draw_opacity_->get_value(); } } } } if (fill.bitmap) { if (props.style_repeat_) { switch(props.style_repeat_->get_type()) { case style_repeat::Repeat : fill.bitmap->bTile = true; fill.bitmap->bStretch = false; break; case style_repeat::Stretch : fill.bitmap->bStretch = true; fill.bitmap->bTile = false; break; } } else { if (props.draw_fill_image_width_ && props.draw_fill_image_height_) { if (props.draw_fill_image_width_->get_type() == odf_types::length_or_percent::Percent && props.draw_fill_image_height_->get_type() == odf_types::length_or_percent::Percent) { if (props.draw_fill_image_width_->get_percent().get_value() > 99.9 && props.draw_fill_image_height_->get_percent().get_value() > 99.9 && props.draw_fill_image_width_->get_percent().get_value() < 100.1 && props.draw_fill_image_height_->get_percent().get_value() < 100.1 ) { fill.bitmap->bStretch = true; fill.bitmap->bTile = false; } } } } } if (props.draw_fill_gradient_name_) { 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<draw_gradient *>(style.get())) { fill.type = 3; fill.gradient = oox::oox_gradient_fill::create(); Compute_GradientFill(image_style, fill.gradient); } } } if (props.draw_fill_hatch_name_) { const std::wstring style_name = L"hatch:" + *props.draw_fill_hatch_name_; if (office_element_ptr style = styles.find_by_style_name(style_name)) { if (draw_hatch * image_style = dynamic_cast<draw_hatch *>(style.get())) { fill.type = 4; fill.hatch = oox::oox_hatch_fill::create(); Compute_HatchFill(image_style, fill.hatch); } } if ((fill.hatch) && (props.draw_fill_color_)) { fill.hatch->color_back_ref = props.draw_fill_color_->get_hex_value(); } } if (props.draw_fill_) { fill.type = props.draw_fill_->get_type(); } switch(fill.type) { case 1: if (!fill.solid) fill.type = -1; case 2: if (!fill.bitmap) { if (fill.solid) fill.type = 1; else fill.type = -1; } break; case 3: if (!fill.gradient) { fill.gradient = oox::oox_gradient_fill::create(); } break; case 4: if (!fill.hatch) { fill.hatch = oox::oox_hatch_fill::create(); } break; } }