private FullTextBreakpoint( FullTextState fullText, int firstCharIndex, int maxLineWidth, ref LsBreaks lsbreaks, int breakIndex ) : this() { // According to antons: PTS only uses the width of a feasible break to avoid // clipping in subpage. At the moment, there is no good solution as of how // PTS client would be able to compute this width efficiently using LS. // The work around - although could be conceived would simply be too slow. // The width should therefore be set to the paragraph width for the time being. // // Client of text formatter would simply pass the value of TextBreakpoint.Width // back to PTS pfnFormatLineVariants call. LsLineWidths lineWidths = new LsLineWidths(); lineWidths.upLimLine = maxLineWidth; lineWidths.upStartMainText = fullText.TextStore.Settings.TextIndent; lineWidths.upStartMarker = lineWidths.upStartMainText; lineWidths.upStartTrailing = lineWidths.upLimLine; lineWidths.upMinStartTrailing = lineWidths.upStartTrailing; // construct the correspondent text metrics unsafe { _metrics.Compute( fullText, firstCharIndex, maxLineWidth, null, // collapsingSymbol ref lineWidths, &lsbreaks.plslinfoArray[breakIndex] ); _ploline = new SecurityCriticalDataForSet <IntPtr>(lsbreaks.pplolineArray[breakIndex]); // keep the line penalty handle _penaltyResource = new SecurityCriticalDataForSet <IntPtr>(lsbreaks.plinepenaltyArray[breakIndex]); if (lsbreaks.plslinfoArray[breakIndex].fForcedBreak != 0) { _isLineTruncated = true; } } }
internal LsErr CreateBreaks( int cpFirst, IntPtr previousLineBreakRecord, IntPtr ploparabreak, IntPtr ptslinevariantRestriction, ref LsBreaks lsbreaks, out int bestFitIndex ) { Invariant.Assert(_ploc.Value != System.IntPtr.Zero); return(UnsafeNativeMethods.LoCreateBreaks( _ploc.Value, cpFirst, previousLineBreakRecord, ploparabreak, ptslinevariantRestriction, ref lsbreaks, out bestFitIndex )); }
internal static IList <TextBreakpoint> CreateMultiple( TextParagraphCache paragraphCache, int firstCharIndex, int maxLineWidth, TextLineBreak previousLineBreak, IntPtr penaltyRestriction, out int bestFitIndex ) { Invariant.Assert(paragraphCache != null); // grab full text state from paragraph cache FullTextState fullText = paragraphCache.FullText; Invariant.Assert(fullText != null); FormatSettings settings = fullText.TextStore.Settings; Invariant.Assert(settings != null); // update formatting parameters at line start settings.UpdateSettingsForCurrentLine( maxLineWidth, previousLineBreak, (firstCharIndex == fullText.TextStore.CpFirst) ); Invariant.Assert(settings.Formatter != null); // acquiring LS context TextFormatterContext context = settings.Formatter.AcquireContext(fullText, IntPtr.Zero); IntPtr previousBreakRecord = IntPtr.Zero; if (settings.PreviousLineBreak != null) { previousBreakRecord = settings.PreviousLineBreak.BreakRecord.Value; } // need not consider marker as tab since marker does not affect line metrics and it wasnt drawn. fullText.SetTabs(context); LsBreaks lsbreaks = new LsBreaks(); LsErr lserr = context.CreateBreaks( fullText.GetBreakpointInternalCp(firstCharIndex), previousBreakRecord, paragraphCache.Ploparabreak.Value, // para breaking session penaltyRestriction, ref lsbreaks, out bestFitIndex ); // get the exception in context before it is released Exception callbackException = context.CallbackException; // release the context context.Release(); if (lserr != LsErr.None) { if (callbackException != null) { // rethrow exception thrown in callbacks throw callbackException; } else { // throw with LS error codes TextFormatterContext.ThrowExceptionFromLsError(SR.Get(SRID.CreateBreaksFailure, lserr), lserr); } } // keep context alive at least till here GC.KeepAlive(context); TextBreakpoint[] breakpoints = new TextBreakpoint[lsbreaks.cBreaks]; for (int i = 0; i < lsbreaks.cBreaks; i++) { breakpoints[i] = new FullTextBreakpoint( fullText, firstCharIndex, maxLineWidth, ref lsbreaks, i // the current break ); } return(breakpoints); }