Example #1
0
        // ------------------------------------------------------------------
        // Create new margin collapsing state and collapse margins if necessary.
        // If no collapsing happens, retrieve margin from old collapsing state.
        // This margin value should be used to advance pen.
        // ------------------------------------------------------------------
        internal static void CollapseTopMargin(
            PtsContext ptsContext,              // Current PTS Context.
            MbpInfo mbp,                        // MBP information for element entering the scope
            MarginCollapsingState mcsCurrent,   // current margin collapsing state (adjacent to the new one).
            out MarginCollapsingState mcsNew,   // margin collapsing state for element entering the scope
            out int margin)                     // collapsed margin value
        {
            margin = 0;
            mcsNew = null;

            // Create new margin collapsing info
            mcsNew = new MarginCollapsingState(ptsContext, mbp.MarginTop);
            // collapse margins, if current margin collapsing exists
            if (mcsCurrent != null)
            {
                mcsNew.Collapse(mcsCurrent);
            }

            // If border or paddind is specified:
            // (1) get collapsed margin value
            // (2) set new mcs to null, because we don't have one anymore
            if (mbp.BPTop != 0)
            {
                margin = mcsNew.Margin;
                mcsNew.Dispose();
                mcsNew = null;
            }
            else if (mcsCurrent == null && DoubleUtil.IsZero(mbp.Margin.Top))
            {
                // No need to create new margin collapsing info
                mcsNew.Dispose();
                mcsNew = null;
            }
        }
Example #2
0
        // ------------------------------------------------------------------
        // Update visuals for list of paragraphs.
        // ------------------------------------------------------------------
        internal static void UpdateParaListVisuals(
            PtsContext ptsContext,
            VisualCollection visualCollection,
            PTS.FSKUPDATE fskupdInherited,
            PTS.FSPARADESCRIPTION [] arrayParaDesc)
        {
            // For each paragraph, do following:
            // (1) Retrieve ParaClient object
            // (3) Update visual, if necessary
            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                // (2) Update visual, if necessary
                PTS.FSKUPDATE fskupd = arrayParaDesc[index].fsupdinf.fskupd;
                if (fskupd == PTS.FSKUPDATE.fskupdInherited)
                {
                    fskupd = fskupdInherited;
                }
                if (fskupd == PTS.FSKUPDATE.fskupdNew)
                {
                    // Disconnect visual from its old parent, if necessary.
                    Visual currentParent = VisualTreeHelper.GetParent(paraClient.Visual) as Visual;
                    if (currentParent != null)
                    {
                        ContainerVisual parent = currentParent as ContainerVisual;
                        Invariant.Assert(parent != null, "parent should always derives from ContainerVisual");
                        parent.Children.Remove(paraClient.Visual);
                    }

                    // New paragraph - insert new visual node
                    visualCollection.Insert(index, paraClient.Visual);

                    paraClient.ValidateVisual(fskupd);
                }
                else
                {
                    // Remove visuals for non-existing paragraphs
                    while (visualCollection[index] != paraClient.Visual)
                    {
                        visualCollection.RemoveAt(index);
                        Invariant.Assert(index < visualCollection.Count);
                    }

                    if (fskupd == PTS.FSKUPDATE.fskupdChangeInside || fskupd == PTS.FSKUPDATE.fskupdShifted)
                    {
                        paraClient.ValidateVisual(fskupd);
                    }
                }
            }
            // Remove obsolete visuals
            if (arrayParaDesc.Length < visualCollection.Count)
            {
                visualCollection.RemoveRange(arrayParaDesc.Length, visualCollection.Count - arrayParaDesc.Length);
            }
        }
Example #3
0
 // Token: 0x060068EB RID: 26859 RVA: 0x001D9960 File Offset: 0x001D7B60
 internal PageBreakRecord(PtsContext ptsContext, SecurityCriticalDataForSet <IntPtr> br, int pageNumber)
 {
     Invariant.Assert(ptsContext != null, "Invalid PtsContext object.");
     Invariant.Assert(br.Value != IntPtr.Zero, "Invalid break record object.");
     this._br         = br;
     this._pageNumber = pageNumber;
     this._ptsContext = new WeakReference(ptsContext);
     ptsContext.OnPageBreakRecordCreated(this._br);
 }
Example #4
0
 // Token: 0x06006932 RID: 26930 RVA: 0x001DC738 File Offset: 0x001DA938
 internal static void UpdateViewportParaList(PtsContext ptsContext, PTS.FSPARADESCRIPTION[] arrayParaDesc, ref PTS.FSRECT viewport)
 {
     for (int i = 0; i < arrayParaDesc.Length; i++)
     {
         BaseParaClient baseParaClient = ptsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient;
         PTS.ValidateHandle(baseParaClient);
         baseParaClient.UpdateViewport(ref viewport);
     }
 }
Example #5
0
        //-------------------------------------------------------------------
        //
        //  Internal Methods
        //
        //-------------------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Acquires new PTS Context and associates it with new owner.
        /// </summary>
        /// <param name="ptsContext">Context used to communicate with PTS component.</param>
        internal static PtsHost AcquireContext(PtsContext ptsContext, TextFormattingMode textFormattingMode)
        {
            PtsCache ptsCache = ptsContext.Dispatcher.PtsCache as PtsCache;
            if (ptsCache == null)
            {
                ptsCache = new PtsCache(ptsContext.Dispatcher);
                ptsContext.Dispatcher.PtsCache = ptsCache;
            }
            return ptsCache.AcquireContextCore(ptsContext, textFormattingMode);
        }
Example #6
0
        private unsafe void CreateSubpageBottomlessHelper(PtsContext ptsContext, IntPtr nSeg, int fSuppressTopSpace, uint fswdir, int lWidth, int urMargin, int durMargin, int vrMargin, int cColumns, PTS.FSCOLUMNINFO[] columnInfoCollection, out PTS.FSFMTRBL pfsfmtr, out IntPtr ppSubPage, out int pdvrUsed, out PTS.FSBBOX pfsBBox, out IntPtr pfsMcsClient, out int pTopSpace, out int fPageBecomesUninterruptible)
        {
            base.StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.MaxWidth), default(Thickness), false, false);
            fixed(PTS.FSCOLUMNINFO *ptr = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageBottomless(ptsContext.Context, nSeg, fSuppressTopSpace, fswdir, lWidth, urMargin, durMargin, vrMargin, cColumns, ptr, 0, null, null, 0, null, null, 0, out pfsfmtr, out ppSubPage, out pdvrUsed, out pfsBBox, out pfsMcsClient, out pTopSpace, out fPageBecomesUninterruptible), ptsContext);
            }

            base.StructuralCache.CurrentFormatContext.PopPageData();
        }
 /// <summary>
 /// Ensures the PtsContext exists.
 /// </summary>
 private void EnsurePtsContext()
 {
     if (_ptsContext == null)
     {
         TextFormattingMode textFormattingMode = TextOptions.GetTextFormattingMode(this.PropertyOwner);
         _ptsContext        = new PtsContext(true, textFormattingMode);
         _textFormatterHost = new TextFormatterHost(_ptsContext.TextFormatter, textFormattingMode);
         _section           = new MS.Internal.PtsHost.Section(this);
     }
 }
        private unsafe void CreateSubpageFiniteHelper(PtsContext ptsContext, IntPtr brParaIn, int fFromPreviousPage, IntPtr nSeg, IntPtr pFtnRej, int fEmptyOk, int fSuppressTopSpace, uint fswdir, int lWidth, int lHeight, ref PTS.FSRECT rcMargin, int cColumns, PTS.FSCOLUMNINFO[] columnInfoCollection, int fApplyColumnBalancing, out PTS.FSFMTR fsfmtr, out IntPtr pSubPage, out IntPtr brParaOut, out int dvrUsed, out PTS.FSBBOX fsBBox, out IntPtr pfsMcsClient, out int topSpace)
        {
            base.StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.FromTextDpi(lHeight)), default(Thickness), false, true);
            fixed(PTS.FSCOLUMNINFO *ptr = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageFinite(ptsContext.Context, brParaIn, fFromPreviousPage, nSeg, pFtnRej, fEmptyOk, fSuppressTopSpace, fswdir, lWidth, lHeight, ref rcMargin, cColumns, ptr, 0, 0, null, null, 0, null, null, 0, PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA.fsksuppresshardbreakbeforefirstparaNone, out fsfmtr, out pSubPage, out brParaOut, out dvrUsed, out fsBBox, out pfsMcsClient, out topSpace), ptsContext);
            }

            base.StructuralCache.CurrentFormatContext.PopPageData();
        }
Example #9
0
        internal static PtsHost AcquireContext(PtsContext ptsContext, TextFormattingMode textFormattingMode)
        {
            PtsCache ptsCache = ptsContext.Dispatcher.PtsCache as PtsCache;

            if (ptsCache == null)
            {
                ptsCache = new PtsCache(ptsContext.Dispatcher);
                ptsContext.Dispatcher.PtsCache = ptsCache;
            }
            return(ptsCache.AcquireContextCore(ptsContext, textFormattingMode));
        }
Example #10
0
        internal unsafe static void LineListCompositeFromTextPara(PtsContext ptsContext, IntPtr para, ref PTS.FSTEXTDETAILSFULL textDetails, out PTS.FSLINEDESCRIPTIONCOMPOSITE[] arrayLineDesc)
        {
            arrayLineDesc = new PTS.FSLINEDESCRIPTIONCOMPOSITE[textDetails.cLines];
            int num;

            fixed(PTS.FSLINEDESCRIPTIONCOMPOSITE *ptr = arrayLineDesc)
            {
                PTS.Validate(PTS.FsQueryLineListComposite(ptsContext.Context, para, textDetails.cLines, ptr, out num));
            }

            ErrorHandler.Assert(textDetails.cLines == num, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #11
0
        internal unsafe static void ParaListFromSubtrack(PtsContext ptsContext, IntPtr subtrack, ref PTS.FSSUBTRACKDETAILS subtrackDetails, out PTS.FSPARADESCRIPTION[] arrayParaDesc)
        {
            arrayParaDesc = new PTS.FSPARADESCRIPTION[subtrackDetails.cParas];
            int num;

            fixed(PTS.FSPARADESCRIPTION *ptr = arrayParaDesc)
            {
                PTS.Validate(PTS.FsQuerySubtrackParaList(ptsContext.Context, subtrack, subtrackDetails.cParas, ptr, out num));
            }

            ErrorHandler.Assert(subtrackDetails.cParas == num, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #12
0
        internal unsafe static void TrackListFromSubpage(PtsContext ptsContext, IntPtr subpage, ref PTS.FSSUBPAGEDETAILS subpageDetails, out PTS.FSTRACKDESCRIPTION[] arrayTrackDesc)
        {
            arrayTrackDesc = new PTS.FSTRACKDESCRIPTION[subpageDetails.u.complex.cBasicColumns];
            int num;

            fixed(PTS.FSTRACKDESCRIPTION *ptr = arrayTrackDesc)
            {
                PTS.Validate(PTS.FsQuerySubpageBasicColumnList(ptsContext.Context, subpage, subpageDetails.u.complex.cBasicColumns, ptr, out num));
            }

            ErrorHandler.Assert(subpageDetails.u.complex.cBasicColumns == num, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #13
0
        internal unsafe static void TrackListFromSection(PtsContext ptsContext, IntPtr section, ref PTS.FSSECTIONDETAILS sectionDetails, out PTS.FSTRACKDESCRIPTION[] arrayTrackDesc)
        {
            arrayTrackDesc = new PTS.FSTRACKDESCRIPTION[sectionDetails.u.withpagenotes.cBasicColumns];
            int num;

            fixed(PTS.FSTRACKDESCRIPTION *ptr = arrayTrackDesc)
            {
                PTS.Validate(PTS.FsQuerySectionBasicColumnList(ptsContext.Context, section, sectionDetails.u.withpagenotes.cBasicColumns, ptr, out num));
            }

            ErrorHandler.Assert(sectionDetails.u.withpagenotes.cBasicColumns == num, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #14
0
        internal unsafe static void AttachedObjectListFromParagraph(PtsContext ptsContext, IntPtr para, int cAttachedObject, out PTS.FSATTACHEDOBJECTDESCRIPTION[] arrayAttachedObjectDesc)
        {
            arrayAttachedObjectDesc = new PTS.FSATTACHEDOBJECTDESCRIPTION[cAttachedObject];
            int num;

            fixed(PTS.FSATTACHEDOBJECTDESCRIPTION *ptr = arrayAttachedObjectDesc)
            {
                PTS.Validate(PTS.FsQueryAttachedObjectList(ptsContext.Context, para, cAttachedObject, ptr, out num));
            }

            ErrorHandler.Assert(cAttachedObject == num, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #15
0
        internal unsafe static void SectionListFromPage(PtsContext ptsContext, IntPtr page, ref PTS.FSPAGEDETAILS pageDetails, out PTS.FSSECTIONDESCRIPTION[] arraySectionDesc)
        {
            arraySectionDesc = new PTS.FSSECTIONDESCRIPTION[pageDetails.u.complex.cSections];
            int num;

            fixed(PTS.FSSECTIONDESCRIPTION *ptr = arraySectionDesc)
            {
                PTS.Validate(PTS.FsQueryPageSectionList(ptsContext.Context, page, pageDetails.u.complex.cSections, ptr, out num));
            }

            ErrorHandler.Assert(pageDetails.u.complex.cSections == num, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #16
0
        internal unsafe static void LineElementListFromCompositeLine(PtsContext ptsContext, ref PTS.FSLINEDESCRIPTIONCOMPOSITE lineDesc, out PTS.FSLINEELEMENT[] arrayLineElement)
        {
            arrayLineElement = new PTS.FSLINEELEMENT[lineDesc.cElements];
            int num;

            fixed(PTS.FSLINEELEMENT *ptr = arrayLineElement)
            {
                PTS.Validate(PTS.FsQueryLineCompositeElementList(ptsContext.Context, lineDesc.pline, lineDesc.cElements, ptr, out num));
            }

            ErrorHandler.Assert(lineDesc.cElements == num, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #17
0
 private void Dispose(bool disposing)
 {
     if (Interlocked.CompareExchange(ref this._disposed, 1, 0) == 0)
     {
         PtsContext ptsContext = this._ptsContext.Target as PtsContext;
         if (ptsContext != null && !ptsContext.Disposed)
         {
             ptsContext.OnPageBreakRecordDisposed(this._br, disposing);
         }
         this._br.Value   = IntPtr.Zero;
         this._ptsContext = null;
     }
 }
Example #18
0
 internal static void ArrangeTrack(PtsContext ptsContext, ref PTS.FSTRACKDESCRIPTION trackDesc, uint fswdirTrack)
 {
     if (trackDesc.pfstrack != IntPtr.Zero)
     {
         PTS.FSTRACKDETAILS fstrackdetails;
         PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out fstrackdetails));
         if (fstrackdetails.cParas != 0)
         {
             PTS.FSPARADESCRIPTION[] arrayParaDesc;
             PtsHelper.ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref fstrackdetails, out arrayParaDesc);
             PtsHelper.ArrangeParaList(ptsContext, trackDesc.fsrc, arrayParaDesc, fswdirTrack);
         }
     }
 }
Example #19
0
 internal static void UpdateViewportTrack(PtsContext ptsContext, ref PTS.FSTRACKDESCRIPTION trackDesc, ref PTS.FSRECT viewport)
 {
     if (trackDesc.pfstrack != IntPtr.Zero)
     {
         PTS.FSTRACKDETAILS fstrackdetails;
         PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out fstrackdetails));
         if (fstrackdetails.cParas != 0)
         {
             PTS.FSPARADESCRIPTION[] arrayParaDesc;
             PtsHelper.ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref fstrackdetails, out arrayParaDesc);
             PtsHelper.UpdateViewportParaList(ptsContext, arrayParaDesc, ref viewport);
         }
     }
 }
Example #20
0
        // ------------------------------------------------------------------
        // Update viewport for para list
        // ------------------------------------------------------------------
        internal static void UpdateViewportParaList(
            PtsContext ptsContext,
            PTS.FSPARADESCRIPTION [] arrayParaDesc,
            ref PTS.FSRECT viewport)
        {
            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                paraClient.UpdateViewport(ref viewport);
            }
        }
Example #21
0
 private void ReleaseContextCore(PtsContext ptsContext)
 {
     lock (_lock)
     {
         if (_disposed == 0)
         {
             if (_releaseQueue == null)
             {
                 _releaseQueue = new List <PtsContext>();
                 ptsContext.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(OnPtsContextReleased), null);
             }
             _releaseQueue.Add(ptsContext);
         }
     }
 }
Example #22
0
        // Token: 0x06006934 RID: 26932 RVA: 0x001DC7DC File Offset: 0x001DA9DC
        internal static IInputElement InputHitTestParaList(PtsContext ptsContext, PTS.FSPOINT pt, ref PTS.FSRECT rcTrack, PTS.FSPARADESCRIPTION[] arrayParaDesc)
        {
            IInputElement inputElement = null;
            int           num          = 0;

            while (num < arrayParaDesc.Length && inputElement == null)
            {
                BaseParaClient baseParaClient = ptsContext.HandleToObject(arrayParaDesc[num].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(baseParaClient);
                if (baseParaClient.Rect.Contains(pt))
                {
                    inputElement = baseParaClient.InputHitTest(pt);
                }
                num++;
            }
            return(inputElement);
        }
        /// <summary>
        /// FormatCellBottomless
        /// </summary>
        /// <param name="fswdir">Text Direction</param>
        /// <param name="width">Width of cell (height is specified by row props)</param>
        /// <param name="fmtrbl">bottomless format result</param>
        /// <param name="dvrUsed">dvr Used</param>
        internal void FormatCellBottomless(uint fswdir, double width, out PTS.FSFMTRBL fmtrbl, out int dvrUsed)
        {
            IntPtr pfspara;

            PTS.FSBBOX fsbbox;
            IntPtr     pmcsclientOut;

            PTS.FSKCLEAR fskclearOut;
            int          dvrTopSpace;
            int          fPageBecomesUninterruptable;

            PTS.FSPAP fspap;


            if (CellParagraph.StructuralCache.DtrList != null)
            {
                CellParagraph.InvalidateStructure(TextContainerHelper.GetCPFromElement(CellParagraph.StructuralCache.TextContainer, CellParagraph.Element, ElementEdge.BeforeStart));
            }

            fspap = new PTS.FSPAP();
            CellParagraph.GetParaProperties(ref fspap);

            CellParagraph.FormatParaBottomless(this, PTS.FromBoolean(false),
                                               fswdir, 0, TextDpi.ToTextDpi(width),
                                               0, null, PTS.FSKCLEAR.fskclearNone,
                                               PTS.FromBoolean(true),
                                               out fmtrbl,
                                               out pfspara,
                                               out dvrUsed,
                                               out fsbbox,
                                               out pmcsclientOut,
                                               out fskclearOut,
                                               out dvrTopSpace,
                                               out fPageBecomesUninterruptable);

            if (pmcsclientOut != IntPtr.Zero)
            {
                MarginCollapsingState mcs = PtsContext.HandleToObject(pmcsclientOut) as MarginCollapsingState;
                PTS.ValidateHandle(mcs);
                dvrUsed += mcs.Margin;
                mcs.Dispose();
                pmcsclientOut = IntPtr.Zero;
            }

            _paraHandle.Value = pfspara;
        }
        // Token: 0x06006906 RID: 26886 RVA: 0x001DA3C0 File Offset: 0x001D85C0
        private void ReleaseContextCore(PtsContext ptsContext)
        {
            object @lock = this._lock;

            lock (@lock)
            {
                if (this._disposed == 0)
                {
                    if (this._releaseQueue == null)
                    {
                        this._releaseQueue = new List <PtsContext>();
                        ptsContext.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(this.OnPtsContextReleased), null);
                    }
                    this._releaseQueue.Add(ptsContext);
                }
            }
        }
Example #25
0
        internal static unsafe void LineListSimpleFromTextPara(
            PtsContext ptsContext,
            IntPtr para,
            ref PTS.FSTEXTDETAILSFULL textDetails,
            out PTS.FSLINEDESCRIPTIONSINGLE [] arrayLineDesc)
        {
            arrayLineDesc = new PTS.FSLINEDESCRIPTIONSINGLE [textDetails.cLines];
            int lineCount;

            fixed(PTS.FSLINEDESCRIPTIONSINGLE *rgLineDesc = arrayLineDesc)
            {
                PTS.Validate(PTS.FsQueryLineListSingle(ptsContext.Context, para, textDetails.cLines,
                                                       rgLineDesc, out lineCount));
            }

            ErrorHandler.Assert(textDetails.cLines == lineCount, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #26
0
        internal static unsafe void ParaListFromTrack(
            PtsContext ptsContext,
            IntPtr track,
            ref PTS.FSTRACKDETAILS trackDetails,
            out PTS.FSPARADESCRIPTION [] arrayParaDesc)
        {
            arrayParaDesc = new PTS.FSPARADESCRIPTION [trackDetails.cParas];
            int paraCount;

            fixed(PTS.FSPARADESCRIPTION *rgParaDesc = arrayParaDesc)
            {
                PTS.Validate(PTS.FsQueryTrackParaList(ptsContext.Context, track, trackDetails.cParas,
                                                      rgParaDesc, out paraCount));
            }

            ErrorHandler.Assert(trackDetails.cParas == paraCount, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #27
0
        internal static void UpdateTrackVisuals(
            PtsContext ptsContext,
            VisualCollection visualCollection,
            PTS.FSKUPDATE fskupdInherited,
            ref PTS.FSTRACKDESCRIPTION trackDesc)
        {
            PTS.FSKUPDATE fskupd = trackDesc.fsupdinf.fskupd;
            if (trackDesc.fsupdinf.fskupd == PTS.FSKUPDATE.fskupdInherited)
            {
                fskupd = fskupdInherited;
            }

            // If there is no change, visual information is valid
            if (fskupd == PTS.FSKUPDATE.fskupdNoChange)
            {
                return;
            }
            ErrorHandler.Assert(fskupd != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid);

            bool emptyTrack = (trackDesc.pfstrack == IntPtr.Zero);

            if (!emptyTrack)
            {
                // Get track details
                PTS.FSTRACKDETAILS trackDetails;
                PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out trackDetails));

                emptyTrack = (trackDetails.cParas == 0);
                if (!emptyTrack)
                {
                    // Get list of paragraphs
                    PTS.FSPARADESCRIPTION[] arrayParaDesc;
                    ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref trackDetails, out arrayParaDesc);

                    // Update visuals for list of paragraphs
                    UpdateParaListVisuals(ptsContext, visualCollection, fskupd, arrayParaDesc);
                }
            }

            // There is possibility to get empty track. (example: large figures)
            if (emptyTrack)
            {
                // There is no content, remove all existing children visuals.
                visualCollection.Clear();
            }
        }
        //-------------------------------------------------------------------
        //
        //  Constructors
        //
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ptsContext">Current PTS Context.</param>
        /// <param name="br">PTS page break record.</param>
        /// <param name="pageNumber">Page number.</param>
        internal PageBreakRecord(PtsContext ptsContext, SecurityCriticalDataForSet <IntPtr> br, int pageNumber)
        {
            Invariant.Assert(ptsContext != null, "Invalid PtsContext object.");
            Invariant.Assert(br.Value != IntPtr.Zero, "Invalid break record object.");

            _br         = br;
            _pageNumber = pageNumber;

            // In the finalizer we may need to reference an object instance
            // to do the right cleanup. For this reason store a WeakReference
            // to such object.
            _ptsContext = new WeakReference(ptsContext);

            // BreakRecord contains unmanaged resources that need to be released when
            // BreakRecord is destroyed or Dispatcher is closing. For this reason keep
            // track of this BreakRecord in PtsContext.
            ptsContext.OnPageBreakRecordCreated(_br);
        }
        //-------------------------------------------------------------------
        //
        //  Constructors
        //
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ptsContext">Current PTS Context.</param>
        /// <param name="br">PTS page break record.</param>
        /// <param name="pageNumber">Page number.</param>
        internal PageBreakRecord(PtsContext ptsContext, SecurityCriticalDataForSet<IntPtr> br, int pageNumber)
        {
            Invariant.Assert(ptsContext != null, "Invalid PtsContext object.");
            Invariant.Assert(br.Value != IntPtr.Zero, "Invalid break record object.");

            _br = br;
            _pageNumber = pageNumber;

            // In the finalizer we may need to reference an object instance
            // to do the right cleanup. For this reason store a WeakReference
            // to such object.
            _ptsContext = new WeakReference(ptsContext);

            // BreakRecord contains unmanaged resources that need to be released when
            // BreakRecord is destroyed or Dispatcher is closing. For this reason keep 
            // track of this BreakRecord in PtsContext. 
            ptsContext.OnPageBreakRecordCreated(_br);
        }
Example #30
0
        internal static IInputElement InputHitTestTrack(PtsContext ptsContext, PTS.FSPOINT pt, ref PTS.FSTRACKDESCRIPTION trackDesc)
        {
            if (trackDesc.pfstrack == IntPtr.Zero)
            {
                return(null);
            }
            IInputElement result = null;

            PTS.FSTRACKDETAILS fstrackdetails;
            PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out fstrackdetails));
            if (fstrackdetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                PtsHelper.ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref fstrackdetails, out arrayParaDesc);
                result = PtsHelper.InputHitTestParaList(ptsContext, pt, ref trackDesc.fsrc, arrayParaDesc);
            }
            return(result);
        }
Example #31
0
        internal static List <Rect> GetRectanglesInTrack(PtsContext ptsContext, ContentElement e, int start, int length, ref PTS.FSTRACKDESCRIPTION trackDesc)
        {
            List <Rect> result = new List <Rect>();

            if (trackDesc.pfstrack == IntPtr.Zero)
            {
                return(result);
            }
            PTS.FSTRACKDETAILS fstrackdetails;
            PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out fstrackdetails));
            if (fstrackdetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                PtsHelper.ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref fstrackdetails, out arrayParaDesc);
                result = PtsHelper.GetRectanglesInParaList(ptsContext, e, start, length, arrayParaDesc);
            }
            return(result);
        }
Example #32
0
        private unsafe void CreateSubpageFiniteHelper(
            PtsContext ptsContext,                   // IN:  ptr to FS context
            IntPtr brParaIn,                         // IN:  break record---use if !NULL
            int fFromPreviousPage,                   // IN:  break record was created on previous page
            IntPtr nSeg,                             // IN:  name of the segment to start from-if pointer to break rec is NULL
            IntPtr pFtnRej,                          // IN:  pftnrej
            int fEmptyOk,                            // IN:  fEmptyOK
            int fSuppressTopSpace,                   // IN:  fSuppressTopSpace
            uint fswdir,                             // IN:  fswdir
            int lWidth,                              // IN:  width of subpage
            int lHeight,                             // IN:  height of subpage
            ref PTS.FSRECT rcMargin,                 // IN:  rectangle within subpage margins
            int cColumns,                            // IN:  number of columns
            PTS.FSCOLUMNINFO[] columnInfoCollection, // IN:  array of column info
            int fApplyColumnBalancing,               // IN:  apply column balancing?
            PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA fsksuppresshardbreakbeforefirstparaIn,
            // IN: suppress breaks at track start?
            out PTS.FSFMTR fsfmtr,              // OUT: why formatting was stopped
            out IntPtr pSubPage,                // OUT: ptr to the subpage
            out IntPtr brParaOut,               // OUT: break record of the subpage
            out int dvrUsed,                    // OUT: dvrUsed
            out PTS.FSBBOX fsBBox,              // OUT: subpage bbox
            out IntPtr pfsMcsClient,            // OUT: margin collapsing state at the bottom
            out int topSpace)                   // OUT: top space due to collapsed margins
        {
            // Exceptions don't need to pop, as the top level measure context will be nulled out if thrown.
            StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.FromTextDpi(lHeight)),
                                                                 new Thickness(),
                                                                 false,
                                                                 true);

            fixed(PTS.FSCOLUMNINFO *rgColumnInfo = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageFinite(ptsContext.Context, brParaIn, fFromPreviousPage, nSeg,
                                                       pFtnRej, fEmptyOk, fSuppressTopSpace, fswdir, lWidth, lHeight,
                                                       ref rcMargin, cColumns, rgColumnInfo, PTS.False,
                                                       0, null, null, 0, null, null, PTS.False,
                                                       fsksuppresshardbreakbeforefirstparaIn,
                                                       out fsfmtr, out pSubPage, out brParaOut, out dvrUsed, out fsBBox, out pfsMcsClient, out topSpace), ptsContext);
            }

            StructuralCache.CurrentFormatContext.PopPageData();
        }
Example #33
0
        internal static TextContentRange TextContentRangeFromTrack(PtsContext ptsContext, IntPtr pfstrack)
        {
            PTS.FSTRACKDETAILS fstrackdetails;
            PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, pfstrack, out fstrackdetails));
            TextContentRange textContentRange = new TextContentRange();

            if (fstrackdetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] array;
                PtsHelper.ParaListFromTrack(ptsContext, pfstrack, ref fstrackdetails, out array);
                for (int i = 0; i < array.Length; i++)
                {
                    BaseParaClient baseParaClient = ptsContext.HandleToObject(array[i].pfsparaclient) as BaseParaClient;
                    PTS.ValidateHandle(baseParaClient);
                    textContentRange.Merge(baseParaClient.GetTextContentRange());
                }
            }
            return(textContentRange);
        }
Example #34
0
        // ------------------------------------------------------------------
        // Update current margin collapsing state and collapse margins if 
        // necessary. If no collapsing happens, retrieve margin from previous 
        // collapsing state. This margin value should be used to advance pen.
        // ------------------------------------------------------------------
        internal static void CollapseBottomMargin(
            PtsContext ptsContext,              // Current PTS Context.
            MbpInfo mbp,                        // MBP information for element leaving the scope
            MarginCollapsingState mcsCurrent,   // current margin collapsing state (adjacent to the new one).
            out MarginCollapsingState mcsNew,   // margin collapsing state for element leaving the scope
            out int margin)                     // collapsed margin value
        {
            margin = 0;
            mcsNew = null;

            // Create new margin collapsing state, if necessary
            if (!DoubleUtil.IsZero(mbp.Margin.Bottom))
            {
                mcsNew = new MarginCollapsingState(ptsContext, mbp.MarginBottom);
            }

            // If the current margin collapsing state does not exist, we are done.
            // Otherwise, get current border and padding and decide if to collapse margin.
            if (mcsCurrent != null)
            {
                if (mbp.BPBottom != 0)
                {
                    // No collapsing happens, get margin value
                    margin = mcsCurrent.Margin;
                }
                else
                {
                    // Collapse margins
                    if (mcsNew == null)
                    {
                        mcsNew = new MarginCollapsingState(ptsContext, 0);
                    }
                    mcsNew.Collapse(mcsCurrent);
                }
            }
        }
Example #35
0
 internal static unsafe void LineElementListFromCompositeLine(
     PtsContext ptsContext,
     ref PTS.FSLINEDESCRIPTIONCOMPOSITE lineDesc,
     out PTS.FSLINEELEMENT [] arrayLineElement)
 {
     arrayLineElement = new PTS.FSLINEELEMENT [lineDesc.cElements];
     int lineElementCount;
     fixed (PTS.FSLINEELEMENT* rgLineElement = arrayLineElement)
     {
         PTS.Validate(PTS.FsQueryLineCompositeElementList(ptsContext.Context, lineDesc.pline, lineDesc.cElements,
             rgLineElement, out lineElementCount));
     }
     ErrorHandler.Assert(lineDesc.cElements == lineElementCount, ErrorHandler.PTSObjectsCountMismatch);
 }
Example #36
0
        internal static void ArrangeParaList(
            PtsContext ptsContext,
            PTS.FSRECT rcTrackContent,
            PTS.FSPARADESCRIPTION [] arrayParaDesc,
            uint fswdirTrack)
        {
            // For each paragraph, do following:
            // (1) Retrieve ParaClient object
            // (2) Arrange and update paragraph metrics
            int dvrPara = 0;
            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                // Convert to appropriate page coordinates.
                if(index == 0)
                {
                    uint fswdirPage = PTS.FlowDirectionToFswdir(paraClient.PageFlowDirection);

                    if(fswdirTrack != fswdirPage)
                    {
                        PTS.FSRECT pageRect = paraClient.Paragraph.StructuralCache.CurrentArrangeContext.PageContext.PageRect;
                        PTS.Validate(PTS.FsTransformRectangle(fswdirTrack, ref pageRect, ref rcTrackContent, fswdirPage, out rcTrackContent));
                    }
                }

                // (2) Arrange and update paragraph metrics
                int dvrTopSpace = arrayParaDesc[index].dvrTopSpace;
                PTS.FSRECT rcPara = rcTrackContent;
                rcPara.v += dvrPara + dvrTopSpace;
                rcPara.dv = arrayParaDesc[index].dvrUsed - dvrTopSpace;

                paraClient.Arrange(arrayParaDesc[index].pfspara, rcPara, dvrTopSpace, fswdirTrack);
                dvrPara += arrayParaDesc[index].dvrUsed;
            }
        }
        private unsafe void CreateSubpageBottomlessHelper(
            PtsContext ptsContext,              // IN:  ptr to FS context
            IntPtr nSeg,                        // IN:  name of the segment to start from
            int fSuppressTopSpace,              // IN:  suppress top space?
            uint fswdir,                        // IN:  fswdir
            int lWidth,                         // IN:  width of subpage
            int urMargin,                       // IN:  ur of margin
            int durMargin,                      // IN:  dur of margin
            int vrMargin,                       // IN:  vr of margin
            int cColumns,                       // IN:  number of columns
            PTS.FSCOLUMNINFO[] columnInfoCollection, // IN:  array of column info
            out PTS.FSFMTRBL pfsfmtr,           // OUT: why formatting was stopped
            out IntPtr ppSubPage,               // OUT: ptr to the subpage
            out int pdvrUsed,                   // OUT: dvrUsed
            out PTS.FSBBOX pfsBBox,             // OUT: subpage bbox
            out IntPtr pfsMcsClient,            // OUT: margin collapsing state at the bottom
            out int pTopSpace,                  // OUT: top space due to collapsed margins
            out int fPageBecomesUninterruptible)// OUT: interruption is prohibited from now on
        {
            // Exceptions don't need to pop, as the top level measure context will be nulled out if thrown.
            StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.MaxWidth),
                                                                 new Thickness(), 
                                                                 false, 
                                                                 false);

            fixed (PTS.FSCOLUMNINFO* rgColumnInfo = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageBottomless(ptsContext.Context, nSeg, fSuppressTopSpace,
                    fswdir, lWidth, urMargin, durMargin, vrMargin,
                    cColumns, rgColumnInfo, 0, null, null, 0, null, null, PTS.False,
                    out pfsfmtr, out ppSubPage, out pdvrUsed, out pfsBBox, out pfsMcsClient,
                    out pTopSpace, out fPageBecomesUninterruptible), ptsContext);
            }

            StructuralCache.CurrentFormatContext.PopPageData();
        }
 // ------------------------------------------------------------------
 // Constructor.
 //
 //      PtsContext - Context
 //      TextLineBreak - Contained line break
 // ------------------------------------------------------------------
 internal LineBreakRecord(PtsContext ptsContext, TextLineBreak textLineBreak) : base(ptsContext)
 {
     _textLineBreak = textLineBreak;
 }
Example #39
0
 /// <summary>
 /// Notifies PtsCache about destruction of a PtsContext.
 /// </summary>
 /// <param name="ptsContext">Context used to communicate with PTS component.</param>
 internal static void ReleaseContext(PtsContext ptsContext)
 {
     PtsCache ptsCache = ptsContext.Dispatcher.PtsCache as PtsCache;
     Invariant.Assert(ptsCache != null, "Cannot retrieve PtsCache from PtsContext object.");
     ptsCache.ReleaseContextCore(ptsContext);
 }
Example #40
0
 internal void EnterContext(PtsContext ptsContext)
 {
     Invariant.Assert(_ptsContext == null);
     _ptsContext = ptsContext;
 }
Example #41
0
        internal static List<Rect> GetRectanglesInTrack(
            PtsContext ptsContext,
            ContentElement e,
            int start,
            int length,
            ref PTS.FSTRACKDESCRIPTION trackDesc)
        {
            List<Rect> rectangles = new List<Rect>();
            // There is possibility to get empty track. (example: large figures)
            if (trackDesc.pfstrack == IntPtr.Zero)
            {
                // TRack is empty. Return empty list.
                return rectangles;
            }

            // Get track details
            PTS.FSTRACKDETAILS trackDetails;
            PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out trackDetails));

            // There might be possibility to get empty track, skip the track
            // in such case.
            if (trackDetails.cParas != 0)
            {
                // Get list of paragraphs
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref trackDetails, out arrayParaDesc);

                // Check list of paragraphs for element
                rectangles = GetRectanglesInParaList(ptsContext, e, start, length, arrayParaDesc);
            }
            return rectangles;
        }
Example #42
0
        // ------------------------------------------------------------------
        // Hit tests to the correct IInputElement within the list of
        // paragraphs that the mouse is over.
        // ------------------------------------------------------------------
        internal static IInputElement InputHitTestParaList(
            PtsContext ptsContext,
            PTS.FSPOINT pt,
            ref PTS.FSRECT rcTrack,                     // track's rectangle
            PTS.FSPARADESCRIPTION [] arrayParaDesc)
        {
            IInputElement ie = null;

            for (int index = 0; index < arrayParaDesc.Length && ie == null; index++)
            {
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                if(paraClient.Rect.Contains(pt))
                {
                    ie = paraClient.InputHitTest(pt);
                }
            }
            return ie;
        }
Example #43
0
        internal static IInputElement InputHitTestTrack(
            PtsContext ptsContext,
            PTS.FSPOINT pt,
            ref PTS.FSTRACKDESCRIPTION trackDesc)
        {
            // There is possibility to get empty track. (example: large figures)
            if (trackDesc.pfstrack == IntPtr.Zero) { return null; }

            IInputElement ie = null;

            // Get track details
            PTS.FSTRACKDETAILS trackDetails;
            PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out trackDetails));

            // There might be possibility to get empty track, skip the track
            // in such case.
            if (trackDetails.cParas != 0)
            {
                // Get list of paragraphs
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref trackDetails, out arrayParaDesc);

                // Hittest list of paragraphs
                ie = InputHitTestParaList(ptsContext, pt, ref trackDesc.fsrc, arrayParaDesc);
            }

            return ie;
        }
Example #44
0
        // ------------------------------------------------------------------
        // Update viewport for para list
        // ------------------------------------------------------------------
        internal static void UpdateViewportParaList(
            PtsContext ptsContext,
            PTS.FSPARADESCRIPTION [] arrayParaDesc,
            ref PTS.FSRECT viewport)
        {
            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                paraClient.UpdateViewport(ref viewport);
            }
        }
Example #45
0
        internal static void UpdateViewportTrack(
            PtsContext ptsContext,
            ref PTS.FSTRACKDESCRIPTION trackDesc,
            ref PTS.FSRECT viewport)
        {
            // There is possibility to get empty track. (example: large figures)
            if (trackDesc.pfstrack != IntPtr.Zero)
            {
                // Get track details
                PTS.FSTRACKDETAILS trackDetails;
                PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out trackDetails));

                // There is possibility to get empty track.
                if (trackDetails.cParas != 0)
                {
                    // Get list of paragraphs
                    PTS.FSPARADESCRIPTION[] arrayParaDesc;
                    ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref trackDetails, out arrayParaDesc);

                    // Arrange paragraphs
                    UpdateViewportParaList(ptsContext, arrayParaDesc, ref viewport);
                }
            }
        }
Example #46
0
        // ------------------------------------------------------------------
        // Update visuals for list of paragraphs.
        // ------------------------------------------------------------------
        internal static void UpdateParaListVisuals(
            PtsContext ptsContext,
            VisualCollection visualCollection,
            PTS.FSKUPDATE fskupdInherited,
            PTS.FSPARADESCRIPTION [] arrayParaDesc)
        {
            // For each paragraph, do following:
            // (1) Retrieve ParaClient object
            // (3) Update visual, if necessary
            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                // (1) Retrieve ParaClient object
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);

                // (2) Update visual, if necessary
                PTS.FSKUPDATE fskupd = arrayParaDesc[index].fsupdinf.fskupd;
                if (fskupd == PTS.FSKUPDATE.fskupdInherited)
                {
                    fskupd = fskupdInherited;
                }
                if (fskupd == PTS.FSKUPDATE.fskupdNew)
                {
                    // Disconnect visual from its old parent, if necessary.
                    Visual currentParent = VisualTreeHelper.GetParent(paraClient.Visual) as Visual;
                    if(currentParent != null)
                    {
                        ContainerVisual parent = currentParent as ContainerVisual;
                        Invariant.Assert(parent != null, "parent should always derives from ContainerVisual");
                        parent.Children.Remove(paraClient.Visual);                         
                    }                                          

                    // New paragraph - insert new visual node
                    visualCollection.Insert(index, paraClient.Visual);

                    paraClient.ValidateVisual(fskupd);
                }
                else
                {
                    // Remove visuals for non-existing paragraphs
                    while (visualCollection[index] != paraClient.Visual)
                    {
                        visualCollection.RemoveAt(index);
                        Invariant.Assert(index < visualCollection.Count);
                    }

                    if(fskupd == PTS.FSKUPDATE.fskupdChangeInside || fskupd == PTS.FSKUPDATE.fskupdShifted)
                    {
                        paraClient.ValidateVisual(fskupd);
                    }
                }
            }
            // Remove obsolete visuals
            if (arrayParaDesc.Length < visualCollection.Count)
            {
                visualCollection.RemoveRange(arrayParaDesc.Length, visualCollection.Count - arrayParaDesc.Length);
            }
        }
Example #47
0
        internal static void UpdateTrackVisuals(
            PtsContext ptsContext,
            VisualCollection visualCollection,
            PTS.FSKUPDATE fskupdInherited,
            ref PTS.FSTRACKDESCRIPTION trackDesc)
        {
            PTS.FSKUPDATE fskupd = trackDesc.fsupdinf.fskupd;
            if (trackDesc.fsupdinf.fskupd == PTS.FSKUPDATE.fskupdInherited)
            {
                fskupd = fskupdInherited;
            }

            // If there is no change, visual information is valid
            if (fskupd == PTS.FSKUPDATE.fskupdNoChange) { return; }
            ErrorHandler.Assert(fskupd != PTS.FSKUPDATE.fskupdShifted, ErrorHandler.UpdateShiftedNotValid);

            bool emptyTrack = (trackDesc.pfstrack == IntPtr.Zero);
            if (!emptyTrack)
            {
                // Get track details
                PTS.FSTRACKDETAILS trackDetails;
                PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, trackDesc.pfstrack, out trackDetails));

                emptyTrack = (trackDetails.cParas == 0);
                if (!emptyTrack)
                {
                    // Get list of paragraphs
                    PTS.FSPARADESCRIPTION[] arrayParaDesc;
                    ParaListFromTrack(ptsContext, trackDesc.pfstrack, ref trackDetails, out arrayParaDesc);

                    // Update visuals for list of paragraphs
                    UpdateParaListVisuals(ptsContext, visualCollection, fskupd, arrayParaDesc);
                }
            }

            // There is possibility to get empty track. (example: large figures)
            if (emptyTrack)
            {
                // There is no content, remove all existing children visuals.
                visualCollection.Clear();
            }
        }
Example #48
0
 internal static unsafe void AttachedObjectListFromParagraph(
     PtsContext ptsContext,
     IntPtr para,
     int cAttachedObject,
     out PTS.FSATTACHEDOBJECTDESCRIPTION [] arrayAttachedObjectDesc)
 {
     arrayAttachedObjectDesc = new PTS.FSATTACHEDOBJECTDESCRIPTION [cAttachedObject];
     int attachedObjectCount;
     fixed (PTS.FSATTACHEDOBJECTDESCRIPTION* rgAttachedObjectDesc = arrayAttachedObjectDesc)
     {
         PTS.Validate(PTS.FsQueryAttachedObjectList(ptsContext.Context, para, cAttachedObject, rgAttachedObjectDesc, out attachedObjectCount));
     }
     ErrorHandler.Assert(cAttachedObject == attachedObjectCount, ErrorHandler.PTSObjectsCountMismatch);
 }
Example #49
0
        internal static TextContentRange TextContentRangeFromTrack(
            PtsContext ptsContext,
            IntPtr pfstrack)
        {
            // Get track details
            PTS.FSTRACKDETAILS trackDetails;
            PTS.Validate(PTS.FsQueryTrackDetails(ptsContext.Context, pfstrack, out trackDetails));

            // Combine ranges from all nested paragraphs.
            TextContentRange textContentRange = new TextContentRange();
            if (trackDetails.cParas != 0)
            {
                PTS.FSPARADESCRIPTION[] arrayParaDesc;
                PtsHelper.ParaListFromTrack(ptsContext, pfstrack, ref trackDetails, out arrayParaDesc);

                // Merge TextContentRanges for all paragraphs
                BaseParaClient paraClient;
                for (int i = 0; i < arrayParaDesc.Length; i++)
                {
                    paraClient = ptsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient;
                    PTS.ValidateHandle(paraClient);
                    textContentRange.Merge(paraClient.GetTextContentRange());
                }
            }
            return textContentRange;
        }
Example #50
0
        // ------------------------------------------------------------------
        // Returns ArrayList of rectangles for the ContentElement e within the
        // list of paragraphs. If the element is not found, returns empty list.
        //      start: int representing start offset of e
        //      length: int representing number of positions occupied by e
        // ------------------------------------------------------------------
        internal static List<Rect> GetRectanglesInParaList(
            PtsContext ptsContext,
            ContentElement e,
            int start,
            int length,
            PTS.FSPARADESCRIPTION[] arrayParaDesc)
        {
            List<Rect> rectangles = new List<Rect>();

            for (int index = 0; index < arrayParaDesc.Length; index++)
            {
                BaseParaClient paraClient = ptsContext.HandleToObject(arrayParaDesc[index].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);
                if (start < paraClient.Paragraph.ParagraphEndCharacterPosition)
                {
                    // Element lies within the paraClient boundaries.
                    rectangles = paraClient.GetRectangles(e, start, length);

                    // Rectangles collection should not be null for consistency
                    Invariant.Assert(rectangles != null);
                    if (rectangles.Count != 0)
                    {
                        // Element cannot span more than one para client in the same track, so we stop
                        // if the element is found and the rectangles are calculated
                        break;
                    }
                }
            }
            return rectangles;
        }
Example #51
0
 internal void LeaveContext(PtsContext ptsContext)
 {
     Invariant.Assert(_ptsContext == ptsContext);
     _ptsContext = null;
 }
Example #52
0
 internal static unsafe void TrackListFromSubpage(
     PtsContext ptsContext,
     IntPtr subpage,
     ref PTS.FSSUBPAGEDETAILS subpageDetails,
     out PTS.FSTRACKDESCRIPTION [] arrayTrackDesc)
 {
     arrayTrackDesc = new PTS.FSTRACKDESCRIPTION [subpageDetails.u.complex.cBasicColumns];
     int trackCount;
     fixed (PTS.FSTRACKDESCRIPTION* rgTrackDesc = arrayTrackDesc)
     {
         PTS.Validate(PTS.FsQuerySubpageBasicColumnList(ptsContext.Context, subpage, subpageDetails.u.complex.cBasicColumns,
             rgTrackDesc, out trackCount));
     }
     ErrorHandler.Assert(subpageDetails.u.complex.cBasicColumns == trackCount, ErrorHandler.PTSObjectsCountMismatch);
 }
Example #53
0
 /// <summary>
 /// Notifies PtsCache about destruction of a PtsContext.
 /// </summary>
 /// <param name="ptsContext">Context used to communicate with PTS component.</param>
 private void ReleaseContextCore(PtsContext ptsContext)
 {
     // _releaseQueue may be accessed from Finalizer thread or Dispatcher thread.
     lock (_lock)
     {
         // After shutdown is initiated, do not allow Finalizer thread to add any
         // items to _releaseQueue.
         if (_disposed == 0)
         {
             // Add PtsContext to collection of released PtsContexts.
             // If the queue is empty, schedule Dispatcher time to dispose
             // PtsContexts in the Dispatcher thread.
             // If the queue is not empty, there is already pending Dispatcher request.
             if (_releaseQueue == null)
             {
                 _releaseQueue = new List<PtsContext>();
                 ptsContext.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(OnPtsContextReleased), null);
             }
             _releaseQueue.Add(ptsContext);
         }
     }
 }
Example #54
0
        internal static unsafe void TrackListFromSection(
            PtsContext ptsContext,
            IntPtr section,
            ref PTS.FSSECTIONDETAILS sectionDetails,
            out PTS.FSTRACKDESCRIPTION [] arrayTrackDesc)
        {
            // 

            Debug.Assert(sectionDetails.u.withpagenotes.cSegmentDefinedColumnSpanAreas == 0);
            Debug.Assert(sectionDetails.u.withpagenotes.cHeightDefinedColumnSpanAreas == 0);

            arrayTrackDesc = new PTS.FSTRACKDESCRIPTION[sectionDetails.u.withpagenotes.cBasicColumns];

            int trackCount;
            fixed (PTS.FSTRACKDESCRIPTION* rgTrackDesc = arrayTrackDesc)
            {
                PTS.Validate(PTS.FsQuerySectionBasicColumnList(ptsContext.Context, section, sectionDetails.u.withpagenotes.cBasicColumns,
                    rgTrackDesc, out trackCount));
            }
            ErrorHandler.Assert(sectionDetails.u.withpagenotes.cBasicColumns == trackCount, ErrorHandler.PTSObjectsCountMismatch);
        }
Example #55
0
 // ------------------------------------------------------------------
 // Constructor.
 //
 //      ptsContext - Current PTS context.
 //      margin - margin value
 // ------------------------------------------------------------------
 internal MarginCollapsingState(PtsContext ptsContext, int margin) : base(ptsContext)
 {
     _maxPositive = (margin >= 0) ? margin : 0;
     _minNegative = (margin <  0) ? margin : 0;
 }
Example #56
0
 internal static unsafe void ParaListFromSubtrack(
     PtsContext ptsContext,
     IntPtr subtrack,
     ref PTS.FSSUBTRACKDETAILS subtrackDetails,
     out PTS.FSPARADESCRIPTION [] arrayParaDesc)
 {
     arrayParaDesc = new PTS.FSPARADESCRIPTION [subtrackDetails.cParas];
     int paraCount;
     fixed (PTS.FSPARADESCRIPTION* rgParaDesc = arrayParaDesc)
     {
         PTS.Validate(PTS.FsQuerySubtrackParaList(ptsContext.Context, subtrack, subtrackDetails.cParas,
             rgParaDesc, out paraCount));
     }
     ErrorHandler.Assert(subtrackDetails.cParas == paraCount, ErrorHandler.PTSObjectsCountMismatch);
 }
Example #57
0
        private PtsHost AcquireContextCore(PtsContext ptsContext, TextFormattingMode textFormattingMode)
        {
            int index;

            // Look for the first free PTS Context.
            for (index = 0; index < _contextPool.Count; index++)
            {
                if (!_contextPool[index].InUse &&
                    _contextPool[index].IsOptimalParagraphEnabled == ptsContext.IsOptimalParagraphEnabled)
                {
                    break;
                }
            }

            // Create new PTS Context, if cannot find free one.
            if (index == _contextPool.Count)
            {
                _contextPool.Add(new ContextDesc());
                _contextPool[index].IsOptimalParagraphEnabled = ptsContext.IsOptimalParagraphEnabled;
                _contextPool[index].PtsHost = new PtsHost();
                _contextPool[index].PtsHost.Context = CreatePTSContext(index, textFormattingMode);
            }

            // Initialize TextFormatter, if optimal paragraph is enabled.
            // Optimal paragraph requires new TextFormatter for every PTS Context.
            if (_contextPool[index].IsOptimalParagraphEnabled)
            {
                ptsContext.TextFormatter = _contextPool[index].TextFormatter;
            }

            // Assign PTS Context to new owner.
            _contextPool[index].InUse = true;
            _contextPool[index].Owner = new WeakReference(ptsContext);

            return _contextPool[index].PtsHost;
        }
Example #58
0
 internal static unsafe void LineListCompositeFromTextPara(
     PtsContext ptsContext,
     IntPtr para,
     ref PTS.FSTEXTDETAILSFULL textDetails,
     out PTS.FSLINEDESCRIPTIONCOMPOSITE [] arrayLineDesc)
 {
     arrayLineDesc = new PTS.FSLINEDESCRIPTIONCOMPOSITE [textDetails.cLines];
     int lineCount;
     fixed (PTS.FSLINEDESCRIPTIONCOMPOSITE* rgLineDesc = arrayLineDesc)
     {
         PTS.Validate(PTS.FsQueryLineListComposite(ptsContext.Context, para, textDetails.cLines,
             rgLineDesc, out lineCount));
     }
     ErrorHandler.Assert(textDetails.cLines == lineCount, ErrorHandler.PTSObjectsCountMismatch);
 }
Example #59
0
 internal static unsafe void SectionListFromPage(
     PtsContext ptsContext,
     IntPtr page,
     ref PTS.FSPAGEDETAILS pageDetails,
     out PTS.FSSECTIONDESCRIPTION [] arraySectionDesc)
 {
     arraySectionDesc = new PTS.FSSECTIONDESCRIPTION [pageDetails.u.complex.cSections];
     int sectionCount;
     fixed (PTS.FSSECTIONDESCRIPTION* rgSectionDesc = arraySectionDesc)
     {
         PTS.Validate(PTS.FsQueryPageSectionList(ptsContext.Context, page, pageDetails.u.complex.cSections,
             rgSectionDesc, out sectionCount));
     }
     ErrorHandler.Assert(pageDetails.u.complex.cSections == sectionCount, ErrorHandler.PTSObjectsCountMismatch);
 }
        private unsafe void CreateSubpageFiniteHelper(
            PtsContext ptsContext,              // IN:  ptr to FS context
            IntPtr brParaIn,                    // IN:  break record---use if !NULL
            int fFromPreviousPage,              // IN:  break record was created on previous page
            IntPtr nSeg,                        // IN:  name of the segment to start from-if pointer to break rec is NULL
            IntPtr pFtnRej,                     // IN:  pftnrej
            int fEmptyOk,                       // IN:  fEmptyOK
            int fSuppressTopSpace,              // IN:  fSuppressTopSpace
            uint fswdir,                        // IN:  fswdir
            int lWidth,                         // IN:  width of subpage
            int lHeight,                        // IN:  height of subpage
            ref PTS.FSRECT rcMargin,            // IN:  rectangle within subpage margins
            int cColumns,                       // IN:  number of columns
            PTS.FSCOLUMNINFO[] columnInfoCollection, // IN:  array of column info
            int fApplyColumnBalancing,          // IN:  apply column balancing?
            out PTS.FSFMTR fsfmtr,              // OUT: why formatting was stopped
            out IntPtr pSubPage,                // OUT: ptr to the subpage
            out IntPtr brParaOut,               // OUT: break record of the subpage
            out int dvrUsed,                    // OUT: dvrUsed
            out PTS.FSBBOX fsBBox,              // OUT: subpage bbox
            out IntPtr pfsMcsClient,            // OUT: margin collapsing state at the bottom
            out int topSpace)                   // OUT: top space due to collapsed margins
        {
            // Exceptions don't need to pop, as the top level measure context will be nulled out if thrown.
            StructuralCache.CurrentFormatContext.PushNewPageData(new Size(TextDpi.FromTextDpi(lWidth), TextDpi.FromTextDpi(lHeight)),
                                                                 new Thickness(), 
                                                                 false, 
                                                                 true);

            fixed (PTS.FSCOLUMNINFO* rgColumnInfo = columnInfoCollection)
            {
                PTS.Validate(PTS.FsCreateSubpageFinite(ptsContext.Context, brParaIn, fFromPreviousPage, nSeg,
                    pFtnRej, fEmptyOk, fSuppressTopSpace, fswdir, lWidth, lHeight,
                    ref rcMargin, cColumns, rgColumnInfo, PTS.False,
                    0, null, null, 0, null, null, PTS.False, 
                    PTS.FSKSUPPRESSHARDBREAKBEFOREFIRSTPARA.fsksuppresshardbreakbeforefirstparaNone, 
                    out fsfmtr, out pSubPage, out brParaOut, out dvrUsed, out fsBBox, out pfsMcsClient, out topSpace), ptsContext);
            }

            StructuralCache.CurrentFormatContext.PopPageData();
        }