From 3f2826cb0e67295d81244fac74db2a7ebcb7fbad Mon Sep 17 00:00:00 2001 From: RKrom Date: Sat, 7 Aug 2010 15:12:37 +0000 Subject: [PATCH] Merge from BRANCH: Workaround for HTML paste problems, reported as Bug #3031672 git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@794 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- GreenshotEditor/Drawing/Surface.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/GreenshotEditor/Drawing/Surface.cs b/GreenshotEditor/Drawing/Surface.cs index b0cc81eb7..375dbea39 100644 --- a/GreenshotEditor/Drawing/Surface.cs +++ b/GreenshotEditor/Drawing/Surface.cs @@ -650,10 +650,22 @@ namespace Greenshot.Drawing { } } } else if ( ClipboardHelper.GetFormats().Contains("HTML Format")) { - HtmlFragment htmlFragment = HtmlFragment.FromClipboard(); - DeselectAllElements(); - HtmlContainer htmlContainer = AddHtmlContainer(htmlFragment.Fragment, 0, 0); - SelectElement(htmlContainer); + try { + HtmlFragment htmlFragment = HtmlFragment.FromClipboard(); + DeselectAllElements(); + HtmlContainer htmlContainer = AddHtmlContainer(htmlFragment.Fragment, 0, 0); + SelectElement(htmlContainer); + } catch (Exception e) { + LOG.Warn("Problem pasting HTML from the clipboard: ", e); + // Switch to plain text + string text = Clipboard.GetText(); + if (text != null) { + DeselectAllElements(); + ITextContainer textContainer = AddTextContainer(text, HorizontalAlignment.Center, VerticalAlignment.CENTER, + FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Black, Color.Transparent); + SelectElement(textContainer); + } + } } else if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); if (text != null) {