コード例 #1
0
ファイル: draw_shapes.cpp プロジェクト: ONLYOFFICE/core
void draw_line::reset_svg_attributes()
{
	double x1 = draw_line_attlist_.svg_x1_.get_value_or(length(0)).get_value_unit(length::pt);
	double y1 = draw_line_attlist_.svg_y1_.get_value_or(length(0)).get_value_unit(length::pt);
	double x2 = draw_line_attlist_.svg_x2_.get_value_or(length(0)).get_value_unit(length::pt);
	double y2 = draw_line_attlist_.svg_y2_.get_value_or(length(0)).get_value_unit(length::pt);
	
	if (x1 > x2)
	{
		common_draw_attlists_.position_.svg_x_	 = draw_line_attlist_.svg_x2_;
		common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(x1-x2, length::pt);
		
		additional_.push_back(_property(L"flipH",true));
	}else
	{
		common_draw_attlists_.position_.svg_x_	 = draw_line_attlist_.svg_x1_;
		common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(x2-x1, length::pt);
	}
	if (y1 > y2)
	{
		common_draw_attlists_.position_.svg_y_	 = draw_line_attlist_.svg_y2_;
		common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(y1-y2, length::pt);

		additional_.push_back(_property(L"flipV",true));
	}else
	{
		common_draw_attlists_.position_.svg_y_	 = draw_line_attlist_.svg_y1_;
		common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(y2-y1, length::pt);
	}
}
コード例 #2
0
ファイル: draw_common.cpp プロジェクト: ShockwaveNN/core
void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_context & Context)
{
	std::vector<std::wstring> transforms;
	
	boost::algorithm::split(transforms,transformStr, boost::algorithm::is_any_of(L")"), boost::algorithm::token_compress_on);
	
	for (size_t i = 0; i < transforms.size(); i++)
	{			
        //_CP_LOG << "[info] : transform = " << t << L"\n";
		std::vector<std::wstring> transform;
		boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);

		if (transform.size()>1)//тока с аргументами
		{
			int res=0;
			if ((res = transform[0].find(L"translate"))>=0)//перемещение
			{
				std::vector<length> Points ;
				parse_string_to_points(transform[1], Points);

				if (Points.size()>0)
				{
					double x_pt = Points[0].get_value_unit(length::pt);
					double y_pt = 0;
					if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть

					Context.get_slide_context().set_translate(x_pt,y_pt);
				}
			}
			else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
			{
				std::vector<length> Points ;
				parse_string_to_points(transform[1], Points);
				if (Points.size()>0)
				{
					double x_pt = Points[0].get_value_unit(length::pt);
					double y_pt = x_pt; 
					if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть

					Context.get_slide_context().set_scale(x_pt,y_pt);
				}
			}
			else if ((res = transform[0].find(L"rotate"))>=0)//вращение
			{
				Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]));
			}
			else if ((res = transform[0].find(L"skewX"))>=0)//вращение
			{
				double angle =  boost::lexical_cast<double>(transform[1]);
				Context.get_slide_context().set_property(_property(L"svg:skewX",angle));
			}
			else if ((res = transform[0].find(L"skewY"))>=0)//вращение
			{
				double angle =  boost::lexical_cast<double>(transform[1]);
				Context.get_slide_context().set_property(_property(L"svg:skewY",angle));
			}
		}
	}
}
コード例 #3
0
ファイル: draw_common.cpp プロジェクト: ShockwaveNN/core
void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional)
{
	std::vector<std::wstring> transforms;
	
	boost::algorithm::split(transforms,transformStr, boost::algorithm::is_any_of(L")"), boost::algorithm::token_compress_on);
	
	for (size_t i = 0; i < transforms.size(); i++)
	{			
        //_CP_LOG << "[info] : transform = " << t << L"\n";
		std::vector<std::wstring> transform;
		
		boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);
		
		if (transform.size() > 1)//тока с аргументами
		{
			int res=0;
			if ((res = transform[0].find(L"translate")) >= 0)	//перемещение
			{
				std::vector<length> Points ;
				parse_string_to_points(transform[1], Points);

				if (Points.size()>0)
				{
					double x_pt = Points[0].get_value_unit(length::pt);
					double y_pt = 0;
					
					if (Points.size()>1) y_pt = Points[1].get_value_unit(length::pt);	//ее может не быть

					//Context.get_drawing_context().set_translate(x_pt,y_pt);
					additional.push_back(_property(L"svg:translate_x", x_pt));
					additional.push_back(_property(L"svg:translate_y", y_pt));
				}
			}
			else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
			{
				std::vector<length> Points ;
				parse_string_to_points(transform[1], Points);
				if (Points.size()>0)
				{
					double x_pt = Points[0].get_value_unit(length::pt);
					double y_pt = x_pt; 
					if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть

					//Context.get_drawing_context().set_scale(x_pt,y_pt);
					additional.push_back(_property(L"svg:scale_x", x_pt));
					additional.push_back(_property(L"svg:scale_y", y_pt));
				}
			}
			else if ((res = transform[0].find(L"rotate"))>=0)//вращение
			{
				double angle =  boost::lexical_cast<double>(transform[1]);
				additional.push_back(_property(L"svg:rotate", angle));
			}
		}
	}
}
コード例 #4
0
ファイル: draw_page.cpp プロジェクト: alexandervnuchkov/core
void draw_page::pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, presentation_class::type PresentationClass)
{
	office_element_ptr elm = Context.root()->odf_context().drawStyles().find_by_style_name(styleName);
	//todooo если это элемент datatime -нужно вытащить формат поля

	if (!elm)return;

	int index=-1;

    const std::wstring masterName = draw_page_attr_.master_page_name_.get_value_or(L"");
	style_master_page * master = Context.root()->odf_context().pageLayoutContainer().master_page_by_name(masterName);

	if (master)
		index = master->find_placeHolderIndex(PresentationClass, Context.last_idx_placeHolder);


	Context.get_slide_context().start_shape(1);
	Context.get_slide_context().set_placeHolder_type(presentation_class(PresentationClass).get_type_ms());
	Context.get_slide_context().set_placeHolder_idx(index);
	
	Context.get_text_context().start_object();
	
	if (PresentationClass == presentation_class::date_time)
	{
		Context.get_text_context().start_field(oox::datetime, L"");
	}
	
	elm->pptx_convert(Context);
	
	std::wstring text_content_ = Context.get_text_context().end_object();

	if (text_content_.length()>0)
	{
		Context.get_slide_context().set_property(_property(L"text-content",text_content_));
	}
	Context.get_slide_context().set_property(_property(L"no_rect",true));
	Context.get_slide_context().end_shape();

}
コード例 #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 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;
    }
}
コード例 #8
0
void graphic_format_properties::apply_to(std::vector<_property> & properties)
{
	if (common_draw_fill_attlist_.draw_fill_color_)	properties.push_back(_property(L"fill-color",	common_draw_fill_attlist_.draw_fill_color_->get_hex_value() ));

	if (draw_stroke_)		properties.push_back(_property(L"stroke",		draw_stroke_->get_type() ));
	if (svg_stroke_color_)	properties.push_back(_property(L"stroke-color",	svg_stroke_color_->get_hex_value() ));
	if (draw_stroke_dash_)	properties.push_back(_property(L"stroke-dash",	draw_stroke_dash_.get()));
	if (svg_stroke_width_)	properties.push_back(_property(L"stroke-width",	svg_stroke_width_->get_length().get_value_unit(odf_types::length::pt) ));
	if (svg_stroke_opacity_)properties.push_back(_property(L"stroke-opacity",svg_stroke_opacity_->get_percent().get_value()));	
	if (draw_marker_start_)	properties.push_back(_property(L"marker-start",	draw_marker_start_->get() ));
	if (draw_marker_end_)	properties.push_back(_property(L"marker-end",	draw_marker_end_->get() ));
	
	if (draw_textarea_horizontal_align_)properties.push_back(_property(L"textarea-horizontal_align",draw_textarea_horizontal_align_->get_type() ));
	if (draw_textarea_vertical_align_)	properties.push_back(_property(L"textarea-vertical_align",	draw_textarea_vertical_align_->get_type() ));

	if (draw_auto_grow_height_)	properties.push_back(_property(L"auto-grow-height", *draw_auto_grow_height_));
	if (draw_auto_grow_width_)	properties.push_back(_property(L"auto-grow-width",	*draw_auto_grow_width_));
	if (draw_fit_to_size_)		properties.push_back(_property(L"fit-to-size",		*draw_fit_to_size_));
	if (draw_fit_to_contour_)	properties.push_back(_property(L"fit-to-contour",	*draw_fit_to_contour_));

	if (common_padding_attlist_.fo_padding_)
	{
		properties.push_back(_property(L"text-padding-left",	common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
		properties.push_back(_property(L"text-padding-right",	common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
		properties.push_back(_property(L"text-padding-top",		common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
		properties.push_back(_property(L"text-padding-bottom",	common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
	}else
	{
		if (common_padding_attlist_.fo_padding_left_) 
			properties.push_back(_property(L"text-padding-left",	common_padding_attlist_.fo_padding_left_->get_value_unit(length::emu)));
		if (common_padding_attlist_.fo_padding_right_) 
			properties.push_back(_property(L"text-padding-right",	common_padding_attlist_.fo_padding_right_->get_value_unit(length::emu)));
		if (common_padding_attlist_.fo_padding_top_) 
			properties.push_back(_property(L"text-padding-top",		common_padding_attlist_.fo_padding_top_->get_value_unit(length::emu)));
		if (common_padding_attlist_.fo_padding_bottom_) 
			properties.push_back(_property(L"text-padding-bottom",	common_padding_attlist_.fo_padding_bottom_->get_value_unit(length::emu)));
	}
	if (fo_wrap_option_)	
		properties.push_back(_property(L"text-wrap", (int)fo_wrap_option_->get_type()));
}
コード例 #9
0
ファイル: property.hpp プロジェクト: aldebaran/libqi
 ~ScopedLockReadWrite()
 {
   _property(_property._value); // Trigger update of the observer callbacks with the new value.
 }
コード例 #10
0
ファイル: draw_shapes_xlsx.cpp プロジェクト: ONLYOFFICE/core
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
		{
		}
	}
}