Ejemplo n.º 1
0
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));
			}
		}
	}
}
Ejemplo n.º 2
0
void draw_a::pptx_convert(oox::pptx_conversion_context & Context)
{
	Context.get_slide_context().start_action(L"");
		Context.get_slide_context().set_link(common_xlink_attlist_.href_.get_value_or(L""));
 	Context.get_slide_context().end_action();
  
	for (size_t i = 0; i < content_.size(); i++)
    {
        content_[i]->pptx_convert(Context);
    }
}
Ejemplo n.º 3
0
void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
{
    const double x = 8 * office_annotation_attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
    const double y = 8 * office_annotation_attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
 /////////////////////////////////
	std::wstring date;
	std::wstring author;
 	std::pair<int,int> id_idx;
	
	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_);
	}
	id_idx = Context.add_author_comments(author);

	Context.get_comments_context().start_comment(x, y,id_idx.first,id_idx.second);//author & idx (uniq number for author
	
	Context.get_text_context().start_comment_content();
	for (size_t i = 0; i < content_.size(); i++)//текст + текстовый стиль
    {
        content_[i]->pptx_convert(Context);
    }

	Context.get_comments_context().add_date(date);
	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"");

	Context.get_comments_context().end_comment();
}
Ejemplo n.º 4
0
void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
{
	if (object_type_ == 1) 
	{
		Context.start_chart(L"");
		oox::oox_chart_context & chart_context = Context.current_chart();
		
		oox_convert(chart_context);

		chart_context.set_cache_only(true);
		Context.end_chart();
	}
	else if (object_type_ == 2 && office_text_)
	{
		office_text_->pptx_convert(Context);
	}
	else if (object_type_ == 3 && office_math_)
	{
		office_math_->pptx_convert(Context);
	}
}
Ejemplo n.º 5
0
void presentation_placeholder::pptx_convert(oox::pptx_conversion_context & Context)
{
	double cx = svg_width_.get_value_or(length(0)).get_value_unit(length::pt);
	double cy = svg_height_.get_value_or(length(0)).get_value_unit(length::pt);

	//пока не понятно что значит отрицательная ширина ...
	cx = fabs(cx);
	cy = fabs(cy);
	
	double x = svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
	double y = svg_y_.get_value_or(length(0)).get_value_unit(length::pt);

	Context.get_slide_context().start_shape(2);//rect
	Context.get_slide_context().set_name(L"place_holder");

	Context.get_slide_context().set_rect(cx,cy,x,y);
	if (presentation_object_)
	{
		Context.get_slide_context().set_placeHolder_type(presentation_object_->get_type_ms());
	}

	Context.get_slide_context().end_shape();
}
Ejemplo n.º 6
0
void presentation_sound::pptx_convert(oox::pptx_conversion_context & Context)
{
	Context.get_slide_context().set_link(common_xlink_attlist_.href_.get_value_or(L""), oox::typeAudio);
}
Ejemplo n.º 7
0
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();

}
Ejemplo n.º 8
0
void draw_page::pptx_convert(oox::pptx_conversion_context & Context)
{
	const std::wstring pageStyleName	= draw_page_attr_.draw_style_name_.get_value_or(L"");
    const std::wstring pageName			= draw_page_attr_.draw_name_.get_value_or(L"");
    const std::wstring layoutName		= draw_page_attr_.page_layout_name_.get_value_or(L"");
    const std::wstring masterName		= draw_page_attr_.master_page_name_.get_value_or(L"");

    _CP_LOG << L"[info][xlsx] process page(slide) \"" << pageName /*L"" */<< L"\"" << std::endl;

    Context.start_page(pageName, pageStyleName, layoutName,masterName);

	if (draw_page_attr_.draw_style_name_)
	{
		style_instance * style_inst = Context.root()->odf_context().styleContainer().style_by_name(pageStyleName,style_family::DrawingPage,false);

		if ((style_inst) && (style_inst->content()))
		{
			const style_drawing_page_properties * properties = style_inst->content()->get_style_drawing_page_properties();

			if (properties)
			{				
				oox::_oox_fill fill;
				Compute_GraphicFill(properties->content().common_draw_fill_attlist_, office_element_ptr(), 
																	Context.root()->odf_context().drawStyles() ,fill);
				Context.get_slide_context().add_background(fill);
			
				//часть свойств переходов между слайдами тута
				
				if (properties->content().presentation_transition_type_)
				{
					if (properties->content().presentation_transition_type_.get() == L"automatic" || 
						properties->content().presentation_transition_type_.get() == L"semi-automatic")
					{
						Context.get_slide_context().set_transitionAction(false);
					}else
						Context.get_slide_context().set_transitionAction(true);//manual (default)
				}
				if (properties->content().presentation_transition_speed_)
				{
					Context.get_slide_context().set_transitionSpeed(properties->content().presentation_transition_speed_.get());
				}

	////////////////////////////////////////////////
				if ((properties->content().presentation_display_footer_) && (*properties->content().presentation_display_footer_))
					Context.get_slide_context().set_footer();
					
				if ((properties->content().presentation_display_header_) && (*properties->content().presentation_display_header_))
					Context.get_slide_context().set_header();			
				
				if ((properties->content().presentation_display_page_number_) && (*properties->content().presentation_display_page_number_))
					Context.get_slide_context().set_page_number();
				
				if ((properties->content().presentation_display_date_time_) && (*properties->content().presentation_display_date_time_))
					Context.get_slide_context().set_date_time();			
			}
		}
	}
	//сначала анимашки .. потому что объекты используют анимацию не нанапрямую (как бы ) а с общей кучи
	//animation_context на slide_context завести
	if (animation_)
	{
		animation_->pptx_convert(Context);
	}
/////////////////////////
	BOOST_FOREACH(const office_element_ptr& elm, content_)
    {
		elm->pptx_convert(Context);
	}