示例#1
0
void RichEdit::InsertTable()
{
	if(IsSelection())
		return;
	WithCreateTableLayout<TopWindow> dlg;
	CtrlLayoutOKCancel(dlg, t_("Insert table"));
	dlg.header = false;
	dlg.columns <<= 2;
	dlg.columns.MinMax(1, 20);
	dlg.ActiveFocus(dlg.columns);
	if(dlg.Run() != IDOK)
		return;
	RichTable::Format fmt;
	int nx = minmax((int)~dlg.columns, 1, 20);
	for(int q = nx; q--;)
		fmt.column.Add(1);
	if(dlg.header)
		fmt.header = 1;
	RichTable table;
	table.SetFormat(fmt);
	for(int i = 0; i < (dlg.header ? 2 : 1); i++)
		for(int j = 0; j < nx; j++) {
			RichText h;
			h.SetStyles(text.GetStyles());
			RichPara p;
			p.format = formatinfo;
			p.format.newpage = false;
			p.format.label.Clear();
			h.Cat(p);
			table.SetPick(i, j, pick(h));
		}
	NextUndo();
	if(cursorp.posinpara)
		InsertLine();
	if(text.GetRichPos(cursor).paralen) {
		InsertLine();
		cursor = anchor = cursor - 1;
		begtabsel = false;
	}
	SaveFormat(cursor, 0);
	AddUndo(new UndoCreateTable(text.SetTable(cursor, table)));
	Finish();
}
示例#2
0
文件: ParseQtf.cpp 项目: koz4k/soccer
void RichQtfParser::FinishOldTable()
{
	FinishCell();
	Index<int>  pos;
	Vector<int> srow;
	RichTable& t = Table();
	Tab& b = table.Top();
	for(int i = 0; i < t.GetRows(); i++) {
		int& s = srow.Add();
		s = 0;
		int nx = b.rown[i];
		for(int j = 0; j < nx; j++)
			s += t.GetSpan(i, j).cx;
		int xn = 0;
		for(int j = 0; j < nx; j++) {
			pos.FindAdd(xn * 10000 / s);
			xn += t.GetSpan(i, j).cx;
		}
	}
	Vector<int> h = pos.PickKeys();
	if(h.GetCount() == 0)
		Error("table");
	Sort(h);
	pos = pick(h);
	pos.Add(10000);
	RichTable tab;
	tab.SetFormat(t.GetFormat());
	for(int i = 0; i < pos.GetCount() - 1; i++) {
		tab.AddColumn(pos[i + 1] - pos[i]);
	}
	for(int i = 0; i < t.GetRows(); i++) {
		int s = srow[i];
		int nx = b.rown[i];
		int xn = 0;
		int xi = 0;
		for(int j = 0; j < nx; j++) {
			Size span = t.GetSpan(i, j);
			xn += span.cx;
			int nxi = pos.Find(xn * 10000 / s);
			tab.SetPick(i, xi, t.GetPick(i, j));
			tab.SetFormat(i, xi, t.GetFormat(i, j));
			tab.SetSpan(i, xi, max(span.cy - 1, 0), nxi - xi - 1);
			xi = nxi;
		}
	}
	table.Drop();
	if(table.GetCount())
		table.Top().text.CatPick(pick(tab));
	else
		target.CatPick(pick(tab));
	oldtab = false;
}
示例#3
0
		void Old()                    { RichTable::Format fmt; fmt.grid = 10; table.SetFormat(fmt); }