/// ------------------------------------------------------------------------------------ /// <summary> /// Make the DispPropOverrides we need to give the specified run of characters the /// display properties defined by the initializer. /// </summary> /// <param name="para">The paragraph.</param> /// <param name="paraMinHighlight">The index (in logical characters, relative to /// para.Contents) of the first character whose properties will be overridden.</param> /// <param name="paraLimHighlight">The character "limit" (in logical characters, /// relative to para.Contents) of the text whose properties will be overridden.</param> /// <param name="initializer">A delegate that modifies the display props of characters /// between ichMin and ichLim.</param> /// ------------------------------------------------------------------------------------ protected void MakeDispPropOverrides(IScrTxtPara para, int paraMinHighlight, int paraLimHighlight, DispPropInitializer initializer) { if (paraLimHighlight < paraMinHighlight) { throw new ArgumentOutOfRangeException("paraLimHighlight", "ParaLimHighlight must be greater or equal to paraMinHighlight"); } int offsetToStartOfParaContents = 0; if (para.Owner is IScrFootnote && para.IndexInOwner == 0) { IScrFootnote footnote = (IScrFootnote)para.Owner; string sMarker = footnote.MarkerAsString; if (sMarker != null) { offsetToStartOfParaContents += sMarker.Length + OneSpaceString.Length; } offsetToStartOfParaContents += footnote.RefAsString.Length; } // Add the needed properties to each run, within our range ITsString tss = para.Contents; TsRunInfo runInfo; int ichOverrideLim; int ichOverrideMin = Math.Min(Math.Max(paraMinHighlight, 0), tss.Length); int prevLim = 0; do { tss.FetchRunInfoAt(ichOverrideMin, out runInfo); ichOverrideLim = Math.Min(paraLimHighlight, runInfo.ichLim); Debug.Assert(ichOverrideLim <= tss.Length, "If we get a run it should be in the bounds of the paragraph"); // Prevent infinite loop in case of bad data in difference if (ichOverrideLim == prevLim) { break; } prevLim = ichOverrideLim; DispPropOverride prop = DispPropOverrideFactory.Create( ichOverrideMin + offsetToStartOfParaContents, ichOverrideLim + offsetToStartOfParaContents); initializer(ref prop); m_DispPropOverrides.Add(prop); // advance Min for next run ichOverrideMin = ichOverrideLim; }while (ichOverrideLim < paraLimHighlight); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Make a (default) DispPropOverride that does nothing for the specified range of /// characters. /// </summary> /// <param name="ichOverrideMin">The index (in logical characters, relative to the /// paragraph as laid out in the view) of the first character whose properties will be /// overridden.</param> /// <param name="ichOverrideLim">The character "limit" (in logical characters, relative /// to the paragraph as laid out in the view) of the text whose properties will be /// overridden.</param> /// ------------------------------------------------------------------------------------ public static DispPropOverride Create(int ichOverrideMin, int ichOverrideLim) { DispPropOverride prop = new DispPropOverride(); unchecked { prop.chrp.clrBack = prop.chrp.clrFore = prop.chrp.clrUnder = (uint)FwTextPropConstants.knNinch; } prop.chrp.dympOffset = -1; prop.chrp.ssv = -1; prop.chrp.unt = -1; prop.chrp.ttvBold = -1; prop.chrp.ttvItalic = -1; prop.chrp.dympHeight = -1; prop.chrp.szFaceName = null; prop.chrp.szFontVar = null; prop.ichMin = ichOverrideMin; prop.ichLim = ichOverrideLim; return prop; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Make a (default) DispPropOverride that does nothing for the specified range of /// characters. /// </summary> /// <param name="ichOverrideMin">The index (in logical characters, relative to the /// paragraph as laid out in the view) of the first character whose properties will be /// overridden.</param> /// <param name="ichOverrideLim">The character "limit" (in logical characters, relative /// to the paragraph as laid out in the view) of the text whose properties will be /// overridden.</param> /// ------------------------------------------------------------------------------------ public static DispPropOverride Create(int ichOverrideMin, int ichOverrideLim) { DispPropOverride prop = new DispPropOverride(); unchecked { prop.chrp.clrBack = prop.chrp.clrFore = prop.chrp.clrUnder = (uint)FwTextPropConstants.knNinch; } prop.chrp.dympOffset = -1; prop.chrp.ssv = -1; prop.chrp.unt = -1; prop.chrp.ttvBold = -1; prop.chrp.ttvItalic = -1; prop.chrp.dympHeight = -1; prop.chrp.szFaceName = null; prop.chrp.szFontVar = null; prop.ichMin = ichOverrideMin; prop.ichLim = ichOverrideLim; return(prop); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the overrides to highlight a footnote diff. /// </summary> /// <param name="hvo">The hvo of the footnote paragraph.</param> /// ------------------------------------------------------------------------------------ private void AddOverridesToHighlightFootnoteDiff(int hvo) { Difference diff = FindSubDiffForFootnote(hvo); if (diff == null) return; StTxtPara para = new StTxtPara(Cache, hvo); // Get the footnote which contains the paragraph. int ownerHvo = para.OwnerHVO; Debug.Assert(m_cache.GetClassOfObject(ownerHvo) == StFootnote.kClassId); if (m_cache.GetClassOfObject(ownerHvo) != StFootnote.kClassId) return; //don't override the props for this para; continue on gracefully ScrFootnote footnote = new ScrFootnote(Cache, ownerHvo); // Only add offset to first paragraph in footnote (should only be one para) int offset = 0; if (footnote.ParagraphsOS[0].Hvo == hvo) { int refLength = footnote.GetReference(m_wsDefault).Length; int markerLength = footnote.FootnoteMarker.Length; //add one for the space in between (added in StVc) offset = refLength + markerLength + 1; } const uint knNinch = 0x80000000; // Now add appropriate properties. // Need to add override properties for each run in the // range to be highlighted. int ichOverrideMin = diff.GetIchMin(m_fRev); ITsString tss = para.Contents.UnderlyingTsString; TsRunInfo runInfo; int ichOverrideLim; int prevLim = 0; do { tss.FetchRunInfoAt(ichOverrideMin, out runInfo); ichOverrideLim = Math.Min(diff.GetIchLim(m_fRev), runInfo.ichLim); // Prevent infinite loop in case of bad data in difference if (ichOverrideLim == prevLim) break; prevLim = ichOverrideLim; DispPropOverride prop = new DispPropOverride(); prop.chrp.clrBack = DiffViewVc.kHighlightColor; prop.chrp.clrFore = knNinch; prop.chrp.clrUnder = knNinch; prop.chrp.dympOffset = -1; prop.chrp.ssv = -1; prop.chrp.unt = -1; prop.chrp.ttvBold = -1; prop.chrp.ttvItalic = -1; prop.chrp.dympHeight = -1; prop.chrp.szFaceName = null; prop.chrp.szFontVar = null; prop.ichMin = ichOverrideMin + offset; prop.ichLim = ichOverrideLim + offset; m_DispPropOverrides.Add(prop); ichOverrideMin = ichOverrideLim; } while (ichOverrideLim < diff.GetIchLim(m_fRev)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Nothing to do here. /// </summary> /// <param name="cOverrideProperties">cOverrideProperties</param> /// <param name="_rgOverrideProperties">_rgOverrideProperties</param> /// ------------------------------------------------------------------------------------ public void OpenOverridePara(int cOverrideProperties, DispPropOverride[] _rgOverrideProperties) { OpenFlowObject(); }
public void OpenOverridePara(int cOverrideProperties, DispPropOverride[] _rgOverrideProperties) { throw new NotImplementedException(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the overrides to highlight a footnote diff. /// </summary> /// <param name="hvo">The hvo of the footnote paragraph.</param> /// ------------------------------------------------------------------------------------ private void AddOverridesToHighlightFootnoteDiff(int hvo) { Difference diff = FindSubDiffForFootnote(hvo); if (diff == null) { return; } StTxtPara para = new StTxtPara(Cache, hvo); // Get the footnote which contains the paragraph. int ownerHvo = para.OwnerHVO; Debug.Assert(m_cache.GetClassOfObject(ownerHvo) == StFootnote.kClassId); if (m_cache.GetClassOfObject(ownerHvo) != StFootnote.kClassId) { return; //don't override the props for this para; continue on gracefully } ScrFootnote footnote = new ScrFootnote(Cache, ownerHvo); // Only add offset to first paragraph in footnote (should only be one para) int offset = 0; if (footnote.ParagraphsOS[0].Hvo == hvo) { int refLength = footnote.GetReference(m_wsDefault).Length; int markerLength = footnote.FootnoteMarker.Length; //add one for the space in between (added in StVc) offset = refLength + markerLength + 1; } const uint knNinch = 0x80000000; // Now add appropriate properties. // Need to add override properties for each run in the // range to be highlighted. int ichOverrideMin = diff.GetIchMin(m_fRev); ITsString tss = para.Contents.UnderlyingTsString; TsRunInfo runInfo; int ichOverrideLim; int prevLim = 0; do { tss.FetchRunInfoAt(ichOverrideMin, out runInfo); ichOverrideLim = Math.Min(diff.GetIchLim(m_fRev), runInfo.ichLim); // Prevent infinite loop in case of bad data in difference if (ichOverrideLim == prevLim) { break; } prevLim = ichOverrideLim; DispPropOverride prop = new DispPropOverride(); prop.chrp.clrBack = DiffViewVc.kHighlightColor; prop.chrp.clrFore = knNinch; prop.chrp.clrUnder = knNinch; prop.chrp.dympOffset = -1; prop.chrp.ssv = -1; prop.chrp.unt = -1; prop.chrp.ttvBold = -1; prop.chrp.ttvItalic = -1; prop.chrp.dympHeight = -1; prop.chrp.szFaceName = null; prop.chrp.szFontVar = null; prop.ichMin = ichOverrideMin + offset; prop.ichLim = ichOverrideLim + offset; m_DispPropOverrides.Add(prop); ichOverrideMin = ichOverrideLim; }while (ichOverrideLim < diff.GetIchLim(m_fRev)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Call virtual OpenParagraph /// </summary> /// <param name="cOverrideProperties">cOverrideProperties</param> /// <param name="_rgOverrideProperties">_rgOverrideProperties</param> /// ------------------------------------------------------------------------------------ public void OpenOverridePara(int cOverrideProperties, DispPropOverride[] _rgOverrideProperties) { OpenParagraph(); }
/// <summary> /// Make a (default) DispPropOverride that does nothing for the specified range of characters. /// </summary> /// <returns></returns> private DispPropOverride MakeDispPropOverride(int ichOverrideMin, int ichOverrideLim) { const uint knNinch = 0x80000000; DispPropOverride prop = new DispPropOverride(); prop.chrp.clrBack = knNinch; prop.chrp.clrFore = knNinch; prop.chrp.clrUnder = knNinch; prop.chrp.dympOffset = -1; prop.chrp.ssv = -1; prop.chrp.unt = -1; prop.chrp.ttvBold = -1; prop.chrp.ttvItalic = -1; prop.chrp.dympHeight = -1; prop.chrp.szFaceName = null; prop.chrp.szFontVar = null; prop.ichMin = ichOverrideMin; prop.ichLim = ichOverrideLim; return prop; }