Beispiel #1
0
        internal PTS.FSFLRES GetFormatResultForBreakpoint(int dcp, TextBreakpoint textBreakpoint)
        {
            int dcpRun = 0;

            PTS.FSFLRES formatResult = PTS.FSFLRES.fsflrOutOfSpace;

            foreach (TextSpan <TextRun> textSpan in _runCache.GetTextRunSpans())
            {
                TextRun run = textSpan.Value;


                if (run != null && ((dcpRun + run.Length) >= (dcp + textBreakpoint.Length)))
                {
                    if (run is ParagraphBreakRun)
                    {
                        formatResult = ((ParagraphBreakRun)run).BreakReason;
                    }
                    else if (run is LineBreakRun)
                    {
                        formatResult = ((LineBreakRun)run).BreakReason;
                    }
                    break;
                }

                dcpRun += textSpan.Length;
            }

            return(formatResult);
        }
Beispiel #2
0
        // Token: 0x060068E9 RID: 26857 RVA: 0x001D9844 File Offset: 0x001D7A44
        internal PTS.FSFLRES GetFormatResultForBreakpoint(int dcp, TextBreakpoint textBreakpoint)
        {
            int num = 0;

            PTS.FSFLRES result = PTS.FSFLRES.fsflrOutOfSpace;
            foreach (TextSpan <TextRun> textSpan in this._runCache.GetTextRunSpans())
            {
                TextRun value = textSpan.Value;
                if (value != null && num + value.Length >= dcp + textBreakpoint.Length)
                {
                    if (value is ParagraphBreakRun)
                    {
                        result = ((ParagraphBreakRun)value).BreakReason;
                        break;
                    }
                    if (value is LineBreakRun)
                    {
                        result = ((LineBreakRun)value).BreakReason;
                        break;
                    }
                    break;
                }
                else
                {
                    num += textSpan.Length;
                }
            }
            return(result);
        }
 // ------------------------------------------------------------------
 // Constructor.
 //
 //      PtsContext - Context
 //      TextBreakpoint - Contained breakpoint
 // ------------------------------------------------------------------
 internal LineBreakpoint(OptimalBreakSession optimalBreakSession, TextBreakpoint textBreakpoint) : base(optimalBreakSession.PtsContext)
 {
     _textBreakpoint      = textBreakpoint;
     _optimalBreakSession = optimalBreakSession;
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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;
        }
Beispiel #6
0
 // ------------------------------------------------------------------
 // Constructor.
 //
 //      PtsContext - Context
 //      TextBreakpoint - Contained breakpoint
 // ------------------------------------------------------------------
 internal LineBreakpoint(OptimalBreakSession optimalBreakSession, TextBreakpoint textBreakpoint) : base(optimalBreakSession.PtsContext)
 {
     _textBreakpoint = textBreakpoint;
     _optimalBreakSession = optimalBreakSession;
 }
Beispiel #7
0
        internal PTS.FSFLRES GetFormatResultForBreakpoint(int dcp, TextBreakpoint textBreakpoint)
        {
            int dcpRun = 0;
            PTS.FSFLRES formatResult = PTS.FSFLRES.fsflrOutOfSpace;

            foreach (TextSpan<TextRun> textSpan in _runCache.GetTextRunSpans())
            {
                TextRun run = textSpan.Value;

                
                if (run != null && ((dcpRun + run.Length) >= (dcp + textBreakpoint.Length)))
                {
                    if (run is ParagraphBreakRun)
                    {
                        formatResult = ((ParagraphBreakRun)run).BreakReason;
                    }
                    else if (run is LineBreakRun)
                    {
                        formatResult = ((LineBreakRun)run).BreakReason;
                    }
                    break;
                }

                dcpRun += textSpan.Length;
            }

            return formatResult;
        }