/// <summary>
        /// Client to collapse the line to fit for display
        /// </summary>
        /// <param name="collapsingPropertiesList">a list of collapsing properties</param>
        public override TextLine Collapse(
            params TextCollapsingProperties[]   collapsingPropertiesList
            )
        {
            if (!HasOverflowed)
                return this;

            Invariant.Assert(_settings != null);

            // instantiate a collapsible full text line, collapse it and return the collapsed line
            TextMetrics.FullTextLine textLine = new TextMetrics.FullTextLine(
                _settings,
                _cpFirst,
                0,  // lineLength
                TextFormatterImp.RealToIdeal(_paragraphWidth),
                LineFlags.None
                );

            // When in TextFormattingMode.Display the math processing performed by SimpleTextLine 
            // involves some rounding operations because of which the decision to collapse the text may 
            // not be unanimous amongst SimpleTextLine and FullTextLine. There are several watson 
            // crash reports that are testament to this theory. See Win8 PS bug# 643676. Hence we 
            // now allow the case where FullTextLine concludes that it doesnt need to collapse the 
            // text even though SimpleTextLine thought it should.
            
            if (textLine.HasOverflowed)
            {
                TextLine collapsedTextLine = textLine.Collapse(collapsingPropertiesList);
                if (collapsedTextLine != textLine)
                {
                    // if collapsed line is genuinely new,
                    // Dispose its maker as we no longer need it around, dispose it explicitly
                    // to reduce unnecessary finalization of this intermediate line.
                    textLine.Dispose();
                }
                return collapsedTextLine;
            }

            return textLine;
        }
Esempio n. 2
0
        /// <summary> 
        /// Client to collapse the line to fit for display 
        /// </summary>
        /// <param name="collapsingPropertiesList">a list of collapsing properties</param> 
        public override TextLine Collapse(
            params TextCollapsingProperties[]   collapsingPropertiesList
            )
        { 
            if (!HasOverflowed)
                return this; 
 
            Invariant.Assert(_settings != null);
 
            // instantiate a collapsible full text line, collapse it and return the collapsed line
            TextMetrics.FullTextLine textLine = new TextMetrics.FullTextLine(
                _settings,
                _cpFirst, 
                0,  // lineLength
                TextFormatterImp.RealToIdeal(_paragraphWidth), 
                LineFlags.None 
                );
 
            Invariant.Assert(textLine.HasOverflowed);
            TextLine collapsedTextLine = textLine.Collapse(collapsingPropertiesList);
            if (collapsedTextLine != textLine)
            { 
                // if collapsed line is genuinely new,
                // Dispose its maker as we no longer need it around, dispose it explicitly 
                // to reduce unnecessary finalization of this intermediate line. 
                textLine.Dispose();
            } 
            return collapsedTextLine;
        }