More stability fixes

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1902 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-05-23 15:35:58 +00:00
commit 9360232ea0
3 changed files with 25 additions and 14 deletions

View file

@ -192,15 +192,19 @@ namespace Greenshot.Interop.Office {
// http://msdn.microsoft.com/en-us/library/dd492012%28v=office.12%29.aspx // http://msdn.microsoft.com/en-us/library/dd492012%28v=office.12%29.aspx
// Earlier versions of Outlook also supported an Inspector.HTMLEditor object property, but since Internet Explorer is no longer the rendering engine for HTML messages and posts, HTMLEditor is no longer supported. // Earlier versions of Outlook also supported an Inspector.HTMLEditor object property, but since Internet Explorer is no longer the rendering engine for HTML messages and posts, HTMLEditor is no longer supported.
if (inspector.IsWordMail() && inspector.WordEditor != null) { if (inspector.IsWordMail() && inspector.WordEditor != null) {
if (WordExporter.InsertIntoExistingDocument(inspector.WordEditor, tmpFile)) { try {
LOG.Info("Inserted into Wordmail"); if (WordExporter.InsertIntoExistingDocument(inspector.WordEditor.Application, inspector.WordEditor, tmpFile)) {
LOG.Info("Inserted into Wordmail");
// check the format afterwards, otherwise we lose the selection // check the format afterwards, otherwise we lose the selection
//if (!OlBodyFormat.olFormatHTML.Equals(currentMail.BodyFormat)) { //if (!OlBodyFormat.olFormatHTML.Equals(currentMail.BodyFormat)) {
// LOG.Info("Changing format to HTML."); // LOG.Info("Changing format to HTML.");
// currentMail.BodyFormat = OlBodyFormat.olFormatHTML; // currentMail.BodyFormat = OlBodyFormat.olFormatHTML;
//} //}
return true; return true;
}
} catch (Exception exportException) {
LOG.Error("Error exporting to the word editor, trying to do it via another method", exportException);
} }
} else if (isAppointment) { } else if (isAppointment) {
LOG.Info("Can't export to an appointment if no word editor is used"); LOG.Info("Can't export to an appointment if no word editor is used");

View file

@ -47,7 +47,7 @@ namespace Greenshot.Interop.Office {
for (int i = 1; i <= wordApplication.Documents.Count; i++) { for (int i = 1; i <= wordApplication.Documents.Count; i++) {
using (IWordDocument wordDocument = wordApplication.Documents.item(i)) { using (IWordDocument wordDocument = wordApplication.Documents.item(i)) {
if (wordDocument.ActiveWindow.Caption.StartsWith(wordCaption)) { if (wordDocument.ActiveWindow.Caption.StartsWith(wordCaption)) {
return InsertIntoExistingDocument(wordDocument, tmpFile); return InsertIntoExistingDocument(wordApplication, wordDocument, tmpFile);
} }
} }
} }
@ -56,9 +56,16 @@ namespace Greenshot.Interop.Office {
return false; return false;
} }
internal static bool InsertIntoExistingDocument(IWordDocument wordDocument, string tmpFile) { /// <summary>
if (wordDocument.Application.Selection != null) { /// Internal method for the insert
AddPictureToSelection(wordDocument.Application.Selection, tmpFile); /// </summary>
/// <param name="wordApplication"></param>
/// <param name="wordDocument"></param>
/// <param name="tmpFile"></param>
/// <returns></returns>
internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile) {
if (wordApplication.Selection != null) {
AddPictureToSelection(wordApplication.Selection, tmpFile);
try { try {
wordDocument.ActiveWindow.ActivePane.View.Zoom.Percentage = 100; wordDocument.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
} catch (Exception e) { } catch (Exception e) {
@ -69,7 +76,7 @@ namespace Greenshot.Interop.Office {
} }
} }
try { try {
wordDocument.Application.Activate(); wordApplication.Activate();
} catch {} } catch {}
try { try {
wordDocument.Activate(); wordDocument.Activate();

View file

@ -167,7 +167,7 @@ namespace GreenshotPlugin.Core {
try { try {
CultureInfo cultureInfo = new CultureInfo(culture); CultureInfo cultureInfo = new CultureInfo(culture);
rssFile.Language = cultureInfo.NativeName; rssFile.Language = cultureInfo.NativeName;
} catch (Exception ex) { } catch (Exception) {
LOG.WarnFormat("Can't read the native name of the culture {0}", culture); LOG.WarnFormat("Can't read the native name of the culture {0}", culture);
} }
} }