Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update gitignore for VS2017 * Fix exception for pasting objects copied from desktop * Refactor ClipboardUtil
- Loading branch information
1 parent
8540685
commit 7fa8625
Showing
16 changed files
with
87 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Windows.Forms; | ||
|
||
using Microsoft.Office.Interop.PowerPoint; | ||
|
||
using PowerPointLabs.ActionFramework.Common.Log; | ||
using PowerPointLabs.Models; | ||
|
||
namespace PowerPointLabs.Utils | ||
{ | ||
internal static class ClipboardUtil | ||
{ | ||
#region API | ||
|
||
public static bool IsClipboardEmpty() | ||
{ | ||
IDataObject clipboardData = Clipboard.GetDataObject(); | ||
return clipboardData == null || clipboardData.GetFormats().Length == 0; | ||
} | ||
|
||
public static ShapeRange PasteShapesFromClipboard(PowerPointSlide slide) | ||
{ | ||
try | ||
{ | ||
// Note: Some copied objects are pasted on currentSlide rather than the desired slide (e.g. jpg from desktop), | ||
// so we must check whether it is pasted correctly, else we cut-and-paste it into the correct slide. | ||
|
||
int initialSlideShapesCount = slide.Shapes.Count; | ||
ShapeRange pastedShapes = slide.Shapes.Paste(); | ||
|
||
int finalSlideShapesCount = slide.Shapes.Count; | ||
if (pastedShapes.Count >= 1 && finalSlideShapesCount == initialSlideShapesCount) | ||
{ | ||
pastedShapes.Cut(); | ||
pastedShapes = slide.Shapes.Paste(); | ||
} | ||
|
||
return pastedShapes; | ||
} | ||
catch (COMException e) | ||
{ | ||
// May be thrown if there is placeholder shape in clipboard | ||
Logger.LogException(e, "PasteShapeFromClipboard"); | ||
return null; | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters