예제 #1
0
파일: docx.cpp 프로젝트: davidgohel/rvg
static void docx_text(double x, double y, const char *str, double rot,
                     double hadj, const pGEcontext gc, pDevDesc dd) {
  DOCX_dev *docx_obj = (DOCX_dev*) dd->deviceSpecific;

  double fs = gc->cex * gc->ps;
  double w = docx_strwidth(str, gc, dd);
  double h = docx_strheight(str, gc, dd);
  if( fs*2 < 1.0 ) return;

  double corrected_offx = translate_rotate_x(x, y, rot, h, w, hadj) ;
  double corrected_offy = translate_rotate_y(x, y, rot, h, w, hadj) ;

  xfrm xfrm_(corrected_offx, corrected_offy, w, h, -rot );


  fputs("<wps:wsp>", docx_obj->file);
    write_nv_pr_docx(dd, "tx");
    fputs("<wps:spPr>", docx_obj->file);
      fprintf(docx_obj->file, "%s", xfrm_.xml().c_str());
      fprintf(docx_obj->file,"%s", a_prstgeom::a_tag("rect").c_str());
      fputs("<a:noFill/>", docx_obj->file);
    fputs("</wps:spPr>", docx_obj->file);
    write_text_body_docx(dd, gc, str, hadj, fs, h);
    fprintf(docx_obj->file, "%s", body_pr::wps_tag().c_str() );


  fputs("</wps:wsp>", docx_obj->file);
}
예제 #2
0
파일: xlsx.cpp 프로젝트: davidgohel/rvg
static void xlsx_text(double x, double y, const char *str, double rot,
                     double hadj, const pGEcontext gc, pDevDesc dd) {
  XLSX_dev *xlsx_obj = (XLSX_dev*) dd->deviceSpecific;

  double fs = gc->cex * gc->ps ;
  double w = xlsx_strwidth(str, gc, dd);
  double h = xlsx_strheight(str, gc, dd);
  if( fs*100 < 1.0 ) return;

  double corrected_offx = translate_rotate_x(x, y, rot, h, w, hadj) ;
  double corrected_offy = translate_rotate_y(x, y, rot, h, w, hadj) ;

  xfrm xfrm_(xlsx_obj->offx + corrected_offx, xlsx_obj->offy + corrected_offy, w, h, -rot );


  fputs("<xdr:sp>", xlsx_obj->file);
    write_nv_pr_xlsx(dd, "tx");
    fputs("<xdr:spPr>", xlsx_obj->file);
      fprintf(xlsx_obj->file, "%s", xfrm_.xml().c_str());
      fprintf(xlsx_obj->file,"%s", a_prstgeom::a_tag("rect").c_str());
      fputs("<a:noFill/>", xlsx_obj->file);
    fputs("</xdr:spPr>", xlsx_obj->file);

    write_text_body_xlsx(dd, gc, str, hadj, fs, h);
  fputs("</xdr:sp>", xlsx_obj->file);
}
예제 #3
0
파일: PPTX.cpp 프로젝트: agstudy/ReporteRs
static void PPTX_Text(double x, double y, const char *str, double rot,
		double hadj, const pGEcontext gc, pDevDesc dev) {

	DOCDesc *pd = (DOCDesc *) dev->deviceSpecific;
	int idx = get_and_increment_idx(dev);

	double w = PPTX_StrWidth(str, gc, dev);
	w = getStrWidth( str, w);
	double h = pd->fi->height[getFontface(gc->fontface)];
	double fs = getFontSize(gc->cex, gc->ps );
	if( h < 1.0 ) return;

	double corrected_offx = translate_rotate_x(x, y, rot, h, w, hadj) ;
	double corrected_offy = translate_rotate_y(x, y, rot, h, w, hadj) ;

	fputs(pptx_elt_tag_start, pd->dmlFilePointer );

	if( pd->editable < 1 )
		fprintf(pd->dmlFilePointer, "<p:nvSpPr><p:cNvPr id=\"%d\" name=\"Text %d\" />%s</p:nvSpPr>", idx, idx, pptx_lock_properties);
	else fprintf(pd->dmlFilePointer, "<p:nvSpPr><p:cNvPr id=\"%d\" name=\"Text %d\" />%s</p:nvSpPr>", idx, idx, pptx_unlock_properties);

	fputs("<p:spPr>", pd->dmlFilePointer );
	if( fabs( rot ) < 1 )
		fputs("<a:xfrm>", pd->dmlFilePointer);
	else fprintf(pd->dmlFilePointer, "<a:xfrm rot=\"%.0f\">", (-rot) * 60000);
	fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>", p2e_(pd->offx + corrected_offx), p2e_(pd->offy + corrected_offy));
	fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>", p2e_(w), p2e_(h));
	fputs("</a:xfrm>", pd->dmlFilePointer );
	fputs("<a:prstGeom prst=\"rect\"><a:avLst /></a:prstGeom>", pd->dmlFilePointer );
	fputs("<a:noFill />", pd->dmlFilePointer );
	fputs("</p:spPr>", pd->dmlFilePointer );

	fputs("<p:txBody>", pd->dmlFilePointer );
	fputs("<a:bodyPr lIns=\"0\" tIns=\"0\" rIns=\"0\" bIns=\"0\" anchor=\"b\">", pd->dmlFilePointer );
	//fputs("<a:spAutoFit />", pd->dmlFilePointer );
	fputs("</a:bodyPr><a:lstStyle /><a:p>", pd->dmlFilePointer );
	fputs("<a:pPr", pd->dmlFilePointer );

	if (hadj < 0.25)
		fputs(" algn=\"l\"", pd->dmlFilePointer );
	else if (hadj < 0.75)
		fputs(" algn=\"ctr\"", pd->dmlFilePointer );
	else
		fputs(" algn=\"r\"", pd->dmlFilePointer );
	fputs(" marL=\"0\" marR=\"0\" indent=\"0\" >", pd->dmlFilePointer );
	fprintf(pd->dmlFilePointer, "<a:lnSpc><a:spcPts val=\"%.0f\"/></a:lnSpc>", fs*100);
	fputs("<a:spcBef><a:spcPts val=\"0\"/></a:spcBef>", pd->dmlFilePointer );
	fputs("<a:spcAft><a:spcPts val=\"0\"/></a:spcAft>", pd->dmlFilePointer );

	fputs("</a:pPr>", pd->dmlFilePointer );
	fputs("<a:r>", pd->dmlFilePointer );
	fprintf(pd->dmlFilePointer, "<a:rPr sz=\"%.0f\"", fs*100);
	if (gc->fontface == 2) {
		fputs(" b=\"1\"", pd->dmlFilePointer );
	} else if (gc->fontface == 3) {
		fputs(" i=\"1\"", pd->dmlFilePointer );
	} else if (gc->fontface == 4) {
		fputs(" b=\"1\" i=\"1\"", pd->dmlFilePointer );
	}

	fputs(">", pd->dmlFilePointer );
	DML_SetFontColor(dev, gc);

	fprintf(pd->dmlFilePointer,
				"<a:latin typeface=\"%s\"/><a:cs typeface=\"%s\"/>",
				pd->fi->fontname, pd->fi->fontname);

	fputs("</a:rPr>", pd->dmlFilePointer );
	fputs("<a:t>", pd->dmlFilePointer );
	dml_text_native(str, pd);
	fputs("</a:t></a:r></a:p></p:txBody>", pd->dmlFilePointer );
	fputs(pptx_elt_tag_end, pd->dmlFilePointer );

	fflush(pd->dmlFilePointer);
}