mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Fixed bug #3582282 where the capture was cropped. Also fixed the error handling so now when the export failed this is also displayed.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2234 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
cd01b2197b
commit
d49a203b3a
2 changed files with 28 additions and 23 deletions
|
@ -107,48 +107,48 @@ namespace Greenshot.Interop.Office {
|
||||||
float height = imageSize.Height;
|
float height = imageSize.Height;
|
||||||
bool isLayoutPictureWithCaption = false;
|
bool isLayoutPictureWithCaption = false;
|
||||||
IShape shapeForCaption = null;
|
IShape shapeForCaption = null;
|
||||||
bool isWidthResized = false;
|
bool hasScaledWidth = false;
|
||||||
bool isHeightResized = false;
|
bool hasScaledHeight = false;
|
||||||
try {
|
try {
|
||||||
slide = presentation.Slides.Add(presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutPictureWithCaption);
|
slide = presentation.Slides.Add(presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutPictureWithCaption);
|
||||||
isLayoutPictureWithCaption = true;
|
isLayoutPictureWithCaption = true;
|
||||||
// Shapes[2] is the image shape on this layout.
|
// Shapes[2] is the image shape on this layout.
|
||||||
shapeForCaption = slide.Shapes.item(1);
|
shapeForCaption = slide.Shapes.item(1);
|
||||||
IShape shapeForLocation = slide.Shapes.item(2);
|
IShape shapeForLocation = slide.Shapes.item(2);
|
||||||
|
|
||||||
if (width > shapeForLocation.Width) {
|
if (width > shapeForLocation.Width) {
|
||||||
width = shapeForLocation.Width;
|
width = shapeForLocation.Width;
|
||||||
isWidthResized = true;
|
|
||||||
left = shapeForLocation.Left;
|
left = shapeForLocation.Left;
|
||||||
|
hasScaledWidth = true;
|
||||||
} else {
|
} else {
|
||||||
//left = (shapeForLocation.Left + (shapeForLocation.Width / 2)) - (imageSize.Width / 2);
|
|
||||||
shapeForLocation.Width = width;
|
|
||||||
shapeForLocation.Left = left;
|
shapeForLocation.Left = left;
|
||||||
}
|
}
|
||||||
|
shapeForLocation.Width = imageSize.Width;
|
||||||
|
|
||||||
if (height > shapeForLocation.Height) {
|
if (height > shapeForLocation.Height) {
|
||||||
height = shapeForLocation.Height;
|
height = shapeForLocation.Height;
|
||||||
isHeightResized = true;
|
|
||||||
top = shapeForLocation.Top;
|
top = shapeForLocation.Top;
|
||||||
|
hasScaledHeight = true;
|
||||||
} else {
|
} else {
|
||||||
top = (shapeForLocation.Top + (shapeForLocation.Height / 2)) - (imageSize.Height / 2);
|
top = (shapeForLocation.Top + (shapeForLocation.Height / 2)) - (imageSize.Height / 2);
|
||||||
shapeForLocation.Height = height;
|
|
||||||
//shapeForLocation.Top = top;
|
|
||||||
}
|
}
|
||||||
//shapeForLocation.Top = top;
|
shapeForLocation.Height = imageSize.Height;
|
||||||
//LOG.DebugFormat("Shape {0},{1},{2},{3}", shapeForLocation.Left, shapeForLocation.Top, imageSize.Width, imageSize.Height);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.Error(e);
|
LOG.Error(e);
|
||||||
slide = presentation.Slides.Add(presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutBlank);
|
slide = presentation.Slides.Add(presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutBlank);
|
||||||
}
|
}
|
||||||
IShape shape = slide.Shapes.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, width, height);
|
IShape shape = slide.Shapes.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, width, height);
|
||||||
shape.LockAspectRatio = MsoTriState.msoTrue;
|
shape.LockAspectRatio = MsoTriState.msoTrue;
|
||||||
|
shape.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
|
||||||
|
shape.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
|
||||||
|
if (hasScaledWidth) {
|
||||||
|
shape.Width = width;
|
||||||
|
}
|
||||||
|
if (hasScaledHeight) {
|
||||||
|
shape.Height = height;
|
||||||
|
}
|
||||||
shape.Left = left;
|
shape.Left = left;
|
||||||
shape.Top = top;
|
shape.Top = top;
|
||||||
if (!isHeightResized) {
|
|
||||||
shape.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
|
|
||||||
}
|
|
||||||
if (!isWidthResized) {
|
|
||||||
shape.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
|
|
||||||
}
|
|
||||||
shape.AlternativeText = title;
|
shape.AlternativeText = title;
|
||||||
if (isLayoutPictureWithCaption && shapeForCaption != null) {
|
if (isLayoutPictureWithCaption && shapeForCaption != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -164,15 +164,22 @@ namespace Greenshot.Interop.Office {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InsertIntoNewPresentation(string tmpFile, Size imageSize, string title) {
|
public static bool InsertIntoNewPresentation(string tmpFile, Size imageSize, string title) {
|
||||||
|
bool isPictureAdded = false;
|
||||||
using (IPowerpointApplication powerpointApplication = COMWrapper.GetOrCreateInstance<IPowerpointApplication>()) {
|
using (IPowerpointApplication powerpointApplication = COMWrapper.GetOrCreateInstance<IPowerpointApplication>()) {
|
||||||
if (powerpointApplication != null) {
|
if (powerpointApplication != null) {
|
||||||
powerpointApplication.Visible = true;
|
powerpointApplication.Visible = true;
|
||||||
IPresentation presentation = powerpointApplication.Presentations.Add(MsoTriState.msoTrue);
|
IPresentation presentation = powerpointApplication.Presentations.Add(MsoTriState.msoTrue);
|
||||||
AddPictureToPresentation(presentation, tmpFile, imageSize, title);
|
try {
|
||||||
presentation.Application.Activate();
|
AddPictureToPresentation(presentation, tmpFile, imageSize, title);
|
||||||
|
isPictureAdded = true;
|
||||||
|
presentation.Application.Activate();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.Error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return isPictureAdded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,8 +119,7 @@ namespace GreenshotOfficePlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (presentationName != null) {
|
if (presentationName != null) {
|
||||||
PowerpointExporter.ExportToPresentation(presentationName, tmpFile, imageSize, captureDetails.Title);
|
exportInformation.ExportMade = PowerpointExporter.ExportToPresentation(presentationName, tmpFile, imageSize, captureDetails.Title);
|
||||||
exportInformation.ExportMade = true;
|
|
||||||
} else {
|
} else {
|
||||||
if (!manuallyInitiated) {
|
if (!manuallyInitiated) {
|
||||||
List<string> presentations = PowerpointExporter.GetPowerpointPresentations();
|
List<string> presentations = PowerpointExporter.GetPowerpointPresentations();
|
||||||
|
@ -134,8 +133,7 @@ namespace GreenshotOfficePlugin {
|
||||||
return ShowPickerMenu(false, surface, captureDetails, destinations);
|
return ShowPickerMenu(false, surface, captureDetails, destinations);
|
||||||
}
|
}
|
||||||
} else if (!exportInformation.ExportMade) {
|
} else if (!exportInformation.ExportMade) {
|
||||||
PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
|
exportInformation.ExportMade = PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
|
||||||
exportInformation.ExportMade = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProcessExport(exportInformation, surface);
|
ProcessExport(exportInformation, surface);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue