public SSlideLayoutAtom(BinaryReader reader)
        {
            int geom = reader.ReadInt32();

            this.Geom = (SlideLayoutType)geom;

            for (int i = 0; i < 8; i++)
            {
                this.PlaceholderTypes[i] = (PlaceholderEnum)reader.ReadByte();
            }
        }
Example #2
0
        public SlideLayoutPart GetOrCreateLayoutPartByLayoutType(SlideLayoutType type,
                                                                 PlaceholderEnum[] placeholderTypes)
        {
            var    masterPart     = this._ctx.GetOrCreateMasterMappingByMasterId(this.MasterId).MasterPart;
            string layoutFilename = Utils.SlideLayoutTypeToFilename(type, placeholderTypes);


            if (!this.LayoutFilenameToLayoutPart.ContainsKey(layoutFilename))
            {
                var slideLayoutDoc = Utils.GetDefaultDocument("slideLayouts." + layoutFilename);

                var layoutPart = masterPart.AddSlideLayoutPart();
                slideLayoutDoc.WriteTo(layoutPart.XmlWriter);
                layoutPart.XmlWriter.Flush();

                this.LayoutFilenameToLayoutPart.Add(layoutFilename, layoutPart);
            }

            return(this.LayoutFilenameToLayoutPart[layoutFilename]);
        }
Example #3
0
        public static string SlideLayoutTypeToFilename(SlideLayoutType type, PlaceholderEnum[] placeholderTypes)
        {
            switch (type)
            {
            case SlideLayoutType.BigObject:
                return("objOnly");

            case SlideLayoutType.Blank:
                return("blank");

            case SlideLayoutType.FourObjects:
                return("fourObj");

            case SlideLayoutType.TitleAndBody:
            {
                PlaceholderEnum body = placeholderTypes[1];

                if (body == PlaceholderEnum.Table)
                {
                    return("tbl");
                }
                else if (body == PlaceholderEnum.OrganizationChart)
                {
                    return("dgm");
                }
                else if (body == PlaceholderEnum.Graph)
                {
                    return("chart");
                }
                else
                {
                    return("obj");
                }
            }

            case SlideLayoutType.TitleOnly:
                return("titleOnly");

            case SlideLayoutType.TitleSlide:
                return("title");

            case SlideLayoutType.TwoColumnsAndTitle:
            {
                PlaceholderEnum leftType  = placeholderTypes[1];
                PlaceholderEnum rightType = placeholderTypes[2];

                if (leftType == PlaceholderEnum.Body && rightType == PlaceholderEnum.Object)
                {
                    return("txAndObj");
                }
                else if (leftType == PlaceholderEnum.Object && rightType == PlaceholderEnum.Body)
                {
                    return("objAndTx");
                }
                else if (leftType == PlaceholderEnum.Body && rightType == PlaceholderEnum.ClipArt)
                {
                    return("txAndClipArt");
                }
                else if (leftType == PlaceholderEnum.ClipArt && rightType == PlaceholderEnum.Body)
                {
                    return("clipArtAndTx");
                }
                else if (leftType == PlaceholderEnum.Body && rightType == PlaceholderEnum.Graph)
                {
                    return("txAndChart");
                }
                else if (leftType == PlaceholderEnum.Graph && rightType == PlaceholderEnum.Body)
                {
                    return("chartAndTx");
                }
                else if (leftType == PlaceholderEnum.Body && rightType == PlaceholderEnum.MediaClip)
                {
                    return("txAndMedia");
                }
                else if (leftType == PlaceholderEnum.MediaClip && rightType == PlaceholderEnum.Body)
                {
                    return("mediaAndTx");
                }
                else
                {
                    return("twoObj");
                }
            }

            case SlideLayoutType.TwoColumnsLeftTwoRows:
            {
                PlaceholderEnum rightType = placeholderTypes[2];

                if (rightType == PlaceholderEnum.Object)
                {
                    return("twoObjAndObj");
                }
                else if (rightType == PlaceholderEnum.Body)
                {
                    return("twoObjAndTx");
                }
                else
                {
                    throw new NotImplementedException(String.Format(
                                                          "Don't know how to map TwoColumnLeftTwoRows with rightType = {0}",
                                                          rightType
                                                          ));
                }
            }

            case SlideLayoutType.TwoColumnsRightTwoRows:
            {
                PlaceholderEnum leftType = placeholderTypes[1];

                if (leftType == PlaceholderEnum.Object)
                {
                    return("objAndTwoObj");
                }
                else if (leftType == PlaceholderEnum.Body)
                {
                    return("txAndTwoObj");
                }
                else
                {
                    throw new NotImplementedException(String.Format(
                                                          "Don't know how to map TwoColumnRightTwoRows with leftType = {0}",
                                                          leftType
                                                          ));
                }
            }

            case SlideLayoutType.TwoRowsAndTitle:
            {
                PlaceholderEnum topType    = placeholderTypes[1];
                PlaceholderEnum bottomType = placeholderTypes[2];

                if (topType == PlaceholderEnum.Body && bottomType == PlaceholderEnum.Object)
                {
                    return("txOverObj");
                }
                else if (topType == PlaceholderEnum.Object && bottomType == PlaceholderEnum.Body)
                {
                    return("objOverTx");
                }
                else
                {
                    throw new NotImplementedException(String.Format(
                                                          "Don't know how to map TwoRowsAndTitle with topType = {0} and bottomType = {1}",
                                                          topType, bottomType
                                                          ));
                }
            }

            case SlideLayoutType.TwoRowsTopTwoColumns:
                return("twoObjOverTx");

            default:
                throw new NotImplementedException("Don't know how to map slide layout type " + type);
            }
        }