internal ReadOnlyCollection <ParagraphResult> GetChildrenParagraphResults(out bool hasTextContent)
        {
#if TEXTPANELLAYOUTDEBUG
            TextPanelDebug.IncrementCounter("ContainerPara.GetParagraphs", TextPanelDebug.Category.TextView);
#endif
            // Query paragraph details
            PTS.FSSUBTRACKDETAILS subtrackDetails;
            PTS.Validate(PTS.FsQuerySubtrackDetails(PtsContext.Context, _paraHandle.Value, out subtrackDetails));

            // hasTextContent is set to true if any of the children paragraphs has text content, not just attached objects
            hasTextContent = false;

            if (subtrackDetails.cParas == 0)
            {
                return(new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0)));
            }

            // Get list of paragraphs
            PTS.FSPARADESCRIPTION [] arrayParaDesc;
            PtsHelper.ParaListFromSubtrack(PtsContext, _paraHandle.Value, ref subtrackDetails, out arrayParaDesc);

            List <ParagraphResult> paragraphResults = new List <ParagraphResult>(arrayParaDesc.Length);
            for (int i = 0; i < arrayParaDesc.Length; i++)
            {
                BaseParaClient paraClient = PtsContext.HandleToObject(arrayParaDesc[i].pfsparaclient) as BaseParaClient;
                PTS.ValidateHandle(paraClient);
                ParagraphResult paragraphResult = paraClient.CreateParagraphResult();
                if (paragraphResult.HasTextContent)
                {
                    hasTextContent = true;
                }
                paragraphResults.Add(paragraphResult);
            }
            return(new ReadOnlyCollection <ParagraphResult>(paragraphResults));
        }
Exemple #2
0
 // ------------------------------------------------------------------
 // Increment counter for specific event.
 // ------------------------------------------------------------------
 internal static void IncrementCounter(string name, Category category)
 {
     if (_instance == null) { _instance = new TextPanelDebug(); }
     if (_instance._IsEnabled(category))
     {
         _instance._IncrementCounter(name);
     }
 }
Exemple #3
0
 // ------------------------------------------------------------------
 // Enter the scope and start timer.
 // ------------------------------------------------------------------
 internal static void StartTimer(string name, Category category)
 {
     if (_instance == null) { _instance = new TextPanelDebug(); }
     if (_instance._IsEnabled(category))
     {
         _instance._StartTimer(name);
     }
 }
Exemple #4
0
 // ------------------------------------------------------------------
 // Enter the scope and log the message.
 // ------------------------------------------------------------------
 internal static void BeginScope(string msg, Category category)
 {
     if (_instance == null) { _instance = new TextPanelDebug(); }
     if (_instance._IsEnabled(category))
     {
         _instance._BeginScope(msg);
     }
 }
 // ------------------------------------------------------------------
 // Log message.
 // ------------------------------------------------------------------
 internal static void Log(string msg, Category category)
 {
     if (_instance == null)
     {
         _instance = new TextPanelDebug();
     }
     if (_instance._IsEnabled(category))
     {
         _instance._Log(msg);
     }
 }
 // ------------------------------------------------------------------
 // Increment counter for specific event.
 // ------------------------------------------------------------------
 internal static void IncrementCounter(string name, Category category)
 {
     if (_instance == null)
     {
         _instance = new TextPanelDebug();
     }
     if (_instance._IsEnabled(category))
     {
         _instance._IncrementCounter(name);
     }
 }
 // ------------------------------------------------------------------
 // Enter the scope and start timer.
 // ------------------------------------------------------------------
 internal static void StartTimer(string name, Category category)
 {
     if (_instance == null)
     {
         _instance = new TextPanelDebug();
     }
     if (_instance._IsEnabled(category))
     {
         _instance._StartTimer(name);
     }
 }
Exemple #8
0
        // ------------------------------------------------------------------
        //
        //  PTS callbacks
        //
        // ------------------------------------------------------------------

        #region PTS callbacks

        /// <summary>
        /// UpdGetParaChange
        /// </summary>
        /// <param name="fskch">
        /// OUT: kind of change
        /// </param>
        /// <param name="fNoFurtherChanges">
        /// OUT: no changes after?
        /// </param>
        internal virtual void UpdGetParaChange(
            out PTS.FSKCHANGE fskch,
            out int fNoFurtherChanges)
        {
            fskch             = _changeType;
            fNoFurtherChanges = PTS.FromBoolean(_stopAsking);

#if TEXTPANELLAYOUTDEBUG
            if (StructuralCache.CurrentFormatContext.IncrementalUpdate)
            {
                TextPanelDebug.Log("Para.UpdGetParaChange, Para=" + this.GetType().Name + " Change=" + _changeType.ToString(), TextPanelDebug.Category.ContentChange);
            }
#endif
        }
Exemple #9
0
        // ------------------------------------------------------------------
        // Merge new DTR with list of exising DTRs:
        // 1) Convert startIndex to index reflecting position before any changes.
        // 2) Merge it with existing list of DTRs.
        //
        //      dtr - New DTR to be merged with exising list of DTRs.
        // ------------------------------------------------------------------
        internal void Merge(DirtyTextRange dtr)
        {
            bool merge         = false;
            int  i             = 0;
            int  startIndexOld = dtr.StartIndex;

            // 1) Convert StartIndex to index reflecting position before any changes.
            //    And find out if there is a need to merge DTRs
            if (_count > 0)
            {
                while (i < _count)
                {
                    // a) New DTR starts before the next one. In this case there are
                    //    two possibilities:
                    //    * new DTR does not intersect with the beginning of the next DTR,
                    //      in this case insert new DTR before the next one.
                    //    * new DTR does intersect with the beginning of the next DTR,
                    //      in this case merge these 2 DTRs
                    if (startIndexOld < _dtrs[i].StartIndex)
                    {
                        if (startIndexOld + dtr.PositionsRemoved > _dtrs[i].StartIndex)
                        {
                            merge = true;
                        }
                        // else new dtr has to be inserted at position 'i'
                        break;
                    }
                    // b) New DTR starts in the range of the previous DTR. In this case
                    //    merge these 2 DTRs
                    else if (startIndexOld <= _dtrs[i].StartIndex + _dtrs[i].PositionsAdded)
                    {
                        // merge with existing dtr at position 'i'
                        merge = true;
                        break;
                    }
                    // c) No intersection has been found, go to the next DTR in the list.
                    startIndexOld -= _dtrs[i].PositionsAdded - _dtrs[i].PositionsRemoved;
                    ++i;
                }
                // Update dcp of the new DTR, to reflect position before any tree changes.
                dtr.StartIndex = startIndexOld;
            }

            // 2) Insert new DTR into the list, merge if necessary
            if (i < _count)
            {
                if (merge)
                {
                    // The simplest way to merge these two DTRs is to add together
                    // cchAdded/cchDeleted form both DTRs, but it will invalidate more
                    // than required. Formula used below is more accurate.

                    // a) New DTR does intersect with the beginning of the next DTR,
                    //    in this case merge these 2 DTRs.
                    // * dcp = dcpN (since it starts before dcpO)
                    // * add = addN + addO - min(addO, delN - (dcpO - dcpN))
                    // * del = delN + delO - min(addO, delN - (dcpO - dcpN))
                    // NOTE: dcpO - dcpN is always <= delN
                    if (dtr.StartIndex < _dtrs[i].StartIndex)
                    {
                        int delta  = _dtrs[i].StartIndex - dtr.StartIndex;
                        int adjust = Math.Min(_dtrs[i].PositionsAdded, dtr.PositionsRemoved - delta);
                        _dtrs[i].StartIndex        = dtr.StartIndex;
                        _dtrs[i].PositionsAdded   += dtr.PositionsAdded - adjust;
                        _dtrs[i].PositionsRemoved += dtr.PositionsRemoved - adjust;
                    }
                    // b) New DTR starts in the range of the previous DTR. In this case
                    //    merge these 2 DTRs.
                    // * dcp = dcpO (since it starts before dcpN)
                    // * add = addN + addO - min(delN, addO - (dcpN - dcpO))
                    // * del = delN + delO - min(delN, addO - (dcpN - dcpO))
                    // NOTE: dcpN - dcpO is always <= addO
                    else
                    {
                        int delta  = dtr.StartIndex - _dtrs[i].StartIndex;
                        int adjust = Math.Min(dtr.PositionsRemoved, _dtrs[i].PositionsAdded - delta);
                        //_dtrs[i].dcp: no need to change it
                        _dtrs[i].PositionsAdded   += dtr.PositionsAdded - adjust;
                        _dtrs[i].PositionsRemoved += dtr.PositionsRemoved - adjust;
                    }
                }
                else
                {
                    // The new DTR has to be inserted before DTR at position 'i'.
                    if (_count == _dtrs.Length)
                    {
                        Resize();
                    }
                    Array.Copy(_dtrs, i, _dtrs, i + 1, _count - i);
                    _dtrs[i] = dtr;
                    ++_count;
                }
                MergeWithNext(i);
            }
            else
            {
                // The new DTR has to be appended to the end of the list.
                if (_count == _dtrs.Length)
                {
                    Resize();
                }
                _dtrs[_count] = dtr;
                ++_count;
            }

#if TEXTPANELLAYOUTDEBUG
            System.Text.StringBuilder msg = new System.Text.StringBuilder();
            msg.Append("Merge DTR (" + dtr.StartIndex + "," + dtr.PositionsAdded + "," + dtr.PositionsRemoved + ") ->");
            for (i = 0; i < _count; i++)
            {
                msg.Append(" (" + _dtrs[i].StartIndex + "," + _dtrs[i].PositionsAdded + "," + _dtrs[i].PositionsRemoved + ")");
            }
            TextPanelDebug.Log(msg.ToString(), TextPanelDebug.Category.ContentChange);
#endif
        }