internal LsErr GetAutoNumberInfo( IntPtr pols, // Line Layout context ref LsKAlign alignment, // [out] Marker alignment ref LsChp lschp, // [out] Marker properties ref IntPtr lsplsrun, // [out] Marker run ref ushort addedChar, // [out] Character to add after marker ref LsChp lschpAddedChar, // [out] Added character properties ref IntPtr lsplsrunAddedChar, // [out] Added character run ref int fWord95Model, // [out] true iff follow Word95 autonumbering model ref int offset, // [out] Offset from marker to start of main text (relevant iff word95Model is true) ref int width // [out] Offset from margin to start of main text (relevant iff word95Model is true) ) { LsErr lserr = LsErr.None; Plsrun plsrun = Plsrun.Undefined; LSRun lsrun = null; try { FullTextState fullTextState = FullText; TextStore markerStore = fullTextState.TextMarkerStore; TextStore store = fullTextState.TextStore; Debug.Assert(markerStore != null, "No marker store, yet autonumbering is specified!"); int lscp = TextStore.LscpFirstMarker; int lsrunLength; do { int lsrunOffset; lsrun = markerStore.FetchLSRun( lscp, fullTextState.TextFormattingMode, fullTextState.IsSideways, out plsrun, out lsrunOffset, out lsrunLength ); lscp += lsrunLength; } while (!TextStore.IsContent(plsrun)); alignment = LsKAlign.lskalRight; lschp = new LsChp(); lschp.idObj = (ushort)TextStore.ObjectId.Text_chp; SetChpFormat(lsrun.RunProp, ref lschp); addedChar = FullText.GetMainTextToMarkerIdealDistance() != 0 ? (ushort)'\t' : (ushort)0; lschpAddedChar = lschp; fWord95Model = 0; // Word95 model requires precise marker width in which we never have offset = 0; // marker offset is controlled by tab stop width = 0; lsplsrun = (IntPtr)plsrun; lsplsrunAddedChar = lsplsrun; } catch (Exception e) { SaveException(e, plsrun, lsrun); lserr = LsErr.ClientAbort; } catch { SaveNonCLSException("GetAutoNumberInfo", plsrun, lsrun); lserr = LsErr.ClientAbort; } return lserr; }
private void SetChpFormat( TextRunProperties runProp, ref LsChp lschp ) { SetChpFormat(runProp.TextDecorations, ref lschp); SetChpFormat(FullText.TextStore.Pap.TextDecorations, ref lschp); }
private void SetChpFormat( TextDecorationCollection textDecorations, ref LsChp lschp ) { if (textDecorations != null) { for (int i = 0; i < textDecorations.Count; i++) { switch (textDecorations[i].Location) { case TextDecorationLocation.Underline: lschp.flags |= LsChp.Flags.fUnderline; break; case TextDecorationLocation.OverLine: case TextDecorationLocation.Strikethrough: case TextDecorationLocation.Baseline: lschp.flags |= LsChp.Flags.fStrike; break; } } } }
internal unsafe LsErr FetchRunRedefined( IntPtr pols, // Line Layout context int lscpFetch, // position to fetch int fIsStyle, // flag indicates if pstyle is given IntPtr pstyle, // current demanded style char* pwchTextBuffer, // [in/out] fixed-size character buffer int cchTextBuffer, // buffer length in characters ref int fIsBufferUsed, // [out] Boolean flag indicating the fixed-size buffer is used out char* pwchText, // [out] pointer to run's character string ref int cchText, // [out] length of string ref int fIsHidden, // [out] Is this run hidden? ref LsChp lschp, // [out] run's character properties ref IntPtr lsplsrun // [out] fetched run ) { LsErr lserr = LsErr.None; pwchText = null; Plsrun plsrun = Plsrun.Undefined; LSRun lsrun = null; try { FullTextState fullTextState = FullText; TextStore store = fullTextState.StoreFrom(lscpFetch); int lsrunOffset; lsrun = store.FetchLSRun( lscpFetch, fullTextState.TextFormattingMode, fullTextState.IsSideways, out plsrun, out lsrunOffset, out cchText ); fIsBufferUsed = 0; pwchText = lsrun.CharacterBuffer.GetCharacterPointer(); if (pwchText == null) { if (cchText <= cchTextBuffer) { Invariant.Assert(pwchTextBuffer != null); int j = lsrun.OffsetToFirstChar + lsrunOffset; for (int i = 0; i < cchText; i++, j++) { pwchTextBuffer[i] = lsrun.CharacterBuffer[j]; } fIsBufferUsed = 1; } else { return LsErr.None; } } else { pwchText += lsrun.OffsetToFirstChar + lsrunOffset; } lschp = new LsChp(); fIsHidden = 0; switch (lsrun.Type) { case Plsrun.Reverse: lschp.idObj = (ushort)TextStore.ObjectId.Reverse; break; case Plsrun.FormatAnchor: case Plsrun.CloseAnchor: lschp.idObj = (ushort)TextStore.ObjectId.Text_chp; break; case Plsrun.InlineObject: lschp.idObj = (ushort)TextStore.ObjectId.InlineObject; SetChpFormat(lsrun.RunProp, ref lschp); break; case Plsrun.Hidden: lschp.idObj = (ushort)TextStore.ObjectId.Text_chp; fIsHidden = 1; break; case Plsrun.Text: { Debug.Assert(TextStore.IsContent(plsrun), "Unrecognizable run!"); Debug.Assert(lsrun.RunProp != null, "invalid lsrun!"); lschp.idObj = (ushort)TextStore.ObjectId.Text_chp; if ( lsrun.Shapeable != null && lsrun.Shapeable.IsShapingRequired) { lschp.flags |= LsChp.Flags.fGlyphBased; if (lsrun.Shapeable.NeedsMaxClusterSize) { lschp.dcpMaxContent = lsrun.Shapeable.MaxClusterSize; } } SetChpFormat(lsrun.RunProp, ref lschp); Invariant.Assert(!TextStore.IsNewline(lsrun.CharacterAttributeFlags)); break; } default : lschp.idObj = (ushort)TextStore.ObjectId.Text_chp; store.CchEol = lsrun.Length; break; } if ( lsrun.Type == Plsrun.Text || lsrun.Type == Plsrun.InlineObject) { Debug.Assert(lsrun.RunProp != null); if ( lsrun.RunProp != null && lsrun.RunProp.BaselineAlignment != BaselineAlignment.Baseline) { FullText.VerticalAdjust = true; } } lsplsrun = (IntPtr)plsrun; } catch (Exception e) { SaveException(e, plsrun, lsrun); lserr = LsErr.ClientAbort; } catch { SaveNonCLSException("FetchRunRedefined", plsrun, lsrun); lserr = LsErr.ClientAbort; } return lserr; }