Exemplo n.º 1
0
 /// <summary>
 /// This method assumes that there is valid data on the clipboard. DO NOT lock the clipboard.
 /// </summary>
 public static ShapeRange PasteShapesFromClipboard(PowerPointPresentation pres, PowerPointSlide slide)
 {
     try
     {
         ShapeRange shapes = null;
         try
         {
             shapes = PasteWithCorrectSlideCheck(slide);
             // Try to get enumerator and sees if it throws an error
             // Will throw error if its a web picture
             shapes.GetEnumerator();
             return(shapes);
         }
         catch (COMException e)
         {
             Logger.LogException(e, "PasteShapesFromClipboard");
             // Delete previously pasted "shapes" because it is not a valid shape
             if (shapes != null)
             {
                 shapes[1].SafeDelete();
             }
             ShapeRange picture = TryPastingAsPNG(slide);
             if (picture == null)
             {
                 picture = TryPastingAsBitmap(slide);
             }
             if (picture == null)
             {
                 picture = TryPastingOntoView(pres, slide);
             }
             return(picture);
         }
     }
     catch (COMException e)
     {
         // May be thrown if there is placeholder shape in clipboard
         Logger.LogException(e, "PasteShapesFromClipboard");
         return(null);
     }
 }