//save disk data void saveData() { std::string strFile = save_file; std::string strHtml = strFile; strHtml.replace(strHtml.end()-3,strHtml.end(),"html"); std::ofstream outfile(strFile.c_str()); std::ofstream outhtml(strHtml.c_str()); outhtml<< "<body><p>" << std::endl; int count=0; for(auto iter = uosdata.begin(); iter != uosdata.end(); iter++) { count++; outfile<< iter->second << std::endl; std::string outputstr = iter->second; boost::algorithm::replace_all(outputstr,"\n","<br/>" ); outhtml<< "<br/>"<< outputstr << std::endl; //cout<<iter->first<<' '<<iter->second<<endl; } outfile<<"total "<<count <<std::endl; outhtml<<"total "<<count <<std::endl; outhtml<< "<br/> </body></p>" << std::endl; outfile.close(); outhtml.close(); if(count_>24*60*10) { uosdata.erase( uosdata.begin(), uosdata.end() ); count_=0;//如果有程序退出.保持一天的状态 } }
void startoutput(void) { char *align; double ps, vs, lm, rm, ti; Rune buf[200]; if(isoutput) return; isoutput = 1; if(getnr(L(".paragraph")) == 0) return; nr(L(".ns"), 0); isoutput = 1; ps = getnr(L(".s")); if(ps <= 1) ps = 10; ps /= 72.0; USED(ps); vs = getnr(L(".v"))*getnr(L(".ls")) * 1.0/UPI; vs /= (10.0/72.0); /* ps */ if(vs == 0) vs = 1.2; lm = (getnr(L(".o"))+getnr(L(".i"))) * 1.0/UPI; ti = getnr(L(".ti")) * 1.0/UPI; nr(L(".ti"), 0); rm = 8.0 - getnr(L(".l"))*1.0/UPI - getnr(L(".o"))*1.0/UPI; if(rm < 0) rm = 0; switch(getnr(L(".j"))){ default: case 0: align = "left"; break; case 1: align = "justify"; break; case 3: align = "center"; break; case 5: align = "right"; break; } if(getnr(L(".ce"))) align = "center"; if(!getnr(L(".margin"))) runesnprint(buf, nelem(buf), "<p style=\"line-height: %.1fem; text-indent: %.2fin; margin-top: 0; margin-bottom: 0; text-align: %s;\">\n", vs, ti, align); else runesnprint(buf, nelem(buf), "<p style=\"line-height: %.1fem; margin-left: %.2fin; text-indent: %.2fin; margin-right: %.2fin; margin-top: 0; margin-bottom: 0; text-align: %s;\">\n", vs, lm, ti, rm, align); outhtml(buf); }
void br(void) { if(!isoutput) return; isoutput = 0; nr(L(".dv"), 0); dv(0); hideihtml(); if(getnr(L(".paragraph"))) outhtml(L("</p>")); }
/* .sv - save a contiguous vertical block */ void sp(int v) { Rune buf[100]; double fv; br(); fv = v * 1.0/UPI; if(fv > 5) fv = eval(L("1v")) * 1.0/UPI; runesnprint(buf, nelem(buf), "<p style=\"margin-top: 0; margin-bottom: %.2fin\"></p>\n", fv); outhtml(buf); }