Exemplo n.º 1
0
        private void AppendToLine(TextToken token, double textWidth)
        {
            string text = token.Text;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            _block = _block ?? new TextTokenBlock
            {
                TextAlign    = _lastOpenTag.TextProperties.TextAlign,
                MarginLeft   = _marginLeft,
                MarginRight  = _marginRight,
                FirstTokenID = _firstTokenID,
                TextIndent   = _textIndent
            };

            _block.LastTokenID = token.ID;
            _block.UpdateHeight(GetTextHeight(text));
            if (_separator)
            {
                TextVisualProperties properties = _lastOpenTag.TextProperties.Clone();
                var inlineItem = _block.Inlines.OfType <TextElement>().LastOrDefault();
                if (inlineItem != null && string.IsNullOrEmpty(inlineItem.LinkID))
                {
                    properties.LinkID = string.Empty;
                }
                _block.AddText(" ", properties, _fontSize, GetTextSize(" ", properties));
            }
            _block.AddText(text, _lastOpenTag.TextProperties, _fontSize, GetTextSize(text, _lastOpenTag.TextProperties), token.Part, token.ID);
            _textWidth += textWidth;
        }
Exemplo n.º 2
0
        private void AppendToLine(TagCloseToken token)
        {
            if (!_lastOpenTag.TextProperties.Inline)
            {
                if (_block != null)
                {
                    _block.EndParagraph();
                    _block.LastTokenID = token.ID;
                    _firstTokenID      = token.ID + 1;
                    _output.Enqueue(_block);
                }
                if (_lastOpenTag.TextProperties.MarginBottom > 0.0)
                {
                    _output.Enqueue(new SeparatorTokenBlock(_lastOpenTag.TextProperties.MarginBottom)
                    {
                        FirstTokenID = token.ID,
                        LastTokenID  = token.ID
                    });
                }

                LeaveMargin(_lastOpenTag.TextProperties);
                _block      = null;
                _textWidth  = 0.0;
                _textIndent = 0.0;
                _separator  = false;
            }
            PopTag();
        }
Exemplo n.º 3
0
 private ParagraphInfo CreateParagraph(TextTokenBlock block)
 {
     return(new ParagraphInfo
     {
         TextAlign = block.TextAlign,
         MarginLeft = block.MarginLeft,
         MarginRight = block.MarginRight,
         TextIndent = block.TextIndent
     });
 }
Exemplo n.º 4
0
        private IEnumerable <TokenBlockBase> OutputLines(bool outputCurrentLine)
        {
            while (_output.Count > 0)
            {
                yield return(_output.Dequeue());
            }

            if (outputCurrentLine && _block != null)
            {
                yield return(_block);

                _block = null;
            }
        }
Exemplo n.º 5
0
        private void AppendToLine(NewPageToken token)
        {
            if (_block != null)
            {
                _block.EndLine();
                _block.LastTokenID = token.ID - 1;
                _output.Enqueue(_block);
            }

            var pageBreakLine = new PageBreakBlock();

            pageBreakLine.FirstTokenID = pageBreakLine.LastTokenID = token.ID;
            _output.Enqueue(pageBreakLine);
            _block = null;
        }
Exemplo n.º 6
0
 private void AddInlineToParagraph(TextTokenBlock block)
 {
     _page.Lines.Add(block);
     foreach (TextElementBase baseInlineItem in block.Inlines)
     {
         if (!(baseInlineItem is EOPElement))
         {
             _paragraph.Inlines.Add(baseInlineItem);
         }
         else
         {
             _paragraph = null;
             break;
         }
     }
 }
Exemplo n.º 7
0
 private void AppendToLine(TagOpenToken token)
 {
     if (!token.TextProperties.Inline)
     {
         if (_block != null)
         {
             _block.EndParagraph();
             _firstTokenID = token.ID;
             _output.Enqueue(_block);
         }
         EnterMargin(token.TextProperties);
         _block     = null;
         _textWidth = _textIndent = token.TextProperties.TextIndent;
         _separator = false;
     }
     PushTag(token);
 }
Exemplo n.º 8
0
 private void CreateEmptyLine(TokenBase token)
 {
     if (_block != null)
     {
         _block.EndLine();
         _block.LastTokenID = token.ID - 1;
         _output.Enqueue(_block);
     }
     _block = new TextTokenBlock
     {
         TextAlign    = _lastOpenTag.TextProperties.TextAlign,
         MarginLeft   = _marginLeft,
         MarginRight  = _marginRight,
         FirstTokenID = token.ID,
         LastTokenID  = token.ID,
         TextIndent   = 0.0
     };
     _firstTokenID = token.ID;
     _textWidth    = 0.0;
     _separator    = false;
 }
Exemplo n.º 9
0
        private bool AppendToPage(TextTokenBlock block)
        {
            if (_page.FirstTokenID < 0)
            {
                _page.FirstTokenID = block.FirstTokenID;
            }

            double height = block.Height * (double)AppSettings.Default.FontSettings.FontInterval;

            if (_height + height <= _pageSize.Height)
            {
                _height           += height;
                _page.LastTokenID  = block.LastTokenID;
                _page.LastTextPart = block.GetLastPart();
                if (_paragraph == null)
                {
                    _paragraph = CreateParagraph(block);
                    _page.Paragraphs.Add(_paragraph);
                }
                AddInlineToParagraph(block);
                return(true);
            }
            return(false);
        }