Example #1
0
        private void InsertMasterStylePlaceholders(ShapeTreeMapping stm)
        {
            SlideAtom slideAtom = this.Slide.FirstChildWithType <SlideAtom>();

            foreach (Slide master in this._ctx.Ppt.MainMasterRecords)
            {
                if (master.PersistAtom.SlideId == slideAtom.MasterId)
                {
                    List <OfficeDrawing.ShapeContainer> shapes = master.AllChildrenWithType <PPDrawing>()[0].AllChildrenWithType <OfficeDrawing.DrawingContainer>()[0].AllChildrenWithType <OfficeDrawing.GroupContainer>()[0].AllChildrenWithType <OfficeDrawing.ShapeContainer>();
                    foreach (OfficeDrawing.ShapeContainer shapecontainer in shapes)
                    {
                        foreach (OfficeDrawing.ClientData data in shapecontainer.AllChildrenWithType <OfficeDrawing.ClientData>())
                        {
                            System.IO.MemoryStream ms  = new System.IO.MemoryStream(data.bytes);
                            OfficeDrawing.Record   rec = OfficeDrawing.Record.ReadRecord(ms);

                            if (rec.TypeCode == 3011)
                            {
                                OEPlaceHolderAtom placeholder = (OEPlaceHolderAtom)rec;

                                if (placeholder != null)
                                {
                                    if (placeholder.PlacementId != PlaceholderEnum.MasterFooter)
                                    {
                                        stm.Apply(shapecontainer, "", "", "");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private void checkHeaderFooter(ShapeTreeMapping stm)
        {
            NotesAtom slideAtom = this.Note.FirstChildWithType <NotesAtom>();

            string footertext   = "";
            string headertext   = "";
            string userdatetext = "";
            SlideHeadersFootersContainer headersfooters = this.Note.FirstChildWithType <SlideHeadersFootersContainer>();

            if (headersfooters != null)
            {
                foreach (CStringAtom text in headersfooters.AllChildrenWithType <CStringAtom>())
                {
                    switch (text.Instance)
                    {
                    case 0:
                        userdatetext = text.Text;
                        break;

                    case 1:
                        headertext = text.Text;
                        break;

                    case 2:
                        footertext = text.Text;
                        break;
                    }
                }
                //CStringAtom text = headersfooters.FirstChildWithType<CStringAtom>();
                //if (text != null)
                //{
                //    footertext = text.Text;
                //}
            }

            bool footer      = false;
            bool header      = false;
            bool slideNumber = false;
            bool date        = false;
            bool userDate    = false;

            foreach (SlideHeadersFootersContainer c in this._ctx.Ppt.DocumentRecord.AllChildrenWithType <SlideHeadersFootersContainer>())
            {
                switch (c.Instance)
                {
                case 0:     //PerSlideHeadersFootersContainer
                    break;

                case 3:     //SlideHeadersFootersContainer
                    break;

                case 4:     //NotesHeadersFootersContainer
                    foreach (HeadersFootersAtom a in c.AllChildrenWithType <HeadersFootersAtom>())
                    {
                        if (a.fHasFooter)
                        {
                            footer = true;
                        }
                        if (a.fHasHeader)
                        {
                            header = true;
                        }
                        if (a.fHasSlideNumber)
                        {
                            slideNumber = true;
                        }
                        if (a.fHasDate)
                        {
                            date = true;
                        }
                        if (a.fHasUserDate)
                        {
                            userDate = true;
                        }
                    }
                    break;
                }
            }

            Note master = _ctx.Ppt.NotesMasterRecords[0];

            if (slideNumber)
            {
                //foreach (Slide master in this._ctx.Ppt.MainMasterRecords)
                //{
                //if (master.PersistAtom.SlideId == slideAtom.MasterId)
                //{
                List <OfficeDrawing.ShapeContainer> shapes = master.AllChildrenWithType <PPDrawing>()[0].AllChildrenWithType <OfficeDrawing.DrawingContainer>()[0].AllChildrenWithType <OfficeDrawing.GroupContainer>()[0].AllChildrenWithType <OfficeDrawing.ShapeContainer>();
                foreach (OfficeDrawing.ShapeContainer shapecontainer in shapes)
                {
                    foreach (OfficeDrawing.ClientData data in shapecontainer.AllChildrenWithType <OfficeDrawing.ClientData>())
                    {
                        System.IO.MemoryStream ms  = new System.IO.MemoryStream(data.bytes);
                        OfficeDrawing.Record   rec = OfficeDrawing.Record.ReadRecord(ms);

                        if (rec.TypeCode == 3011)
                        {
                            OEPlaceHolderAtom placeholder = (OEPlaceHolderAtom)rec;

                            if (placeholder != null)
                            {
                                if (placeholder.PlacementId == PlaceholderEnum.MasterSlideNumber)
                                {
                                    stm.Apply(shapecontainer, "", "", "");
                                }
                            }
                        }
                    }
                }

                //}
                //}
            }

            //if (date)
            //{
            //if (!(userDate & userdatetext.Length == 0))
            //    {
            //    foreach (Slide master in this._ctx.Ppt.MainMasterRecords)
            //    {
            //        if (master.PersistAtom.SlideId == slideAtom.MasterId)
            //        {
            //            List<OfficeDrawing.ShapeContainer> shapes = master.AllChildrenWithType<PPDrawing>()[0].AllChildrenWithType<OfficeDrawing.DrawingContainer>()[0].AllChildrenWithType<OfficeDrawing.GroupContainer>()[0].AllChildrenWithType<OfficeDrawing.ShapeContainer>();
            //            foreach (OfficeDrawing.ShapeContainer shapecontainer in shapes)
            //            {
            //                foreach (OfficeDrawing.ClientData data in shapecontainer.AllChildrenWithType<OfficeDrawing.ClientData>())
            //                {
            //                    System.IO.MemoryStream ms = new System.IO.MemoryStream(data.bytes);
            //                    OfficeDrawing.Record rec = OfficeDrawing.Record.ReadRecord(ms, 0);

            //                    if (rec.TypeCode == 3011)
            //                    {
            //                        OEPlaceHolderAtom placeholder = (OEPlaceHolderAtom)rec;

            //                        if (placeholder != null)
            //                        {
            //                            if (placeholder.PlacementId == PlaceholderEnum.MasterDate)
            //                            {
            //                                stm.Apply(shapecontainer, "");
            //                            }
            //                        }
            //                    }
            //                }
            //            }

            //        }
            //    }
            //  }
            //}

            if (header)
            {
                string s = "";
            }

            // if (footer)
            // //foreach (Note master in this._ctx.Ppt.NotesMasterRecords)
            // {
            //     List<OfficeDrawing.ShapeContainer> shapes = master.AllChildrenWithType<PPDrawing>()[0].AllChildrenWithType<OfficeDrawing.DrawingContainer>()[0].AllChildrenWithType<OfficeDrawing.GroupContainer>()[0].AllChildrenWithType<OfficeDrawing.ShapeContainer>();
            //     foreach (OfficeDrawing.ShapeContainer shapecontainer in shapes)
            //     {
            //         foreach (OfficeDrawing.ClientData data in shapecontainer.AllChildrenWithType<OfficeDrawing.ClientData>())
            //         {
            //             System.IO.MemoryStream ms = new System.IO.MemoryStream(data.bytes);
            //             OfficeDrawing.Record rec = OfficeDrawing.Record.ReadRecord(ms);

            //             if (rec.TypeCode == 3011)
            //             {
            //                 OEPlaceHolderAtom placeholder = (OEPlaceHolderAtom)rec;

            //                 if (placeholder != null)
            //                 {
            //                     if (placeholder.PlacementId == PlaceholderEnum.MasterFooter)
            //                     {
            //                         stm.Apply(shapecontainer, footertext, "", "");
            //                         footer = false;
            //                     }
            //                 }
            //             }
            //         }
            //     }
            //}

            if (footer)
            //foreach (Slide master in this._ctx.Ppt.TitleMasterRecords)
            {
                //if (master.PersistAtom.SlideId == slideAtom.MasterId)
                //{
                List <OfficeDrawing.ShapeContainer> shapes = master.AllChildrenWithType <PPDrawing>()[0].AllChildrenWithType <OfficeDrawing.DrawingContainer>()[0].AllChildrenWithType <OfficeDrawing.GroupContainer>()[0].AllChildrenWithType <OfficeDrawing.ShapeContainer>();
                foreach (OfficeDrawing.ShapeContainer shapecontainer in shapes)
                {
                    foreach (OfficeDrawing.ClientData data in shapecontainer.AllChildrenWithType <OfficeDrawing.ClientData>())
                    {
                        System.IO.MemoryStream ms  = new System.IO.MemoryStream(data.bytes);
                        OfficeDrawing.Record   rec = OfficeDrawing.Record.ReadRecord(ms);

                        if (rec.TypeCode == 3011)
                        {
                            OEPlaceHolderAtom placeholder = (OEPlaceHolderAtom)rec;

                            if (placeholder != null)
                            {
                                if (placeholder.PlacementId == PlaceholderEnum.MasterFooter)
                                {
                                    bool doit = footertext.Length > 0;
                                    if (!doit)
                                    {
                                        foreach (ShapeOptions so in shapecontainer.AllChildrenWithType <ShapeOptions>())
                                        {
                                            if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.FillStyleBooleanProperties))
                                            {
                                                FillStyleBooleanProperties props = new FillStyleBooleanProperties(so.OptionsByID[ShapeOptions.PropertyId.FillStyleBooleanProperties].op);
                                                if (props.fFilled && props.fUsefFilled)
                                                {
                                                    doit = true;
                                                }
                                            }
                                        }
                                    }
                                    if (doit)
                                    {
                                        stm.Apply(shapecontainer, footertext, "", "");
                                    }
                                    footer = false;
                                }
                            }
                        }
                    }
                }

                //}
            }

            if (footer)
            //foreach (Slide master in this._ctx.Ppt.MainMasterRecords)
            {
                //if (master.PersistAtom.SlideId == slideAtom.MasterId)
                //{
                List <OfficeDrawing.ShapeContainer> shapes = master.AllChildrenWithType <PPDrawing>()[0].AllChildrenWithType <OfficeDrawing.DrawingContainer>()[0].AllChildrenWithType <OfficeDrawing.GroupContainer>()[0].AllChildrenWithType <OfficeDrawing.ShapeContainer>();
                foreach (OfficeDrawing.ShapeContainer shapecontainer in shapes)
                {
                    foreach (OfficeDrawing.ClientData data in shapecontainer.AllChildrenWithType <OfficeDrawing.ClientData>())
                    {
                        System.IO.MemoryStream ms  = new System.IO.MemoryStream(data.bytes);
                        OfficeDrawing.Record   rec = OfficeDrawing.Record.ReadRecord(ms);

                        if (rec.TypeCode == 3011)
                        {
                            OEPlaceHolderAtom placeholder = (OEPlaceHolderAtom)rec;

                            if (placeholder != null)
                            {
                                if (placeholder.PlacementId == PlaceholderEnum.MasterFooter)
                                {
                                    if (footertext.Length == 0 & shapecontainer.AllChildrenWithType <ClientTextbox>().Count > 0)
                                    {
                                        footertext = new SlideMapping(_ctx).readFooterFromClientTextBox(shapecontainer.FirstChildWithType <ClientTextbox>());
                                    }

                                    bool doit = footertext.Length > 0;
                                    if (!doit)
                                    {
                                        foreach (ShapeOptions so in shapecontainer.AllChildrenWithType <ShapeOptions>())
                                        {
                                            if (so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.FillStyleBooleanProperties))
                                            {
                                                FillStyleBooleanProperties props = new FillStyleBooleanProperties(so.OptionsByID[ShapeOptions.PropertyId.FillStyleBooleanProperties].op);
                                                if (props.fFilled && props.fUsefFilled)
                                                {
                                                    doit = true;
                                                }
                                            }
                                        }
                                    }
                                    if (doit)
                                    {
                                        stm.Apply(shapecontainer, footertext, "", "");
                                    }
                                    footer = false;
                                }
                            }
                        }
                    }
                }
            }
        }