void RichTxt::RestoreFormat(int pi, const Formating& info, int& ii, const RichStyles& style) { Array<RichObject> dummy; while(ii < info.format.GetCount() && pi < GetPartCount()) { if(IsTable(pi)) { RichTable& tab = part[pi].Get<RichTable>(); for(int i = 0; i < tab.GetRows(); i++) for(int j = 0; j < tab.GetColumns(); j++) { if(tab(i, j)) { if(ii >= info.format.GetCount()) return; tab.InvalidateRefresh(i, j); tab[i][j].text.RestoreFormat(0, info, ii, style); } } pi++; } else { RichPara pa = Get(pi, style); RichPara pf; pf.Unpack(info.format[ii], dummy, GetStyle(style, info.styleid[ii]).format); RichPara t; t.format = pf.format; int si = 0; int sp = 0; for(int j = 0; j < pf.GetCount(); j++) { const RichPara::Part& q = pf[j]; for(int k = 0; k < q.text.GetLength(); k++) { int len = q.text[k] - 32; t.part.Add().format = q.format; while(len) { const RichPara::Part& p = pa[si]; if(p.IsText()) { int l = min(len, p.GetLength() - sp); t.part.Top().text.Cat(p.text.Mid(sp, l)); sp += l; len -= l; ASSERT(sp <= p.GetLength()); if(sp >= p.GetLength()) { sp = 0; si++; } } else { ASSERT(sp == 0); (t.part.Add() = pa[si++]).format = q.format; len--; sp = 0; } } } } ASSERT(si == pa.GetCount() && sp == 0); Put(pi, t, style); ii++; pi++; } } }