private string GrowToAnchorParent(HTMLData htmlData)
        {
            if (htmlData.OnlyImageElement == null)
            {
                return(null);
            }

            string html;
            // Load up the html document from the clipboard to a document to examine the html about to be inserted
            MshtmlMarkupServices markupServices = new MshtmlMarkupServices(htmlData.HTMLDocument as IMarkupServicesRaw);
            MarkupRange          range          = markupServices.CreateMarkupRange(htmlData.OnlyImageElement, true);

            // look to see if this is a case where the inserted html is <a>|<img>|</a>
            MarkupContext markupContextStart = range.Start.Left(true);
            MarkupContext markupContextEnd   = range.End.Right(true);

            // if that is the cause, change the html about to be inserted to |<a><img></a>|
            if (markupContextStart.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_ExitScope &&
                markupContextEnd.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_ExitScope &&
                markupContextStart.Element.tagName == "A" &&
                markupContextEnd.Element.tagName == "A")
            {
                html = markupContextStart.Element.outerHTML;
            }
            else
            {
                html = htmlData.HTMLSelection;
            }

            return(html);
        }
Esempio n. 2
0
        /// <inheritdoc/>
        protected override void ExportPageBegin(ReportPage page)
        {
            if (ExportMode == ExportType.Export)
            {
                base.ExportPageBegin(page);
            }
            pagesCount++;
            if (!WebMode)
            {
                if (singlePage)
                {
                    d            = new HTMLData();
                    d.page       = page;
                    d.ReportPage = pagesCount;
                    d.PageNumber = pagesCount;
                    if (navigator)
                    {
                        if (saveStreams)
                        {
                            d.PagesStream = new MemoryStream();
                            ExportHTMLPageBegin(d);
                        }
                        else
                        {
                            d.PagesStream = new FileStream(singlePageFileName, FileMode.Append);
                            ExportHTMLPageBegin(d);
                        }
                    }
                    else
                    {
                        if (format == HTMLExportFormat.HTML)
                        {
                            d.PagesStream = Stream;
                        }
                        else
                        {
                            d.PagesStream = mimeStream;
                        }

                        ExportHTMLPageBegin(d);
                    }
                }
                else
                {
                    ProcessPageBegin(pagesCount - 1, pagesCount, page);
                }
            }
            else
            {
                // Web
                ProcessPageBegin(pagesCount - 1, pagesCount, page);
            }
        }
Esempio n. 3
0
        private static bool IsOfficeHtml(HTMLData data)
        {
            string generator = data.HTMLMetaData.Generator;

            if (String.IsNullOrEmpty(generator))
            {
                return(false);
            }
            return
                (generator.StartsWith("Microsoft Word") || generator.StartsWith("Microsoft Excel") ||
                 generator.StartsWith("Microsoft PowerPoint"));
        }
        /// <summary>
        /// Grabs an HTML img copied in the clipboard and pastes it into the document.
        /// </summary>
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            using (new WaitCursor())
            {
                try
                {
                    HTMLData htmlData = DataMeister.HTMLData;
                    string   baseUrl  = UrlHelper.GetBaseUrl(htmlData.SourceURL);
                    string   html     = htmlData.HTMLSelection;

                    if (HtmlHandler.IsPasteFromSharedCanvas(DataMeister))
                    {
                        if (action == DataAction.Move)
                        {
                            // if we are dragging and dropping the image, we need to grow to find the anchor for an image
                            html = GrowToAnchorParent(htmlData);
                        }
                        else
                        {
                            // if we are copying and pasting an image from writer, we need to change temp path references the orginal file path
                            if (htmlData.OnlyImageElement != null)
                            {
                                // WinLive 96840 - Copying and pasting images within shared canvas should persist source
                                // decorator settings. "wlCopySrcUrl" is inserted while copy/pasting within canvas.
                                // Insert wlCopySrcUrl attribute
                                html = ImageCopyFixupHelper.FixupSourceUrlForCopy(html);
                            }
                            html = EditorContext.FixImageReferences(html, htmlData.SourceURL);
                        }
                    }
                    else
                    {
                        html = EditorContext.FixImageReferences(html, htmlData.SourceURL);
                        html = EditorContext.HtmlGenerationService.CleanupHtml(html, baseUrl, HtmlCleanupRule.Normal);
                    }

                    html = EditorContext.HtmlGenerationService.GenerateHtmlFromHtmlFragment(html, baseUrl);
                    EditorContext.InsertHtml(begin, end, html, DataMeister.HTMLData.SourceURL);

                    return(true);
                }
                catch (Exception e)
                {
                    //bugfix 1696, put exceptions into the trace log.
                    Trace.Fail("Exception while inserting HTML: " + e.Message, e.StackTrace);
                    return(false);
                }
            }
        }
Esempio n. 5
0
        private void ExportHTMLPageFinalWeb(FastString CSS, FastString Page, HTMLData d, float MaxWidth, float MaxHeight)
        {
            CalcPageSize(pages[d.CurrentPage], MaxWidth, MaxHeight);

            if (Page != null)
            {
                pages[d.CurrentPage].PageText = Page.ToString();
                Page.Clear();
            }
            if (CSS != null)
            {
                pages[d.CurrentPage].CSSText = CSS.ToString();
                CSS.Clear();
            }
            pages[d.CurrentPage].PageEvent.Set();
        }
Esempio n. 6
0
 private void ExportHTMLPageFinal(FastString CSS, FastString Page, HTMLData d, float MaxWidth, float MaxHeight)
 {
     if (!webMode)
     {
         if (!singlePage)
         {
             Page.AppendLine(BODY_END);
         }
         if (d.PagesStream == null)
         {
             string pageFileName = targetIndexPath + targetFileName + d.PageNumber.ToString() + ".html";
             if (saveStreams)
             {
                 string fileName  = singlePage ? singlePageFileName : pageFileName;
                 int    i         = GeneratedFiles.IndexOf(fileName);
                 Stream outStream = (i == -1) ? new MemoryStream() : generatedStreams[i];
                 DoPage(outStream, documentTitle, CSS, Page);
                 GeneratedUpdate(fileName, outStream);
             }
             else
             {
                 GeneratedFiles.Add(pageFileName);
                 using (FileStream outStream = new FileStream(pageFileName, FileMode.Create))
                 {
                     DoPage(outStream, documentTitle, CSS, Page);
                 }
             }
         }
         else
         {
             DoPage(d.PagesStream, documentTitle, CSS, Page);
         }
     }
     else
     {
         ExportHTMLPageFinalWeb(CSS, Page, d, MaxWidth, MaxHeight);
     }
 }
        private void ExportHTMLPageLayeredEnd(HTMLData d)
        {
            // to do
            if (d.page.Watermark.Enabled && d.page.Watermark.ShowImageOnTop)
            {
                Watermark(htmlPage, d.page, false);
            }

            if (d.page.Watermark.Enabled && d.page.Watermark.ShowTextOnTop)
            {
                Watermark(htmlPage, d.page, true);
            }

            ExportPageStylesLayers(css, d.PageNumber);

            if (singlePage)
            {
                hPos = 0;
                prevStyleListIndex = cssStyles.Count;
            }
            htmlPage.Append("</div>");

            ExportHTMLPageFinal(css, htmlPage, d, maxWidth, maxHeight);
        }
Esempio n. 8
0
 /// <summary>
 /// Process Page with number p and real page ReportPage
 /// </summary>
 /// <param name="p"></param>
 /// <param name="ReportPage"></param>
 /// <param name="page"></param>
 public void ProcessPageBegin(int p, int ReportPage, ReportPage page)
 {
     d = new HTMLData(ReportPage, pagesCount, p, page, null);
     ExportHTMLPageBegin(d);
 }
        private void ExportHTMLPageLayeredBegin(HTMLData d)
        {
            if (!singlePage && !WebMode)
            {
                cssStyles.Clear();
            }

            css      = new FastString();
            htmlPage = new FastString();

            ReportPage reportPage = d.page;

            if (reportPage != null)
            {
                maxWidth  = ExportUtils.GetPageWidth(reportPage) * Units.Millimeters;
                maxHeight = ExportUtils.GetPageHeight(reportPage) * Units.Millimeters;

                if (enableMargins)
                {
                    leftMargin = reportPage.LeftMargin * Units.Millimeters;
                    topMargin  = reportPage.TopMargin * Units.Millimeters;
                }
                else
                {
                    maxWidth  -= (reportPage.LeftMargin + reportPage.RightMargin) * Units.Millimeters;
                    maxHeight -= (reportPage.TopMargin + reportPage.BottomMargin) * Units.Millimeters;
                    leftMargin = 0;
                    topMargin  = 0;
                }

                currentPage = d.PageNumber - 1;

                ExportHTMLPageStart(htmlPage, d.PageNumber, d.CurrentPage);

                doPageBreak = (singlePage && pageBreaks);

                htmlPage.Append(HTMLGetAncor((d.PageNumber).ToString()));

                htmlPage.Append("<div ").Append(doPageBreak ? "class=\"frpage\"" : String.Empty).
                Append(" style=\"position:relative;width:").Append(Px(maxWidth * Zoom + 3)).
                Append("height:").Append(Px(maxHeight * Zoom));

                if (reportPage.Fill is SolidFill)
                {
                    SolidFill fill = reportPage.Fill as SolidFill;
                    htmlPage.Append("; background-color:").
                    Append(fill.Color.A == 0 ? "transparent" : ExportUtils.HTMLColor(fill.Color));
                }
                htmlPage.Append("\">");

                if (!(reportPage.Fill is SolidFill))
                {
                    // to-do for picture background
                }

                if (reportPage.Watermark.Enabled && !reportPage.Watermark.ShowImageOnTop)
                {
                    Watermark(htmlPage, reportPage, false);
                }

                if (reportPage.Watermark.Enabled && !reportPage.Watermark.ShowTextOnTop)
                {
                    Watermark(htmlPage, reportPage, true);
                }
            }
        }
Esempio n. 10
0
        private void ExportHTMLPageEnd(object data)
        {
            HTMLData d = (HTMLData)data;

            ExportHTMLPageLayeredEnd(d);
        }
Esempio n. 11
0
        private void ExportHTMLPageBegin(object data)
        {
            HTMLData d = (HTMLData)data;

            ExportHTMLPageLayeredBegin(d);
        }