Пример #1
0
void draw_path::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	reset_svg_path();
///////////////////////////////////////////////////////////////////////
	Context.get_drawing_context().start_shape(6);

	common_xlsx_convert(Context);

	Context.get_drawing_context().end_shape();
	Context.get_drawing_context().clear();
}
Пример #2
0
void draw_line::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	Context.get_drawing_context().start_shape(5);
	
	reset_svg_attributes();
	
	common_xlsx_convert(Context);

	Context.get_drawing_context().end_shape();
	Context.get_drawing_context().clear();
}
Пример #3
0
void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	if (!control_id_) return;

	oox::forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
	if (state.id.empty()) return;

	if (state.ctrlPropId.empty())
	{
		std::wstring target;
		state.ctrlPropId = Context.get_mediaitems().add_control_props(target);
		
		std::wstringstream strm;		
		
		form_element* control = dynamic_cast<form_element*>(state.element);
		if (control)
		{
			control->serialize_control_props(strm);
		}

		Context.add_control_props(state.ctrlPropId, target, strm.str());
	}

	Context.get_drawing_context().start_frame();
	Context.get_drawing_context().set_control(state.ctrlPropId);
	
	common_xlsx_convert(Context);

	Context.get_drawing_context().end_frame();
	Context.get_drawing_context().clear();

}
Пример #4
0
void draw_object_ole::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	//временно - замещающая картинка(если она конечно присутствует)
	//Context.get_drawing_context().start_object_ole();

	Context.get_drawing_context().set_use_image_replacement();

	//Context.get_drawing_context().end_object_ole();
}
Пример #5
0
void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	Context.get_drawing_context().start_shape(2);//rect с наваротами
	Context.get_text_context().start_drawing_content();

	for (int i = 0 ; i < content_.size(); i++)
    {
		content_[i]->xlsx_convert(Context);
    }

	std::wstring text_content_ = Context.get_text_context().end_drawing_content();

	if (text_content_.length()>0)
	{
		Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
	}
    Context.get_drawing_context().end_shape();  
}
Пример #6
0
void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
{
    const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
    Context.get_drawing_context().start_image(href);
////////////////////////////////////в принципе достаточно общая часть ...
	Context.get_text_context().start_drawing_content();//...  если в объекте есть текст он привяжется к объекту - иначе к ячейке

	for (int i = 0 ; i < content_.size(); i++)
    {
		content_[i]->xlsx_convert(Context);
    }
	std::wstring text_content_ = Context.get_text_context().end_drawing_content();

	if (text_content_.length()>0)
	{
		Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
	}
////////////////////////////////////////////////////////////////////////////3 раза уже повторилась Content -> Context
    Context.get_drawing_context().end_image();
}
Пример #7
0
void chart_build::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	if (object_type_ == 1) 
	{
		Context.start_chart(L"");
		oox::oox_chart_context & chart = Context.current_chart();
		
		oox_convert(chart);

		Context.end_chart();
	}
	else if (object_type_ == 2 && office_text_)
	{
		office_text_->xlsx_convert(Context);
	}
	else if (object_type_ == 3 && office_math_)
	{
		office_math_->xlsx_convert(Context);
	}
}
Пример #8
0
void draw_connector::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	if (draw_connector_attlist_.draw_type_)
	{
		if (*draw_connector_attlist_.draw_type_ == L"curve")
		{
			sub_type_ = 11;
		}
	}
	reset_svg_attributes();	

	reset_svg_path();
///////////////////////////////////////////////////////////////////////
	Context.get_drawing_context().start_shape(6);

	common_xlsx_convert(Context);

	Context.get_drawing_context().end_shape();
	Context.get_drawing_context().clear();
}
Пример #9
0
void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
{
    try {
        const std::wstring href		= common_xlink_attlist_.href_.get_value_or(L"");

        odf_reader::odf_document * odf_reader = Context.root();
        
		std::wstring folderPath = odf_reader->get_folder();
        std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;

		// normalize path ???? todooo
		boost::algorithm::replace_all(objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);

        cpdoccore::odf_reader::odf_document objectSubDoc(objectPath,NULL);    
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//в отдельных embd объектах чаще всего диаграммы... но МОГУТ быть и обычные объекты подтипа frame!!! пример RemanejamentoOrcamentario.ods
///////////////////////////////////////////////////////////////////////////
//функциональная часть
		const office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
		chart_build objectBuild;
		
		if (contentSubDoc)
		{
			process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context());
			contentSubDoc->accept(process_build_object_); 
		}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//отображательная часть

		if (objectBuild.object_type_ == 1)//диаграмма
		{		
			const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
			objectBuild.xlsx_convert(Context);
			
			Context.get_drawing_context().start_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы 
			Context.get_drawing_context().end_chart();		
		}
		else if (objectBuild.object_type_ == 2)//текст (odt text)
		{
			Context.get_drawing_context().start_shape(2); 
			Context.get_text_context().start_drawing_content();

			//сменить контекст с главного на другой ... проблема со стилями!!
			Context.get_text_context().set_local_styles_container(&objectSubDoc.odf_context().styleContainer());

			objectBuild.xlsx_convert(Context);
			
			std::wstring text_content_ = Context.get_text_context().end_drawing_content();
			Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ...

			if (text_content_.length()>0)
			{
				Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
			}
			Context.get_drawing_context().end_shape();		
		}
		else
		{
			//временно - замещающая картинка(если она конечно присутствует)
			Context.get_drawing_context().set_use_image_replacement();
		}
	
	}
    catch(...)
    {
        _CP_LOG << "[error] : convert draw::object error" << std::endl;
    }
}
Пример #10
0
void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
{
    const _CP_OPT(length) svg_widthVal = office_annotation_attr_.svg_width_;
    
    const double width_cm = svg_widthVal.get_value_or(length(0)).get_value_unit(length::cm);
    const double width_pt = svg_widthVal.get_value_or(length(0)).get_value_unit(length::pt);
    
    const _CP_OPT(length) svg_heightVal =office_annotation_attr_.svg_height_;

    const double height_cm = svg_heightVal.get_value_or(length(0)).get_value_unit(length::cm);
    const double height_pt = svg_heightVal.get_value_or(length(0)).get_value_unit(length::pt);

    const double x_pt = office_annotation_attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
    const double y_pt = office_annotation_attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
 /////////////////////////////////
	std::wstring date;
 	std::wstring author;
	if (dc_date_)
	{
		date = xml::utils::replace_text_to_xml(dynamic_cast<dc_date * >(dc_date_.get())->content_);
	}
	if (dc_creator_)
	{
		author = xml::utils::replace_text_to_xml(dynamic_cast<dc_creator * >(dc_creator_.get())->content_);
	}
////////////////////////////////////////
	Context.get_comments_context().start_comment(width_pt, height_pt, x_pt, y_pt);
	if (office_annotation_attr_.display_)
	{
		Context.get_comments_context().set_visibly(office_annotation_attr_.display_.get());
	}  

	Context.get_text_context().start_comment_content();
	for (size_t i = 0; i < content_.size(); i++)//текст + текстовый стиль
    {
        content_[i]->xlsx_convert(Context);
    }
	Context.get_comments_context().add_author(author);
	Context.get_comments_context().add_content(Context.get_text_context().end_comment_content());
	

//////////////////////////////////////////////////////////////////
    /// Обрабатываем стиль draw
	std::vector<const odf_reader::style_instance *> instances;
	style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(
				office_annotation_attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
	if (styleInst)
	{
		style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
		if (defaultStyle)instances.push_back(defaultStyle);

		instances.push_back(styleInst);
	}
	graphic_format_properties graphicProperties = calc_graphic_properties_content(instances);	

	graphicProperties.apply_to(Context.get_comments_context().get_draw_properties());

	const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(L"");

	int col = Context.current_table_column();	if (col < 0) col = 0;
	int row = Context.current_table_row();		if (row < 0) row = 0;

	std::wstring  ref = oox::getCellAddress(col, row); 

	Context.get_comments_context().end_comment(ref, col, row);
}
Пример #11
0
void dr3d_sphere::xlsx_convert(oox::xlsx_conversion_context & Context)
{
	Context.get_drawing_context().start_shape(sub_type_); //reset type

}
Пример #12
0
void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context) 
{
	find_draw_type_oox();

	if (attlist_.draw_mirror_horizontal_)
	{
		Context.get_drawing_context().set_property(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
	}
	if (attlist_.draw_mirror_vertical_)
	{
		Context.get_drawing_context().set_property(_property(L"flipV", *attlist_.draw_mirror_vertical_));
	}
	if (draw_type_oox_index_)
	{
		Context.get_drawing_context().set_property(_property(L"oox-geom-index", draw_type_oox_index_.get()));	
		Context.get_drawing_context().set_property(_property(L"oox-geom", bOoxType_));	

		if (word_art_ == true)
			Context.get_drawing_context().set_property(_property(L"wordArt", true));	

	}
	if (sub_type_)
	{
		Context.get_drawing_context().start_shape(sub_type_.get());
	}

	std::wstring odf_path;
	if (attlist_.drawooo_enhanced_path_)
		odf_path = attlist_.drawooo_enhanced_path_.get();
	else if (attlist_.draw_enhanced_path_)
		odf_path = attlist_.draw_enhanced_path_.get();
	
	if (!odf_path.empty())
	{
		std::vector<::svg_path::_polyline> o_Polyline;
	
		bool res = false;
		bool bClosed = false;
		
		try
		{
			res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
		}
		catch(...)
		{
			res = false; 
		}
		//if (!bClosed) lined_shape_ = true;
		
		if (o_Polyline.size() > 1 && res )
		{
			//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
			std::wstringstream output_;   
            ::svg_path::oox_serialize(output_, o_Polyline);
			Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path", output_.str()));

			if (attlist_.drawooo_sub_view_size_)
			{
				std::vector< std::wstring > splitted;			    
				boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
				
				if (splitted.size() == 2)
				{
					int w = boost::lexical_cast<int>(splitted[0]);
					int h = boost::lexical_cast<int>(splitted[1]);
					
					Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path_w", w));
					Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path_h", h));
				}
				else if (splitted.size() == 4)
				{///???? rect ???
					int l = boost::lexical_cast<int>(splitted[0]);
					int t = boost::lexical_cast<int>(splitted[1]);
					int r = boost::lexical_cast<int>(splitted[2]);
					int b = boost::lexical_cast<int>(splitted[3]);

				}
			}
		}
		else if (!draw_type_oox_index_)
		{
			draw_type_oox_index_ = 0;
		}
	}
	if (attlist_.draw_modifiers_)
	{
		if (bOoxType_)
			Context.get_drawing_context().set_property(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));	
		else
		{
		}
	}
}