private void AddMapRunsForClientRun(IClientRun input, List <MapRun> runs, ref int ichLog, ref int ichRen) { TextClientRun textRun = input as TextClientRun; if (textRun == null) { // inserting a box! runs.Add(new MapRun(ichLog, input, ichRen, 0, 1)); ichLog++; ichRen++; return; } if (textRun.Length == 0 && textRun.Substitute != null) { runs.Add(new SubstituteMapRun(ichLog, textRun, ichRen, textRun.Substitute, textRun.SubstituteStyle)); ichRen += textRun.Substitute.Length; return; } int cRuns = textRun.UniformRunCount; Debug.Assert(cRuns > 0, "we can't replace a client run reliably if it has no uniform runs"); for (int irun = 0; irun < cRuns; irun++) { AddRunsForUniformRun(textRun, runs, ref ichLog, ref ichRen, irun); } }
internal void AddHookupToRun(TextClientRun run, LiteralStringParaHookup stringHookup) { run.Hookup = stringHookup; stringHookup.ClientRunIndex = stringHookup.ParaBox.Source.ClientRuns.IndexOf(run); if (CurrentHookup != null) { CurrentHookup.InsertChildHookup(run.Hookup, CurrentHookup.Children.Count); } }
private void AddRunsForUniformRun(TextClientRun textRun, List <MapRun> runs, ref int ichLog, ref int ichRen, int irun) { int offset = 0; string contents = textRun.UniformRunText(irun); int orcIndex = contents.IndexOf(orc); int len = textRun.UniformRunLength(irun); int fullLength = len; while (orcIndex >= 0) { // Make a run for the (possibly empty) text before the ORC len = fullLength - orcIndex - 1; runs.Add(new MapRun(ichLog, textRun, ichRen, offset, irun, orcIndex)); ichLog += orcIndex; ichRen += orcIndex; offset += orcIndex; // Make a run for the ORC itself. IClientRun orcRun = Interpreter(textRun, offset); TextClientRun textOrcRun = orcRun as TextClientRun; if (textOrcRun == null) { // interpreted as a box! Need to put the ORC run (the box) in as the contents of // the run. runs.Add(new OrcMapRun(ichLog, orcRun, ichRen, offset, irun, 1, orcRun)); ichRen++; } else { int renderLength = textOrcRun.UniformRunLength(0); // not yet supporting multi-run TextClientRuns for ORCs. runs.Add(new OrcMapRun(ichLog, textRun, ichRen, offset, irun, renderLength, orcRun)); Debug.Assert(textOrcRun.UniformRunCount == 1); ichRen += renderLength; } offset++; ichLog++; orcIndex = contents.IndexOf(orc, orcIndex + 1); } // Make a (possibly empty) run for any text left over (most commonly the whole contents) runs.Add(new MapRun(ichLog, textRun, ichRen, offset, irun, len)); ichLog += len; ichRen += len; offset += len; }
private ParaBox InsertParaOrRun(TextClientRun run) { var para = m_destination as ParaBox; if (para != null) { ((ParaBox)m_destination).InsertRun(m_insertRunAt, run); m_insertRunAt++; } else { var runs = new List <IClientRun>(); runs.Add(run); var source = new TextSource(runs); para = new ParaBox(m_destination.Style, source); InsertBox(para); } return(para); }
IClientRun MockInterpretOrc(TextClientRun run, int offset) { return(new StringClientRun(orcText, run.UniformRunStyles(0).WithWs(wsFrn))); }