internal ReadOnlyCollection<ColumnResult> GetColumnResults(out bool hasTextContent)
        {
            List<ColumnResult> columnResults = new List<ColumnResult>(0);
            Vector contentOffset = new Vector(); 

            // hasTextContent is set to true if any of the columns has text content, not just attached objects. A column has text content if any of 
            // it's paragraph results has text content 
            hasTextContent = false;
 
            // Query subpage details
            PTS.FSSUBPAGEDETAILS subpageDetails;
            PTS.Validate(PTS.FsQuerySubpageDetails(PtsContext.Context, _paraHandle.Value, out subpageDetails));
 
            // Subpage content may be simple or complex -
            // depending of set of features used in the content of the page. 
            // (1) simple subpage (contains only one track) 
            // (2) complex subpage (contains columns)
            if (PTS.ToBoolean(subpageDetails.fSimple)) 
            {
                // (1) simple subpage (contains only one track)
                PTS.FSTRACKDETAILS trackDetails;
                PTS.Validate(PTS.FsQueryTrackDetails(PtsContext.Context, subpageDetails.u.simple.trackdescr.pfstrack, out trackDetails)); 
                if (trackDetails.cParas > 0)
                { 
                    columnResults = new List<ColumnResult>(1); 
                    ColumnResult columnResult = new ColumnResult(this, ref subpageDetails.u.simple.trackdescr, contentOffset);
                    columnResults.Add(columnResult); 
                    if (columnResult.HasTextContent)
                    {
                        hasTextContent = true;
                    } 
                }
            } 
            else 
            {
                // (2) complex page (contains columns) 
                // cBasicColumns == 0, means that subpage content is empty
                if (subpageDetails.u.complex.cBasicColumns != 0)
                {
                    // Retrieve description for each column. 
                    PTS.FSTRACKDESCRIPTION[] arrayColumnDesc;
                    PtsHelper.TrackListFromSubpage(PtsContext, _paraHandle.Value, ref subpageDetails, out arrayColumnDesc); 
 
                    // Floaters are held at one column; just add the first one
                    columnResults = new List<ColumnResult>(1); 
                    PTS.FSTRACKDETAILS trackDetails;
                    PTS.Validate(PTS.FsQueryTrackDetails(PtsContext.Context, arrayColumnDesc[0].pfstrack, out trackDetails));
                    if (trackDetails.cParas > 0)
                    { 
                        ColumnResult columnResult = new ColumnResult(this, ref arrayColumnDesc[0], contentOffset);
                        columnResults.Add(columnResult); 
                        if (columnResult.HasTextContent) 
                        {
                            hasTextContent = true; 
                        }
                    }
                }
            } 

            return new ReadOnlyCollection<ColumnResult>(columnResults); 
        } 
Beispiel #2
0
        internal ReadOnlyCollection<ColumnResult> GetColumnResults(out bool hasTextContent)
        {
            Invariant.Assert(!IsDisposed);
            List<ColumnResult> columnResults = new List<ColumnResult>(0);

            // hasTextContent is set to true if any of the columns in the page has text content. This is determined by checking the columns'
            // paragraph collections
            hasTextContent = false;

            // There are 3 cases:
            // (1) PTS page is not created - no columns are available.
            // (2) PTS page - use page PTS APIs to get columns.
            if (_ptsPage.PageHandle == IntPtr.Zero)
            {
                // (1) PTS page is not created
            }
            else
            {
               // (2) PTS page - use page PTS APIs to get columns.
                PTS.FSPAGEDETAILS pageDetails;
                PTS.Validate(PTS.FsQueryPageDetails(StructuralCache.PtsContext.Context, _ptsPage.PageHandle, out pageDetails));

                // There are 2 different types of PTS page:
                // (a) simple page (contains only one track) - 1 column.
                // (b) complex page (contains header, page body, footnotes and footer) - get columns
                //     from the page body.
                if (PTS.ToBoolean(pageDetails.fSimple))
                {
                    // (a) simple page (contains only one track) - 1 column.
                    PTS.FSTRACKDETAILS trackDetails;
                    PTS.Validate(PTS.FsQueryTrackDetails(StructuralCache.PtsContext.Context, pageDetails.u.simple.trackdescr.pfstrack, out trackDetails));
                    if (trackDetails.cParas > 0)
                    {
                        columnResults = new List<ColumnResult>(1);
                        ColumnResult columnResult = new ColumnResult(this, ref pageDetails.u.simple.trackdescr, new Vector());
                        columnResults.Add(columnResult);
                        if (columnResult.HasTextContent)
                        {
                            hasTextContent = true;
                        }
                    }
                }
                else if (pageDetails.u.complex.cSections > 0)
                {
                    // (b) complex page (contains header, page body, footnotes and footer) - get columns
                    //     from the page body.
                    Debug.Assert(pageDetails.u.complex.cSections == 1); // Only one section is supported right now.

                    // Retrieve description for each section.
                    PTS.FSSECTIONDESCRIPTION[] arraySectionDesc;
                    PtsHelper.SectionListFromPage(StructuralCache.PtsContext, _ptsPage.PageHandle, ref pageDetails, out arraySectionDesc);

                    // Get section details
                    PTS.FSSECTIONDETAILS sectionDetails;
                    PTS.Validate(PTS.FsQuerySectionDetails(StructuralCache.PtsContext.Context, arraySectionDesc[0].pfssection, out sectionDetails));

                    // There are 2 types of sections:
                    // (1) with page notes - footnotes in section treated as endnotes
                    // (2) with column notes - footnotes in section treated as column notes
                    if (PTS.ToBoolean(sectionDetails.fFootnotesAsPagenotes))
                    {
                        // (1) with page notes - footnotes in section treated as endnotes
                        Debug.Assert(sectionDetails.u.withpagenotes.cEndnoteColumns == 0); // Footnotes are not supported yet.

                        // 

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

                        // cBasicColumns == 0, means that section content is empty.
                        // In such case there is nothing to render.
                        if (sectionDetails.u.withpagenotes.cBasicColumns > 0)
                        {
                            // Retrieve description for each column.
                            PTS.FSTRACKDESCRIPTION[] arrayColumnDesc;
                            PtsHelper.TrackListFromSection(StructuralCache.PtsContext, arraySectionDesc[0].pfssection, ref sectionDetails, out arrayColumnDesc);

                            columnResults = new List<ColumnResult>(sectionDetails.u.withpagenotes.cBasicColumns);
                            for (int i = 0; i < arrayColumnDesc.Length; i++)
                            {
                                PTS.FSTRACKDESCRIPTION columnDesc = arrayColumnDesc[i];

                                // Column may have null track, in which case we should not add it
                                if (columnDesc.pfstrack != IntPtr.Zero)
                                {
                                    PTS.FSTRACKDETAILS trackDetails;
                                    PTS.Validate(PTS.FsQueryTrackDetails(StructuralCache.PtsContext.Context, columnDesc.pfstrack, out trackDetails));
                                    if (trackDetails.cParas > 0)
                                    {
                                        ColumnResult columnResult = new ColumnResult(this, ref columnDesc, new Vector());
                                        columnResults.Add(columnResult);
                                        if (columnResult.HasTextContent)
                                        {
                                            hasTextContent = true;
                                        }
                                    }
                                }
                            }
                        }
                        // else; section empty => no columns
                    }
                    else
                    {
                        // (2) with column notes - footnotes in section treated as column notes
                        Debug.Assert(false); // Complex columns are not supported yet.
                    }
                }
            }

            Invariant.Assert(columnResults != null);
            return new ReadOnlyCollection<ColumnResult>(columnResults);
        }