Exemplo n.º 1
0
 public Shape AddPlaceholder(PpPlaceholderType Type, float Left = -1f, float Top = -1f, float Width = -1f, float Height = -1f)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Fake a copy by creating a similar object with the same formats
        /// Copy/Pasting MsoPlaceHolder doesn't work.
        /// Note: Shapes.AddPlaceholder(..) does not work as well.
        /// It restores a deleted placeholder to the slide, not create a shape
        /// </summary>
        /// <param name="formats"></param>
        /// <param name="msoPlaceHolder"></param>
        /// <param name="shapesSource">Shapes object, source of shapes</param>
        /// <returns>returns null if input placeholder is not supported</returns>
        public static Shape CopyMsoPlaceHolder(Format[] formats, Shape msoPlaceHolder, Shapes shapesSource)
        {
            PpPlaceholderType realType = msoPlaceHolder.PlaceholderFormat.Type;

            // charts, tables, pictures & smart shapes may return a general type,
            // ppPlaceHolderObject or ppPlaceHolderVerticalObject
            bool isGeneralType = realType == PpPlaceholderType.ppPlaceholderObject ||
                                 realType == PpPlaceholderType.ppPlaceholderVerticalObject;

            if (isGeneralType)
            {
                realType = GetSpecificPlaceholderType(msoPlaceHolder);
            }

            // create an appropriate shape, based on placeholder type
            Shape shapeTemplate = null;

            switch (realType)
            {
            // the type never seems to be anything other than subtitle, center title, title, body or object.
            // still, place the rest here to be safe.
            case PpPlaceholderType.ppPlaceholderBody:
            case PpPlaceholderType.ppPlaceholderCenterTitle:
            case PpPlaceholderType.ppPlaceholderTitle:
            case PpPlaceholderType.ppPlaceholderSubtitle:
            case PpPlaceholderType.ppPlaceholderVerticalBody:
            case PpPlaceholderType.ppPlaceholderVerticalTitle:
                // not safe to do shape.Duplicate(), the duplicated textbox has differences in configuration
                // width is one example. more investigation is required to find out the exact differences
                shapeTemplate = shapesSource.AddTextbox(
                    msoPlaceHolder.TextFrame.Orientation,
                    msoPlaceHolder.Left,
                    msoPlaceHolder.Top,
                    msoPlaceHolder.Width,
                    msoPlaceHolder.Height);
                break;

            case PpPlaceholderType.ppPlaceholderChart:
            case PpPlaceholderType.ppPlaceholderOrgChart:
                // not much value in copying charts, differed for now
                break;

            case PpPlaceholderType.ppPlaceholderTable:
                // not much value in copying tables, differed for now
                break;

            case PpPlaceholderType.ppPlaceholderPicture:
            case PpPlaceholderType.ppPlaceholderBitmap:
                // must use duplicate. there is no way to create a replacement picture
                // as the image's source is not obtainable through the Shape API
                var tempShape = msoPlaceHolder.Duplicate()[1];
                tempShape.Copy();
                shapeTemplate = shapesSource.Paste()[1];
                tempShape.Delete();
                break;

            case PpPlaceholderType.ppPlaceholderVerticalObject:
            case PpPlaceholderType.ppPlaceholderObject:
                // already narrowed down the type
                // should only perform actions valid for all placeholder objects here
                // do nothing for now
                break;

            default:
                // types not listed above are types that do not make sense to be copied in pptlabs
                // eg. footer, header, date placeholders
                break;
            }

            if (shapeTemplate == null)
            {
                // placeholder type is not supported, no copy made
                return(null);
            }

            ApplyFormats(formats, msoPlaceHolder, shapeTemplate);
            return(shapeTemplate);
        }
Exemplo n.º 3
0
        public PPTDocument ReadAll(int width, int height)
        {
            if (Directory.Exists(_tempPath) == false)
            {
                return(null);
            }

            int slideNumber = 0;

            List <string> files = new List <string>();

            files.AddRange(Directory.GetFiles(_tempPath));

            files.Sort(CompareOnlyNumbers);

            PPTDocument document = new PPTDocument();

            for (int i = 1; i <= _current.Slides.Count; i++)
            {
                Slide slide = null;

                try
                {
                    slide = _current.Slides[i];
                }
                catch
                {
                }

                if (slide == null)
                {
                    continue;
                }

                string note           = string.Empty;
                int    animationCount = 0;

                SlideRange nodePath = null;

                try
                {
                    nodePath = slide.NotesPage;
                }
                catch { }

                if (nodePath != null)
                {
                    foreach (Shape shape in nodePath.Shapes)
                    {
                        PpPlaceholderType currentType = PpPlaceholderType.ppPlaceholderObject;

                        try
                        {
                            currentType = shape.PlaceholderFormat.Type;
                        }
                        catch { }

                        if (currentType == PpPlaceholderType.ppPlaceholderBody)
                        {
                            if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                            {
                                if (shape.TextFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                                {
                                    note += shape.TextFrame.TextRange.Text;
                                }
                            }
                        }

                        AnimationSettings animationSettings = null;

                        try
                        {
                            animationSettings = shape.AnimationSettings;

                            if (animationSettings.Animate == Microsoft.Office.Core.MsoTriState.msoTrue)
                            {
                                animationCount++;
                            }
                        }
                        catch { }
                    }
                }

                try
                {
                    foreach (Effect effect in slide.TimeLine.MainSequence)
                    {
                        if (effect.Timing.TriggerType == MsoAnimTriggerType.msoAnimTriggerOnPageClick)
                        {
                            animationCount++;
                        }
                    }
                }
                catch { }

                PPTPage page = new PPTPage();
                page.Note           = note;
                page.ImageAsText    = ConvertToImage(files[slideNumber], width, height);
                page.AnimationCount = animationCount;

                slideNumber++;

                document.List.Add(page);
            }

            document.Count  = document.List.Count;
            document.Width  = width;
            document.Height = height;
            return(document);
        }
 public MsoPlaceholderException(PpPlaceholderType t)
 {
     T = t;
 }
Exemplo n.º 5
0
 public Shape AddPlaceholder(PpPlaceholderType Type, float Left = -1f, float Top = -1f, float Width = -1f, float Height = -1f)
 {
     throw new NotImplementedException();
 }