Exemple #1
0
        //Convert the first "not empty" header element in a document model into a TextRange
        //composed by an hyperlink to the page and a summary composed up to "size" charactes.
        public void AddFirstHeader(Microsoft.Office.Interop.PowerPoint.TextRange parent, Document doc, Page page, string title, int size)
        {
            Microsoft.Office.Interop.PowerPoint.TextRange tr1;
            tr1             = parent.InsertAfter("\r");
            tr1.IndentLevel = 1;
            Microsoft.Office.Interop.PowerPoint.Hyperlink link = tr1.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].Hyperlink;
            link.Address       = wiki.site.site + wiki.site.indexPath + "index.php?title=" + HttpUtility.UrlEncode(page.title);
            link.TextToDisplay = title;
            tr1.InsertAfter(". ");
            int len = tr1.Text.Length;

            for (int i = 0; i < doc.headers.Count; i++)
            {
                Header header = doc.headers[i];
                if (!IsEmptyHeader(header))
                {
                    tr1.InsertAfter(Header2Text(header, 0, size - title.Length, true));
                    break;
                }
            }
            tr1.InsertAfter("\r");
        }
Exemple #2
0
        //Convert an header element into PowerPoint TextRage
        public void AddHeader(Microsoft.Office.Interop.PowerPoint.TextRange parent, Header header, bool firstSpecial, int maxElems)
        {
            Microsoft.Office.Interop.PowerPoint.TextRange tr = null;
            if ((maxElems < 1) || (maxElems > header.elements.Count))
            {
                maxElems = header.elements.Count;
            }
            bool trim = true;

            for (int i = 0; i < maxElems; i++)
            {
                Element e = header.elements[i];
                if (e is NewLine)
                {
                    trim = true;
                    tr   = parent.InsertAfter("\r");
                    tr   = null;
                }
                else
                {
                    string row = e.ToString();
                    if (trim)
                    {
                        row = row.TrimStart();
                    }
                    trim = false;
                    int level = 1;
                    if (!String.IsNullOrEmpty(row))
                    {
                        if (e is ListItem)
                        {
                            level          = (e as ListItem).level + 1;
                            tr             = parent.InsertAfter(row.Trim() + "\r");
                            tr.IndentLevel = level;
                            trim           = true;
                        }
                        else if (e is HyperLink)
                        {
                            HyperLink link = e as HyperLink;
                            if (tr == null)
                            {
                                tr = parent;
                            }
                            tr = tr.InsertAfter(" ");
                            Microsoft.Office.Interop.PowerPoint.Hyperlink l = tr.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].Hyperlink;
                            string url = link.URL;
                            if (url != null)
                            {
                                if ((!url.StartsWith("http:")) || (!url.StartsWith("mailto:")))
                                {
                                    url = wiki.site.site + url;
                                }
                                l.Address = url;
                            }
                            l.TextToDisplay = link.text.ToString();
                        }
                        else
                        {
                            tr = parent.InsertAfter(row);
                            if (e is Text)
                            {
                                CopyFormatting(e as Text, tr);
                            }
                        }
                    }
                }
            }
            if (firstSpecial)
            {
                if (header.elements.Count == 1)
                {
                    tr.ParagraphFormat.Bullet.Visible = MsoTriState.msoFalse;
                    tr.Text = '\t' + tr.Text;
                }
            }
        }