Пример #1
0
        public static Shape CutAndPaste(Shape shape, Slide slide)
        {
            string tempFilePath = FileDir.GetTemporaryPngFilePath();

            ExportShape(shape, tempFilePath);
            Shape resultShape = ImportPictureToSlide(shape, slide, tempFilePath);

            FileDir.TryDeleteFile(tempFilePath);
            return(resultShape);
        }
Пример #2
0
        public static Shape AddSlideAsShape(PowerPointSlide slideToAdd, PowerPointSlide targetSlide)
        {
            string tempFilePath = FileDir.GetTemporaryPngFilePath();

            ExportSlide(slideToAdd, tempFilePath);
            Shape slideAsShape = ImportPictureToSlide(slideToAdd, targetSlide, tempFilePath);

            FileDir.TryDeleteFile(tempFilePath);
            return(slideAsShape);
        }
Пример #3
0
 private static Shape ImportPictureToSlide(PowerPointSlide slideToAdd, PowerPointSlide targetSlide, string tempFilePath)
 {
     // The AccessViolationException is longer catchable
     if (!FileDir.IsFileReadable(tempFilePath))
     {
         return(targetSlide.Shapes.SafeCopySlide(slideToAdd));
     }
     else
     {
         return(targetSlide.Shapes.AddPicture2(tempFilePath,
                                               MsoTriState.msoFalse,
                                               MsoTriState.msoTrue,
                                               0,
                                               0));
     }
 }
Пример #4
0
 private static Shape ImportPictureToSlide(Shape shapeToAdd, Slide targetSlide, string tempFilePath)
 {
     // The AccessViolationException is no longer catchable
     if (!FileDir.IsFileReadable(tempFilePath))
     {
         return(PPLClipboard.Instance.LockAndRelease(() =>
         {
             shapeToAdd.Cut();
             return targetSlide.Shapes.PasteSpecial(PpPasteDataType.ppPastePNG)[1];
         }));
     }
     else
     {
         shapeToAdd.Delete();
         return(targetSlide.Shapes.AddPicture2(tempFilePath,
                                               MsoTriState.msoFalse,
                                               MsoTriState.msoTrue,
                                               0,
                                               0));
     }
 }