diff --git a/Greenshot/Destinations/PowerpointDestination.cs b/Greenshot/Destinations/PowerpointDestination.cs index 7c9983003..c8b3a18ef 100644 --- a/Greenshot/Destinations/PowerpointDestination.cs +++ b/Greenshot/Destinations/PowerpointDestination.cs @@ -110,16 +110,6 @@ namespace Greenshot.Destinations { yield return new PowerpointDestination(presentationName); } } - /// - /// Helper method for adding the normal "empty" PowerpointDestination - /// - /// - private IEnumerable AllDynamicDestinations() { - yield return new PowerpointDestination(); - foreach (string presentationName in PowerpointExporter.GetPowerpointPresentations()) { - yield return new PowerpointDestination(presentationName); - } - } public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { string tmpFile = captureDetails.Filename; @@ -133,13 +123,20 @@ namespace Greenshot.Destinations { if (presentationName != null) { PowerpointExporter.ExportToPresentation(presentationName, tmpFile, imageSize, captureDetails.Title); } else { - if (manuallyInitiated) { - PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title); - } else { - ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, AllDynamicDestinations()); - PickerDestination.ShowMenuAtCursor(menu); - return false; + if (!manuallyInitiated) { + List presentations = PowerpointExporter.GetPowerpointPresentations(); + if (presentations.Count > 0) { + List destinations = new List(); + destinations.Add(new PowerpointDestination()); + foreach (string presentation in presentations) { + destinations.Add(new PowerpointDestination(presentation)); + } + ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations); + PickerDestination.ShowMenuAtCursor(menu); + return false; + } } + PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title); } surface.SendMessageEvent(this, SurfaceMessageTyp.Info, lang.GetFormattedString(LangKey.exported_to, Description)); surface.Modified = false; diff --git a/Greenshot/Destinations/WordDestination.cs b/Greenshot/Destinations/WordDestination.cs index 22c08fd79..055443465 100644 --- a/Greenshot/Destinations/WordDestination.cs +++ b/Greenshot/Destinations/WordDestination.cs @@ -112,17 +112,6 @@ namespace Greenshot.Destinations { } } - /// - /// Helper method for adding the normal "empty" WordDestination - /// - /// - private IEnumerable AllDynamicDestinations() { - yield return new WordDestination(); - foreach (string wordCaption in WordExporter.GetWordDocuments()) { - yield return new WordDestination(wordCaption); - } - } - public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { string tmpFile = captureDetails.Filename; if (tmpFile == null || surface.Modified) { @@ -133,13 +122,20 @@ namespace Greenshot.Destinations { if (documentCaption != null) { WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile); } else { - if (manuallyInitiated) { - WordExporter.InsertIntoNewDocument(tmpFile); - } else { - ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, AllDynamicDestinations()); - PickerDestination.ShowMenuAtCursor(menu); - return false; + if (!manuallyInitiated) { + List documents = WordExporter.GetWordDocuments(); + if (documents.Count > 0) { + List destinations = new List(); + destinations.Add(new WordDestination()); + foreach (string document in documents) { + destinations.Add(new WordDestination(document)); + } + ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations); + PickerDestination.ShowMenuAtCursor(menu); + return false; + } } + WordExporter.InsertIntoNewDocument(tmpFile); } surface.SendMessageEvent(this, SurfaceMessageTyp.Info, lang.GetFormattedString(LangKey.exported_to, Description)); surface.Modified = false; diff --git a/GreenshotInterop/OfficeExport/PowerpointExporter.cs b/GreenshotInterop/OfficeExport/PowerpointExporter.cs index 458fff471..ec445bce1 100644 --- a/GreenshotInterop/OfficeExport/PowerpointExporter.cs +++ b/GreenshotInterop/OfficeExport/PowerpointExporter.cs @@ -111,9 +111,13 @@ namespace Greenshot.Interop.Office { if (isLayoutPictureWithCaption) { try { // Using try/catch to make sure problems with the text range don't give an exception. - shape.TextFrame.TextRange.Text = title; + ITextFrame textFrame = shape.TextFrame; + if (textFrame.HasText == MsoTriState.msoTrue) { + textFrame.TextRange.Text = title; + } + shape.AlternativeText = title; } catch (Exception ex) { - LOG.WarnFormat("Problem setting the title to a text-range: {0}", ex.Message); + LOG.Warn("Problem setting the title to a text-range", ex); } } presentation.Application.ActiveWindow.View.GotoSlide(slide.SlideNumber); diff --git a/GreenshotInterop/OfficeInterop/PowerpointInterop.cs b/GreenshotInterop/OfficeInterop/PowerpointInterop.cs index e97b26c0c..296e2f5a1 100644 --- a/GreenshotInterop/OfficeInterop/PowerpointInterop.cs +++ b/GreenshotInterop/OfficeInterop/PowerpointInterop.cs @@ -88,10 +88,12 @@ namespace Greenshot.Interop.Office { ITextFrame TextFrame { get; } void ScaleWidth(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale); void ScaleHeight(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale); + string AlternativeText { get; set; } } public interface ITextFrame : Common { ITextRange TextRange { get; } + MsoTriState HasText { get; } } public interface ITextRange : Common { string Text { get; set; }