Ejemplo n.º 1
0
        public override void RtfText(string text)
        {
            bool isParagraphNumber = false;

            if (Stack.IsParagraphNumberMode(ParagraphNumberEnum.ListText))
            {
                isParagraphNumber = text.IndexOf(".") > 0;
                if (isParagraphNumber)
                {
                    CurrentParagraph = new Paragraph(text);
                    Doc.AddParagraph(CurrentParagraph);
                    EnclosingParagraphId = null;
                }
            }

            if (!isParagraphNumber)
            {
                if (Stack.IsParagraphNumberMode(ParagraphNumberEnum.PnText))
                {
                    text = text.Trim();

                    // This paragraph is a continuation of the preceding one.
                    if (CurrentParagraph != null)
                    {
                        if (text.CompareTo("-") == 0)
                        {
                            // Add dash separated list in the same paragraph
                            // because there is no way to uniquely identify
                            // each element
                            addTextToCurrentParagraph(text);
                        }
                        else
                        {
                            if (EnclosingParagraphId == null)
                            {
                                EnclosingParagraphId = CurrentParagraph.Id;
                            }

                            // Create the paragraph number
                            string id = EnclosingParagraphId + "." + text;
                            if (id.EndsWith(")"))
                            {
                                id = id.Substring(0, id.Length - 1);
                            }

                            CurrentParagraph = new Paragraph(id);
                            Doc.AddParagraph(CurrentParagraph);
                        }
                    }
                }
                else
                {
                    addTextToCurrentParagraph(text);
                }
            }
        }
Ejemplo n.º 2
0
        public override void RtfKeyword(string key, bool hasParameter, int parameter)
        {
            // Try to recognise a paragraph number \listtext\...
            if (key.Equals("listtext"))
            {
                Stack.CurrentFrame.ParagraphNumberMode = ParagraphNumberEnum.ListText;
            }
            // Try to recognise a list number \pntext
            else if (key.Equals("pntext"))
            {
                Stack.CurrentFrame.ParagraphNumberMode = ParagraphNumberEnum.PnText;
            }


            // When an outline level is encountered, this starts a new paragraph
            else if (key.Equals("outlinelevel"))
            {
                if (CurrentParagraph != null && (CurrentParagraph.Text == null || CurrentParagraph.Text.Length == 0))
                {
                    // The current paragraph has not yet been filled, continue with it.
                }
                else
                {
                    CurrentParagraph = null;
                }
            }

            // \bkmkstart and \bkmkend seems to be related to bookmarks. Ignore the corresponding text
            if (key.Equals("xmlopen") ||
                key.Equals("bkmkstart") ||
                key.Equals("bkmkend") ||
                key.Equals("objclass") ||
                key.Equals("objdata") ||
                key.Equals("field") ||
                key.Equals("datafield") ||
                key.Equals("shpgrp") ||
                key.Equals("headerr") ||
                key.Equals("footerr") ||
                key.Equals("pntxta") ||
                key.Equals("shp") ||
                key.Equals("themedata") ||
                key.Equals("colorschememapping") ||
                key.Equals("lsdlockedexcept") ||
                key.Equals("datastore") ||
                key.Equals("pntxta") ||
                key.Equals("pntxtb") ||
                key.Equals("pict"))
            {
                Stack.CurrentFrame.IgnoreTextMode = IgnoreTextEnum.IgnoreText;
            }

            // Do the paragraph modifications
            if (key.Equals("par"))
            {
                addTextToCurrentParagraph("\n");
            }
            else if (key.Equals("line"))
            {
                addTextToCurrentParagraph("\n");
            }
            else if (key.Equals("cell"))
            {
                addTextToCurrentParagraph(",");
            }

            if (key.Equals("trowd"))
            {
                if (CurrentParagraph != null)
                {
                    CurrentParagraph = new TableRow(CurrentParagraph);
                    Doc.AddParagraph(CurrentParagraph);
                    EnclosingParagraphId = null;
                }
            }
        }