public static IReadOnlyList <IAttributedText> CreateParagraphs(this IAttributedText attributedText)
        {
            if (attributedText?.Text == null)
            {
                return(null);
            }

            List <IAttributedText> paragraphs = new List <IAttributedText>();

            int start          = 0;
            int attributeIndex = 0;

            using (var sr = new StringReader(attributedText.Text))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    var length = line.Length;

                    var runs = new List <IAttributedTextRun>();
                    attributeIndex = attributedText.CreateParagraphRun(start, length, runs, attributeIndex);

                    var paragraph = new AttributedText(line, runs);
                    paragraphs.Add(paragraph);

                    start += length + 1;
                }
            }

            return(paragraphs);
        }
Пример #2
0
 static IControl CreateAtomHeaderText()
 {
     return(Theme.Link.Select(linkColor =>
                              Label.FormattedText(
                                  textParts: Observable.Return(
                                      AttributedText.Parts().Text("We also have an ").Link("Atom Plugin", "https://atom.io/packages/fuse", linkColor).Text(".")),
                                  color: Theme.DefaultText,
                                  font: Theme.DefaultFont)).Switch());
 }
Пример #3
0
        static void Main(string[] args)
        {
            TextDocument doc = new TextDocument("c:\\test\\input.odt");

            IList <MasterPage> masterPages = doc.CommonStyles.MasterStyles.MasterPages;

            foreach (MasterPage masterPage in masterPages)
            {
                Header header = masterPage.Header;
                Footer footer = masterPage.Footer;

                if (header != null)
                {
                    IList <IHeaderFooterContent> headerContent = header.Content;

                    foreach (IHeaderFooterContent headerContentElement in headerContent)
                    {
                        if (headerContentElement is Paragraph)
                        {
                            Paragraph paragraph = (Paragraph)headerContentElement;

                            for (int j = 0; j < paragraph.Content.Count; j++)
                            {
                                if (paragraph.Content[j] is AttributedText)
                                {
                                    AttributedText attributedText = (AttributedText)paragraph.Content[j];

                                    for (int a = 0; a < attributedText.Content.Count; a++)
                                    {
                                        if (attributedText.Content[a] is Text)
                                        {
                                            Text text = (Text)attributedText.Content[a];
                                            Console.WriteLine(text.Value);
                                        }
                                    }
                                }
                                else if (paragraph.Content[j] is Text)
                                {
                                    Text text = (Text)paragraph.Content[j];
                                    Console.WriteLine(text.Value);
                                }
                            }
                        }
                    }
                }

                if (footer != null)
                {
                    IList <IHeaderFooterContent> footerContent = footer.Content;

                    foreach (IHeaderFooterContent footerContentElement in footerContent)
                    {
                        if (footerContentElement is Paragraph)
                        {
                            Paragraph paragraph = (Paragraph)footerContentElement;

                            for (int j = 0; j < paragraph.Content.Count; j++)
                            {
                                if (paragraph.Content[j] is AttributedText)
                                {
                                    AttributedText attributedText = (AttributedText)paragraph.Content[j];

                                    for (int a = 0; a < attributedText.Content.Count; a++)
                                    {
                                        if (attributedText.Content[a] is Text)
                                        {
                                            Text text = (Text)attributedText.Content[a];
                                            Console.WriteLine(text.Value);
                                        }
                                    }
                                }
                                else if (paragraph.Content[j] is Text)
                                {
                                    Text text = (Text)paragraph.Content[j];
                                    Console.WriteLine(text.Value);
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Pess any key to close.");
            Console.Read();
        }