// Token: 0x060069ED RID: 27117 RVA: 0x001E1F90 File Offset: 0x001E0190 internal bool PrepareForFiniteUpdate(PageBreakRecord breakRecord) { bool flag = !this.IsEmpty; if (this._section.StructuralCache != null) { if (this._section.StructuralCache.ForceReformat) { flag = false; this._section.InvalidateStructure(); this._section.StructuralCache.ClearUpdateInfo(this._section.StructuralCache.DestroyStructure); } else if (this._section.StructuralCache.DtrList != null) { this._section.InvalidateStructure(); if (!flag) { this._section.StructuralCache.ClearUpdateInfo(false); } } else { flag = false; this._section.StructuralCache.ClearUpdateInfo(false); } } return(flag); }
// Token: 0x06006835 RID: 26677 RVA: 0x001D5B40 File Offset: 0x001D3D40 internal PageBreakRecord FormatFinite(Size pageSize, Thickness pageMargin, PageBreakRecord breakRecord) { Invariant.Assert(!this.IsDisposed); this._formattedLinesCount = 0; TextDpi.EnsureValidPageSize(ref pageSize); TextDpi.EnsureValidPageMargin(ref pageMargin, pageSize); double num = PtsHelper.CalculatePageMarginAdjustment(this._structuralCache, pageSize.Width - (pageMargin.Left + pageMargin.Right)); if (!DoubleUtil.IsZero(num)) { pageMargin.Right += num - num / 100.0; } this._pageMargin = pageMargin; base.SetSize(pageSize); base.SetContentBox(new Rect(pageMargin.Left, pageMargin.Top, pageSize.Width - (pageMargin.Left + pageMargin.Right), pageSize.Height - (pageMargin.Top + pageMargin.Bottom))); using (this._structuralCache.SetDocumentFormatContext(this)) { this.OnBeforeFormatPage(); if (this._ptsPage.PrepareForFiniteUpdate(breakRecord)) { this._structuralCache.CurrentFormatContext.PushNewPageData(pageSize, this._pageMargin, true, true); this._ptsPage.UpdateFinitePage(breakRecord); } else { this._structuralCache.CurrentFormatContext.PushNewPageData(pageSize, this._pageMargin, false, true); this._ptsPage.CreateFinitePage(breakRecord); } this._structuralCache.CurrentFormatContext.PopPageData(); this.OnAfterFormatPage(); this._structuralCache.DetectInvalidOperation(); } return(this._ptsPage.BreakRecord); }
/// <summary> /// Updates entry of BreakRecordTable with new data. /// </summary> /// <param name="pageNumber">Index of the entry to update.</param> /// <param name="page">DocumentPage object that has been just created.</param> /// <param name="brOut">Output BreakRecord for created page.</param> /// <param name="dependentMax">Last content position that can affect the output break record.</param> internal void UpdateEntry(int pageNumber, FlowDocumentPage page, PageBreakRecord brOut, TextPointer dependentMax) { ITextView textView; BreakRecordTableEntry entry; bool isClean; Invariant.Assert(pageNumber >= 0 && pageNumber <= _breakRecords.Count, "The previous BreakRecord does not exist."); Invariant.Assert(page != null && page != DocumentPage.Missing, "Cannot update BRT with an invalid document page."); // Get TextView for DocumentPage. This TextView is used to access list of // content ranges. Those serve as optimalization in finding affeceted pages. textView = (ITextView)((IServiceProvider)page).GetService(typeof(ITextView)); Invariant.Assert(textView != null, "Cannot access ITextView for FlowDocumentPage."); // Get current state of BreakRecordTable isClean = this.IsClean; // Add new entry into BreakRecordTable entry = new BreakRecordTableEntry(); entry.BreakRecord = brOut; entry.DocumentPage = new WeakReference(page); entry.TextSegments = textView.TextSegments; entry.DependentMax = dependentMax; if (pageNumber == _breakRecords.Count) { _breakRecords.Add(entry); // Raise PaginationProgress event only if we did not have valid // entry for specified page number. _owner.OnPaginationProgress(pageNumber, 1); } else { // If old Page and/or BreakRecord are not changing, do not dispose them. if (_breakRecords[pageNumber].BreakRecord != null && _breakRecords[pageNumber].BreakRecord != entry.BreakRecord) { _breakRecords[pageNumber].BreakRecord.Dispose(); } if (_breakRecords[pageNumber].DocumentPage != null && _breakRecords[pageNumber].DocumentPage.Target != null && _breakRecords[pageNumber].DocumentPage.Target != entry.DocumentPage.Target) { ((FlowDocumentPage)_breakRecords[pageNumber].DocumentPage.Target).Dispose(); } _breakRecords[pageNumber] = entry; } // Raise PaginationCompleted event only if the BreakRecordTable just // become clean. if (!isClean && this.IsClean) { _owner.OnPaginationCompleted(); } }
// Token: 0x06006754 RID: 26452 RVA: 0x001CDFA8 File Offset: 0x001CC1A8 internal PageBreakRecord GetPageBreakRecord(int pageNumber) { PageBreakRecord pageBreakRecord = null; Invariant.Assert(pageNumber >= 0 && pageNumber <= this._breakRecords.Count, "Invalid PageNumber."); if (pageNumber > 0) { Invariant.Assert(this._breakRecords[pageNumber - 1] != null, "Invalid BreakRecordTable entry."); pageBreakRecord = this._breakRecords[pageNumber - 1].BreakRecord; Invariant.Assert(pageBreakRecord != null, "BreakRecord can be null only for the first page."); } return(pageBreakRecord); }
//------------------------------------------------------------------- // // Internal Methods // //------------------------------------------------------------------- #region Internal Methods /// <summary> /// Retrieves input BreakRecord for given PageNumber. /// </summary> /// <param name="pageNumber"> /// Page index indicating which input BreakRecord should be retrieved.</param> /// <returns>Input BreakRecord for given PageNumber.</returns> internal PageBreakRecord GetPageBreakRecord(int pageNumber) { PageBreakRecord breakRecord = null; Invariant.Assert(pageNumber >= 0 && pageNumber <= _breakRecords.Count, "Invalid PageNumber."); // Input BreakRecord for the first page is always NULL. // For the rest of pages, go to the entry preceding requested index and // return the output BreakRecord. if (pageNumber > 0) { Invariant.Assert(_breakRecords[pageNumber - 1] != null, "Invalid BreakRecordTable entry."); breakRecord = _breakRecords[pageNumber - 1].BreakRecord; Invariant.Assert(breakRecord != null, "BreakRecord can be null only for the first page."); } return(breakRecord); }
internal void CreateFinitePage(PageBreakRecord breakRecord) { this.OnBeforeFormatPage(true, false); if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace(TraceEventType.Start, TracePageFormatting.FormatPage, this.PageContext, this.PtsContext); } IntPtr pfsBRPageStart = (breakRecord != null) ? breakRecord.BreakRecord : IntPtr.Zero; PTS.FSFMTR fsfmtr; IntPtr value; IntPtr zero; int num = PTS.FsCreatePageFinite(this.PtsContext.Context, pfsBRPageStart, this._section.Handle, out fsfmtr, out value, out zero); if (num != 0) { this._ptsPage.Value = IntPtr.Zero; zero = IntPtr.Zero; PTS.ValidateAndTrace(num, this.PtsContext); } else { this._ptsPage.Value = value; } if (zero != IntPtr.Zero) { StructuralCache structuralCache = this._section.StructuralCache; if (structuralCache != null) { this._breakRecord = new PageBreakRecord(this.PtsContext, new SecurityCriticalDataForSet <IntPtr>(zero), (breakRecord != null) ? (breakRecord.PageNumber + 1) : 1); } } if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace(TraceEventType.Stop, TracePageFormatting.FormatPage, this.PageContext, this.PtsContext); } this.OnAfterFormatPage(true, false); }
internal void UpdateFinitePage(PageBreakRecord breakRecord) { if (this.IsEmpty) { return; } this.OnBeforeFormatPage(true, true); if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace(TraceEventType.Start, TracePageFormatting.FormatPage, this.PageContext, this.PtsContext); } IntPtr pfsBRPageStart = (breakRecord != null) ? breakRecord.BreakRecord : IntPtr.Zero; PTS.FSFMTR fsfmtr; IntPtr intPtr; int num = PTS.FsUpdateFinitePage(this.PtsContext.Context, this._ptsPage.Value, pfsBRPageStart, this._section.Handle, out fsfmtr, out intPtr); if (num != 0) { this.DestroyPage(); PTS.ValidateAndTrace(num, this.PtsContext); } if (intPtr != IntPtr.Zero) { StructuralCache structuralCache = this._section.StructuralCache; if (structuralCache != null) { this._breakRecord = new PageBreakRecord(this.PtsContext, new SecurityCriticalDataForSet <IntPtr>(intPtr), (breakRecord != null) ? (breakRecord.PageNumber + 1) : 1); } } if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace(TraceEventType.Stop, TracePageFormatting.FormatPage, this.PageContext, this.PtsContext); } this.OnAfterFormatPage(true, true); }
// Token: 0x0600675B RID: 26459 RVA: 0x001CE224 File Offset: 0x001CC424 internal void UpdateEntry(int pageNumber, FlowDocumentPage page, PageBreakRecord brOut, TextPointer dependentMax) { Invariant.Assert(pageNumber >= 0 && pageNumber <= this._breakRecords.Count, "The previous BreakRecord does not exist."); Invariant.Assert(page != null && page != DocumentPage.Missing, "Cannot update BRT with an invalid document page."); ITextView textView = (ITextView)((IServiceProvider)page).GetService(typeof(ITextView)); Invariant.Assert(textView != null, "Cannot access ITextView for FlowDocumentPage."); bool isClean = this.IsClean; BreakRecordTable.BreakRecordTableEntry breakRecordTableEntry = new BreakRecordTable.BreakRecordTableEntry(); breakRecordTableEntry.BreakRecord = brOut; breakRecordTableEntry.DocumentPage = new WeakReference(page); breakRecordTableEntry.TextSegments = textView.TextSegments; breakRecordTableEntry.DependentMax = dependentMax; if (pageNumber == this._breakRecords.Count) { this._breakRecords.Add(breakRecordTableEntry); this._owner.OnPaginationProgress(pageNumber, 1); } else { if (this._breakRecords[pageNumber].BreakRecord != null && this._breakRecords[pageNumber].BreakRecord != breakRecordTableEntry.BreakRecord) { this._breakRecords[pageNumber].BreakRecord.Dispose(); } if (this._breakRecords[pageNumber].DocumentPage != null && this._breakRecords[pageNumber].DocumentPage.Target != null && this._breakRecords[pageNumber].DocumentPage.Target != breakRecordTableEntry.DocumentPage.Target) { ((FlowDocumentPage)this._breakRecords[pageNumber].DocumentPage.Target).Dispose(); } this._breakRecords[pageNumber] = breakRecordTableEntry; } if (!isClean && this.IsClean) { this._owner.OnPaginationCompleted(); } }
internal void UpdateFinitePage(PageBreakRecord breakRecord) { if (IsEmpty) { return; } OnBeforeFormatPage(true, true); if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace( TraceEventType.Start, TracePageFormatting.FormatPage, PageContext, PtsContext); } // Retrieve PTS break record IntPtr brIn = (breakRecord != null) ? breakRecord.BreakRecord : IntPtr.Zero; // Create finite page and update layout size information PTS.FSFMTR formattingResult; IntPtr brOut; int fserr = PTS.FsUpdateFinitePage(PtsContext.Context, _ptsPage.Value, brIn, _section.Handle, out formattingResult, out brOut); if (fserr != PTS.fserrNone) { // Do inplace cleanup. DestroyPage(); // Generic error handling. PTS.ValidateAndTrace(fserr, PtsContext); } if (brOut != IntPtr.Zero) { StructuralCache structuralCache = _section.StructuralCache; if (structuralCache != null) { _breakRecord = new PageBreakRecord(PtsContext, new SecurityCriticalDataForSet<IntPtr>(brOut), (breakRecord != null) ? breakRecord.PageNumber + 1 : 1); } } if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace( TraceEventType.Stop, TracePageFormatting.FormatPage, PageContext, PtsContext); } OnAfterFormatPage(true, true); }
internal void CreateFinitePage(PageBreakRecord breakRecord) { OnBeforeFormatPage(true, false); if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace( TraceEventType.Start, TracePageFormatting.FormatPage, PageContext, PtsContext); } // Retrieve PTS break record IntPtr brIn = (breakRecord != null) ? breakRecord.BreakRecord : IntPtr.Zero; // Create finite page and update layout size information PTS.FSFMTR formattingResult; IntPtr brOut; IntPtr ptsPage; int fserr = PTS.FsCreatePageFinite(PtsContext.Context, brIn, _section.Handle, out formattingResult, out ptsPage, out brOut); if (fserr != PTS.fserrNone) { // Formatting failed and ptsPage may be set to a partially formatted page. Set value to IntPtr.Zero _ptsPage.Value = IntPtr.Zero; brOut = IntPtr.Zero; PTS.ValidateAndTrace(fserr, PtsContext); } else { _ptsPage.Value = ptsPage; } if (brOut != IntPtr.Zero) { StructuralCache structuralCache = _section.StructuralCache; if (structuralCache != null) { _breakRecord = new PageBreakRecord(PtsContext, new SecurityCriticalDataForSet<IntPtr>(brOut), (breakRecord != null) ? breakRecord.PageNumber + 1 : 1); } } if (TracePageFormatting.IsEnabled) { TracePageFormatting.Trace( TraceEventType.Stop, TracePageFormatting.FormatPage, PageContext, PtsContext); } OnAfterFormatPage(true, false); }
//------------------------------------------------------------------- // Prepare for incremental update process of a finite page. Finite // page incremental is always done by PTS as full format with change // delta exposed through queries. // Allow incremental update if there is a page previously created. // Before formatting needs to make sure that following is done: // a) If ForceReformat is true, clear entire NameTable (reformat needs to // start from the first page). // b) If there is existing DTR, invalidate NameTable from the firts position // stored in DTR list, then clear DTR list. // NOTE: If ForceReformat is false and DTR list is null, it means that // existing NameTable is in a valid state, and format can be done using // cached portion of the NameTable. // // breakRecord - PageBreakRecord describing start position of the page. // // Returns: 'true' if can do incremental update. //------------------------------------------------------------------- internal bool PrepareForFiniteUpdate(PageBreakRecord breakRecord) { bool canUpdate = !IsEmpty; #if DEBUG Debug.Assert(!canUpdate || _section.CanUpdate); #endif if (_section.StructuralCache != null) { // No update is possible when ForceReformat flag is set. // Clear update information and clear entire NameTable. if (_section.StructuralCache.ForceReformat) { canUpdate = false; Debug.Assert(breakRecord == null || !_section.StructuralCache.DestroyStructure, "Cannot format from dirty break record unless StructuralCache.DestroyStructure is not set."); _section.InvalidateStructure(); // Update structural cache info. The DestroyStructureCache parameter is set to true if // the name table is not preserved. If the name table is to be preserved, e.g. for highlight // changed, we do not clear structure cache _section.StructuralCache.ClearUpdateInfo(/*destroy structure cache:*/ _section.StructuralCache.DestroyStructure); } // If there is DRT list, invalidate entire NameTable starting from the // position of the first DTR. // Then clear update info, if incremental update is not possible. else if (_section.StructuralCache.DtrList != null) { _section.InvalidateStructure(); if (!canUpdate) { _section.StructuralCache.ClearUpdateInfo(false); } } // The NameTable is in a valid state, but cannot do incremental update, because // there is no DTR stored anymore. else { canUpdate = false; _section.StructuralCache.ClearUpdateInfo(false); } } return canUpdate; }
//------------------------------------------------------------------- // Format content into a single finite page. // // pageSize - size of the page // pageMargin - margin of the page // breakRecord - input BreakRecor for the page // // Returns: Returns output break record. //------------------------------------------------------------------- internal PageBreakRecord FormatFinite(Size pageSize, Thickness pageMargin, PageBreakRecord breakRecord) { Invariant.Assert(!IsDisposed); // Every time full format is done reset formatted lines count to 0. _formattedLinesCount = 0; // Make sure that PTS limitations are not exceeded. TextDpi.EnsureValidPageSize(ref pageSize); TextDpi.EnsureValidPageMargin(ref pageMargin, pageSize); double pageMarginAdjustment = PtsHelper.CalculatePageMarginAdjustment(_structuralCache, pageSize.Width - (pageMargin.Left + pageMargin.Right)); if (!DoubleUtil.IsZero(pageMarginAdjustment)) { // Potentially some FP drift here, as we're anticipating that our column count will now work out exactly. Add a small fraction back to prevent this pageMargin.Right += pageMarginAdjustment - (pageMarginAdjustment / 100.0); } _pageMargin = pageMargin; SetSize(pageSize); SetContentBox(new Rect(pageMargin.Left, pageMargin.Top, pageSize.Width - (pageMargin.Left + pageMargin.Right), pageSize.Height - (pageMargin.Top + pageMargin.Bottom))); using(_structuralCache.SetDocumentFormatContext(this)) { OnBeforeFormatPage(); if (_ptsPage.PrepareForFiniteUpdate(breakRecord)) { _structuralCache.CurrentFormatContext.PushNewPageData(pageSize, _pageMargin, true, true); _ptsPage.UpdateFinitePage(breakRecord); } else { _structuralCache.CurrentFormatContext.PushNewPageData(pageSize, _pageMargin, false, true); _ptsPage.CreateFinitePage(breakRecord); } _structuralCache.CurrentFormatContext.PopPageData(); OnAfterFormatPage(); _structuralCache.DetectInvalidOperation(); } return _ptsPage.BreakRecord; }