コード例 #1
0
 internal virtual IList <ICompiledParagraphInstance> Parse(string richText)
 {
     m_currentStyle                = new CompiledStyleInfo();
     m_currentParagraph            = new CompiledParagraphInfo();
     m_paragraphInstanceCollection = m_IRichTextInstanceCreator.CreateParagraphInstanceCollection();
     if (!string.IsNullOrEmpty(richText))
     {
         InternalParse(richText);
     }
     m_currentParagraph = new CompiledParagraphInfo();
     if (m_paragraphInstanceCollection.Count == 0)
     {
         m_currentParagraphInstance       = CreateParagraphInstance();
         m_currentTextRunInstance         = CreateTextRunInstance();
         m_currentParagraphInstance.Style = m_IRichTextInstanceCreator.CreateStyleInstance(isParagraph: true);
         m_currentTextRunInstance.Style   = m_IRichTextInstanceCreator.CreateStyleInstance(isParagraph: false);
     }
     else
     {
         for (int i = 0; i < m_paragraphInstanceCollection.Count; i++)
         {
             m_currentParagraphInstance = m_paragraphInstanceCollection[i];
             if (m_currentParagraphInstance.CompiledTextRunInstances == null || m_currentParagraphInstance.CompiledTextRunInstances.Count == 0)
             {
                 m_currentTextRunInstance       = CreateTextRunInstance();
                 m_currentTextRunInstance.Style = m_IRichTextInstanceCreator.CreateStyleInstance(isParagraph: true);
             }
         }
     }
     CloseParagraph();
     return(m_paragraphInstanceCollection);
 }
コード例 #2
0
        private void ApplyPendingMargins()
        {
            ICompiledParagraphInstance lastPopulatedParagraph = m_flatStore.LastPopulatedParagraph;
            ReportSize pendingMarginBottom = m_flatStore.PendingMarginBottom;

            if (IsNonEmptySize(pendingMarginBottom))
            {
                if (lastPopulatedParagraph != null)
                {
                    ReportSize marginTop = m_flatStore.MarginTop;
                    if (marginTop == null)
                    {
                        AddToParagraphSpaceAfter(lastPopulatedParagraph, pendingMarginBottom);
                    }
                    else if (pendingMarginBottom.ToMillimeters() >= marginTop.ToMillimeters())
                    {
                        AddToParagraphSpaceAfter(lastPopulatedParagraph, pendingMarginBottom);
                        m_flatStore.ClearMarginTop();
                    }
                }
                else
                {
                    m_flatStore.UpdateMarginTop(pendingMarginBottom);
                }
                m_flatStore.ClearPendingMarginBottom();
            }
            m_flatStore.LastPopulatedParagraph = null;
        }
コード例 #3
0
 public virtual IList <ICompiledParagraphInstance> Parse(string richText)
 {
     this.m_currentStyle                = new CompiledStyleInfo();
     this.m_currentParagraph            = new CompiledParagraphInfo();
     this.m_paragraphInstanceCollection = this.m_IRichTextInstanceCreator.CreateParagraphInstanceCollection();
     if (!string.IsNullOrEmpty(richText))
     {
         this.InternalParse(richText);
     }
     this.m_currentParagraph = new CompiledParagraphInfo();
     if (this.m_paragraphInstanceCollection.Count == 0)
     {
         this.m_currentParagraphInstance       = this.CreateParagraphInstance();
         this.m_currentTextRunInstance         = this.CreateTextRunInstance();
         this.m_currentParagraphInstance.Style = this.m_IRichTextInstanceCreator.CreateStyleInstance(true);
         this.m_currentTextRunInstance.Style   = this.m_IRichTextInstanceCreator.CreateStyleInstance(false);
     }
     else
     {
         for (int i = 0; i < this.m_paragraphInstanceCollection.Count; i++)
         {
             this.m_currentParagraphInstance = this.m_paragraphInstanceCollection[i];
             if (this.m_currentParagraphInstance.CompiledTextRunInstances == null || this.m_currentParagraphInstance.CompiledTextRunInstances.Count == 0)
             {
                 this.m_currentTextRunInstance       = this.CreateTextRunInstance();
                 this.m_currentTextRunInstance.Style = this.m_IRichTextInstanceCreator.CreateStyleInstance(true);
             }
         }
     }
     this.CloseParagraph();
     return(this.m_paragraphInstanceCollection);
 }
コード例 #4
0
 private void StoreLastParagraph(ICompiledParagraphInstance paragraphInstance)
 {
     m_lastParagraph = paragraphInstance;
     if (m_parentParagraph != null)
     {
         m_parentParagraph.StoreLastParagraph(paragraphInstance);
     }
 }
コード例 #5
0
 private void ResetParagraph()
 {
     m_leftIndentSet    = false;
     m_rightIndentSet   = false;
     m_hangingIndentSet = false;
     m_spaceAfterSet    = false;
     m_marginBottomSet  = false;
     m_hasSpaceBefore   = false;
     m_lastParagraph    = null;
 }
コード例 #6
0
        protected virtual ICompiledTextRunInstance CreateTextRunInstance()
        {
            if (m_currentParagraphInstance == null)
            {
                m_currentParagraphInstance = CreateParagraphInstance();
            }
            IList <ICompiledTextRunInstance> compiledTextRunInstances = m_currentParagraphInstance.CompiledTextRunInstances;
            ICompiledTextRunInstance         compiledTextRunInstance  = m_IRichTextInstanceCreator.CreateTextRunInstance();
            ICompiledStyleInstance           styleInstance            = compiledTextRunInstance.Style = m_IRichTextInstanceCreator.CreateStyleInstance(isParagraph: false);

            m_currentStyle.PopulateStyleInstance(styleInstance, isParagraphStyle: false);
            compiledTextRunInstances.Add(compiledTextRunInstance);
            return(compiledTextRunInstance);
        }
コード例 #7
0
        protected virtual ICompiledTextRunInstance CreateTextRunInstance()
        {
            if (this.m_currentParagraphInstance == null)
            {
                this.m_currentParagraphInstance = this.CreateParagraphInstance();
            }
            IList <ICompiledTextRunInstance> compiledTextRunInstances = this.m_currentParagraphInstance.CompiledTextRunInstances;
            ICompiledTextRunInstance         compiledTextRunInstance  = this.m_IRichTextInstanceCreator.CreateTextRunInstance();
            ICompiledStyleInstance           styleInstance            = compiledTextRunInstance.Style = this.m_IRichTextInstanceCreator.CreateStyleInstance(false);

            this.m_currentStyle.PopulateStyleInstance(styleInstance, false);
            compiledTextRunInstances.Add(compiledTextRunInstance);
            return(compiledTextRunInstance);
        }
コード例 #8
0
        protected virtual ICompiledParagraphInstance CreateParagraphInstance()
        {
            if (!m_allowMultipleParagraphs && m_onlyParagraphInstance != null)
            {
                m_currentParagraphInstance = m_onlyParagraphInstance;
                AppendText(Environment.NewLine, onlyIfValueExists: true);
                return(m_onlyParagraphInstance);
            }
            ICompiledParagraphInstance compiledParagraphInstance = m_IRichTextInstanceCreator.CreateParagraphInstance();

            if (m_allowMultipleParagraphs)
            {
                m_currentParagraph.PopulateParagraph(compiledParagraphInstance);
                int listLevel = compiledParagraphInstance.ListLevel;
                if (listLevel > 9)
                {
                    if (!m_loggedListLevelWarning)
                    {
                        m_richTextLogger.RegisterOutOfRangeSizeWarning("ListLevel", Convert.ToString(listLevel, CultureInfo.InvariantCulture), Convert.ToString(0, CultureInfo.InvariantCulture), Convert.ToString(9, CultureInfo.InvariantCulture));
                        m_loggedListLevelWarning = true;
                    }
                    compiledParagraphInstance.ListLevel = 9;
                }
            }
            else
            {
                m_onlyParagraphInstance = compiledParagraphInstance;
            }
            ICompiledStyleInstance compiledStyleInstance = m_IRichTextInstanceCreator.CreateStyleInstance(isParagraph: true);

            m_currentStyle.PopulateStyleInstance(compiledStyleInstance, isParagraphStyle: true);
            compiledParagraphInstance.Style = compiledStyleInstance;
            IList <ICompiledTextRunInstance> list2 = compiledParagraphInstance.CompiledTextRunInstances = m_IRichTextInstanceCreator.CreateTextRunInstanceCollection();

            m_paragraphInstanceCollection.Add(compiledParagraphInstance);
            return(compiledParagraphInstance);
        }
コード例 #9
0
        internal void PopulateParagraph(ICompiledParagraphInstance paragraphInstance)
        {
            ApplyPendingMargins();
            m_flatStore.LastPopulatedParagraph = paragraphInstance;
            paragraphInstance.ListStyle        = m_flatStore.ListStyle;
            m_flatStore.ListStyle       = ListStyle.None;
            paragraphInstance.ListLevel = m_flatStore.ListLevel;
            ReportSize leftIndent = LeftIndent;

            if (leftIndent != null)
            {
                paragraphInstance.LeftIndent = leftIndent;
            }
            ReportSize rightIndent = RightIndent;

            if (rightIndent != null)
            {
                paragraphInstance.RightIndent = rightIndent;
            }
            ReportSize hangingIndent = HangingIndent;

            if (hangingIndent != null)
            {
                paragraphInstance.HangingIndent = hangingIndent;
            }
            ReportSize marginTop   = MarginTop;
            ReportSize spaceBefore = SpaceBefore;

            if (spaceBefore != null || marginTop != null)
            {
                paragraphInstance.SpaceBefore = ReportSize.SumSizes(marginTop, spaceBefore);
                m_flatStore.SpaceBefore       = null;
                m_flatStore.ClearMarginTop();
            }
            StoreLastParagraph(paragraphInstance);
        }
コード例 #10
0
 protected virtual void CloseParagraph()
 {
     m_currentParagraphInstance = null;
     m_currentTextRunInstance   = null;
 }
コード例 #11
0
 private void AddToParagraphSpaceAfter(ICompiledParagraphInstance paragraphInstance, ReportSize additionalSpace)
 {
     paragraphInstance.SpaceAfter = ReportSize.SumSizes(paragraphInstance.SpaceAfter, additionalSpace);
 }
 bool ICollection <ICompiledParagraphInstance> .Remove(ICompiledParagraphInstance item)
 {
     return(m_compiledParagraphInstances.Remove((CompiledParagraphInstance)item));
 }
 bool ICollection <ICompiledParagraphInstance> .Contains(ICompiledParagraphInstance item)
 {
     return(m_compiledParagraphInstances.Contains((CompiledParagraphInstance)item));
 }
 void ICollection <ICompiledParagraphInstance> .Add(ICompiledParagraphInstance item)
 {
     m_compiledParagraphInstances.Add((CompiledParagraphInstance)item);
 }
 void IList <ICompiledParagraphInstance> .Insert(int index, ICompiledParagraphInstance item)
 {
     m_compiledParagraphInstances.Insert(index, (CompiledParagraphInstance)item);
 }
 int IList <ICompiledParagraphInstance> .IndexOf(ICompiledParagraphInstance item)
 {
     return(m_compiledParagraphInstances.IndexOf((CompiledParagraphInstance)item));
 }