コード例 #1
0
        /// <summary>
        /// Constructor
        /// Get URI attribute value of PresentationExtension
        /// </summary>
        /// <param name="filePath">Generated file path</param>
        public TestEntities(string filePath)
        {
            using (PresentationDocument package = PresentationDocument.Open(filePath, false))
            {
                try
                {
                    //Get Extension Uri value. (This element is P15.SlideGuideList parrent element.)
                    P15.SlideGuideList    slideGuideList = package.PresentationPart.RootElement.Descendants <P15.SlideGuideList>().Single();
                    PresentationExtension slideGuidePresentationExtension = (PresentationExtension)slideGuideList.Parent;
                    this.SldExtUri = slideGuidePresentationExtension.Uri;
                    if (string.IsNullOrEmpty(this.SldExtUri))
                    {
                        throw new Exception("Uri attribute value in Extension element is not set. It element of P15.SlideGuideList parent element.");
                    }

                    //Get Extension Uri value. (This element is P15.SlideGuideList parrent element.)
                    P15.NotesGuideList    notesGuideList = package.PresentationPart.RootElement.Descendants <P15.NotesGuideList>().Single();
                    PresentationExtension notesGuidePresentationExtension = (PresentationExtension)notesGuideList.Parent;
                    this.NotesExtUri = notesGuidePresentationExtension.Uri;
                    if (string.IsNullOrEmpty(this.NotesExtUri))
                    {
                        throw new Exception("Uri attribute value in Extension element is not set. It element of P15.SlideGuideList parent element.");
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Editing PresentationExtensionList element.
        /// </summary>
        /// <param name="filePath">Tartget file path</param>
        /// <param name="log">Logger</param>
        public void EditElement(string filePath, VerifiableLog log)
        {
            using (PresentationDocument package = PresentationDocument.Open(filePath, true))
            {
                try
                {
                    PresentationExtensionList presentationExtensionList = package.PresentationPart.RootElement.Descendants <PresentationExtensionList>().Single();
                    PresentationExtension     PresentationExtension1    = package.PresentationPart.RootElement.Descendants <PresentationExtension>().Where(e => e.Uri == this.SldExtUri).Single();
                    P15.ExtendedGuideList     extendedGuideList1        = PresentationExtension1.Descendants <P15.SlideGuideList>().Single();

                    //Editing Guide(1) element
                    P15.ExtendedGuide extendedGuide1 = extendedGuideList1.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id1).Single();
                    extendedGuide1.Position    = this.position1;
                    extendedGuide1.Orientation = this.directionValues1;

                    A.RgbColorModelHex rgbColorModelHex1 = extendedGuide1.Descendants <A.RgbColorModelHex>().First();
                    rgbColorModelHex1.Val.Value = this.Color1;

                    //Editing Guide(2) element
                    P15.ExtendedGuide extendedGuide2 = extendedGuideList1.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id2).Single();
                    extendedGuide2.Position    = this.position2;
                    extendedGuide2.Orientation = this.directionValues2;

                    A.RgbColorModelHex rgbColorModelHex2 = extendedGuide2.Descendants <A.RgbColorModelHex>().First();
                    rgbColorModelHex2.Val.Value = this.Color2;

                    log.Pass("Edited the ExtendedGuideList element.");

                    PresentationExtension PresentationExtension2 = package.PresentationPart.RootElement.Descendants <PresentationExtension>().Where(e => e.Uri == this.NotesExtUri).Single();

                    P15.NotesGuideList notesGuideList = PresentationExtension2.Descendants <P15.NotesGuideList>().Single();

                    //Editing Guide(NotesGuide_1) element
                    P15.ExtendedGuide extendedGuide3 = notesGuideList.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id1).Single();
                    extendedGuide3.Position    = this.position3;
                    extendedGuide3.Orientation = this.directionValues2;

                    A.RgbColorModelHex rgbColorModelHex3 = extendedGuide3.Descendants <A.RgbColorModelHex>().First();
                    rgbColorModelHex3.Val.Value = this.Color3;

                    //Editing Guide(NotesGuide_2) element
                    P15.ExtendedGuide extendedGuide4 = notesGuideList.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id2).Single();
                    extendedGuide4.Position    = this.position4;
                    extendedGuide4.Orientation = this.directionValues1;

                    A.RgbColorModelHex rgbColorModelHex4 = extendedGuide4.Descendants <A.RgbColorModelHex>().First();
                    rgbColorModelHex4.Val.Value = this.Color4;

                    log.Pass("Edited the NotesGuideList element.");
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Verifying PresentationExtensionList element.
        /// </summary>
        /// <param name="filePath">Tartget file path</param>
        /// <param name="log">Logger</param>
        public void VerifyElement(string filePath, VerifiableLog log)
        {
            using (PresentationDocument package = PresentationDocument.Open(filePath, false))
            {
                try
                {
                    //Verify ExtendedGuideList
                    PresentationExtensionList presentationExtensionList = package.PresentationPart.RootElement.Descendants <PresentationExtensionList>().Single();
                    PresentationExtension     PresentationExtension1    = package.PresentationPart.RootElement.Descendants <PresentationExtension>().Where(e => e.Uri == this.SldExtUri).Single();
                    P15.ExtendedGuideList     extendedGuideList1        = PresentationExtension1.Descendants <P15.SlideGuideList>().Single();

                    //Verifying Guide(1) element
                    P15.ExtendedGuide extendedGuide1 = extendedGuideList1.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id1).Single();

                    log.Verify(extendedGuide1.Position == this.position1, "An incorrect value, Position value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    log.Verify(extendedGuide1.Orientation == this.directionValues1, "An incorrect value, Orientation value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    A.RgbColorModelHex rgbColorModelHex1 = extendedGuide1.Descendants <A.RgbColorModelHex>().First();
                    log.Verify(rgbColorModelHex1.Val.Value == this.Color1, "An incorrect value, RgbColorModelHex value. Guide Id=[{0}].", extendedGuide1.Id);

                    //Verifying Guide(2) element
                    P15.ExtendedGuide extendedGuide2 = extendedGuideList1.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id2).Single();

                    log.Verify(extendedGuide2.Position == this.position2, "An incorrect value, Position value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    log.Verify(extendedGuide2.Orientation == this.directionValues2, "An incorrect value, Orientation value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    A.RgbColorModelHex rgbColorModelHex2 = extendedGuide2.Descendants <A.RgbColorModelHex>().First();
                    log.Verify(rgbColorModelHex2.Val.Value == this.Color2, "An incorrect value, RgbColorModelHex value. Guide Id=[{0}].", extendedGuide1.Id);


                    //Verify NotesGuideList
                    PresentationExtension PresentationExtension2 = package.PresentationPart.RootElement.Descendants <PresentationExtension>().Where(e => e.Uri == this.NotesExtUri).Single();
                    P15.NotesGuideList    notesGuideList         = PresentationExtension2.Descendants <P15.NotesGuideList>().Single();

                    //Verifying Guide(1) element
                    P15.ExtendedGuide extendedGuide3 = notesGuideList.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id1).Single();

                    log.Verify(extendedGuide3.Position == this.position3, "An incorrect value, Position value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    log.Verify(extendedGuide3.Orientation == this.directionValues2, "An incorrect value, Orientation value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    A.RgbColorModelHex rgbColorModelHex3 = extendedGuide3.Descendants <A.RgbColorModelHex>().First();
                    log.Verify(rgbColorModelHex3.Val.Value == this.Color3, "An incorrect value, RgbColorModelHex value. Guide Id=[{0}].", extendedGuide1.Id);

                    //Verifying Guide(2) element
                    P15.ExtendedGuide extendedGuide4 = notesGuideList.Descendants <P15.ExtendedGuide>().Where(e => e.Id == this.Id2).Single();

                    log.Verify(extendedGuide4.Position == this.position4, "An incorrect value, Position value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    log.Verify(extendedGuide4.Orientation == this.directionValues1, "An incorrect value, Orientation value of ExtendedGuide. Id=[{0}].", extendedGuide1.Id);
                    A.RgbColorModelHex rgbColorModelHex4 = extendedGuide4.Descendants <A.RgbColorModelHex>().First();
                    log.Verify(rgbColorModelHex4.Val.Value == this.Color4, "An incorrect value, RgbColorModelHex value. Guide Id=[{0}].", extendedGuide1.Id);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }
            }
        }
コード例 #4
0
ファイル: TestEntities.cs プロジェクト: eriawan/Open-XML-SDK
        /// <summary>
        /// Adding PresentationExtensionList element.
        /// </summary>
        /// <param name="filePath">Tartget file path</param>
        /// <param name="log">Logger</param>
        public void AddElement(string filePath, VerifiableLog log)
        {
            using (PresentationDocument package = PresentationDocument.Open(filePath, true))
            {
                //Adding Guide element
                A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex() { Val = this.Color3 };
                P15.ColorType colorType1 = new P15.ColorType();
                P15.ExtendedGuide ExtendedGuide1 = new P15.ExtendedGuide() { Id = this.Id3, Position = this.position3, Orientation = this.directionValues2 };
                P15.SlideGuideList slideGuideList = new P15.SlideGuideList();
                PresentationExtension presentationExtension1 = new PresentationExtension() { Uri = this.SldExtUri };
                PresentationExtensionList presentationExtensionList = new PresentationExtensionList();

                colorType1.AppendChild<A.RgbColorModelHex>(rgbColorModelHex1);
                log.Pass("Added RgbColorModelHex element. It SlideGuideList.");

                ExtendedGuide1.AppendChild<P15.ColorType>(colorType1);
                log.Pass("Added ColorType element. It SlideGuideList.");

                slideGuideList.AppendChild<P15.ExtendedGuide>(ExtendedGuide1);
                log.Pass("Added ExtendedGuide element. It SlideGuideList.");

                presentationExtension1.AppendChild<P15.SlideGuideList>(slideGuideList);
                log.Pass("Added SlideGuideList element. It SlideGuideList.");

                presentationExtensionList.AppendChild<PresentationExtension>(presentationExtension1);
                log.Pass("Added PresentationExtension element. It SlideGuideList.");

                //Adding NotesGuide element
                A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex() { Val = this.Color4 };
                P15.ColorType colorType2 = new P15.ColorType();
                P15.ExtendedGuide ExtendedGuide2 = new P15.ExtendedGuide() { Id = this.Id4, Position = this.position4, Orientation = this.directionValues2 };
                P15.NotesGuideList NotesGuideList = new P15.NotesGuideList();
                PresentationExtension presentationExtension2 = new PresentationExtension() { Uri = this.NotesExtUri };

                colorType2.AppendChild<A.RgbColorModelHex>(rgbColorModelHex2);
                log.Pass("Added RgbColorModelHex element. It SlideGuideList.");

                ExtendedGuide2.AppendChild<P15.ColorType>(colorType2);
                log.Pass("Added ColorType element. It SlideGuideList.");

                NotesGuideList.AppendChild<P15.ExtendedGuide>(ExtendedGuide2);
                log.Pass("Added ExtendedGuide element. It SlideGuideList.");

                presentationExtension2.AppendChild<P15.NotesGuideList>(NotesGuideList);
                log.Pass("Added SlideGuideList element. It SlideGuideList.");

                presentationExtensionList.AppendChild<PresentationExtension>(presentationExtension2);
                log.Pass("Added PresentationExtension element. It SlideGuideList.");

                package.PresentationPart.Presentation.Append(presentationExtensionList);
                log.Pass("Added PresentationExtensionList element. It SlideGuideList.");
            }
        }
コード例 #5
0
        /// <summary>
        /// Adding PresentationExtensionList element.
        /// </summary>
        /// <param name="filePath">Tartget file path</param>
        /// <param name="log">Logger</param>
        public void AddElement(string filePath, VerifiableLog log)
        {
            using (PresentationDocument package = PresentationDocument.Open(filePath, true))
            {
                //Adding Guide element
                A.RgbColorModelHex rgbColorModelHex1 = new A.RgbColorModelHex()
                {
                    Val = this.Color3
                };
                P15.ColorType     colorType1     = new P15.ColorType();
                P15.ExtendedGuide ExtendedGuide1 = new P15.ExtendedGuide()
                {
                    Id = this.Id3, Position = this.position3, Orientation = this.directionValues2
                };
                P15.SlideGuideList    slideGuideList         = new P15.SlideGuideList();
                PresentationExtension presentationExtension1 = new PresentationExtension()
                {
                    Uri = this.SldExtUri
                };
                PresentationExtensionList presentationExtensionList = new PresentationExtensionList();

                colorType1.AppendChild <A.RgbColorModelHex>(rgbColorModelHex1);
                log.Pass("Added RgbColorModelHex element. It SlideGuideList.");

                ExtendedGuide1.AppendChild <P15.ColorType>(colorType1);
                log.Pass("Added ColorType element. It SlideGuideList.");

                slideGuideList.AppendChild <P15.ExtendedGuide>(ExtendedGuide1);
                log.Pass("Added ExtendedGuide element. It SlideGuideList.");

                presentationExtension1.AppendChild <P15.SlideGuideList>(slideGuideList);
                log.Pass("Added SlideGuideList element. It SlideGuideList.");

                presentationExtensionList.AppendChild <PresentationExtension>(presentationExtension1);
                log.Pass("Added PresentationExtension element. It SlideGuideList.");

                //Adding NotesGuide element
                A.RgbColorModelHex rgbColorModelHex2 = new A.RgbColorModelHex()
                {
                    Val = this.Color4
                };
                P15.ColorType     colorType2     = new P15.ColorType();
                P15.ExtendedGuide ExtendedGuide2 = new P15.ExtendedGuide()
                {
                    Id = this.Id4, Position = this.position4, Orientation = this.directionValues2
                };
                P15.NotesGuideList    NotesGuideList         = new P15.NotesGuideList();
                PresentationExtension presentationExtension2 = new PresentationExtension()
                {
                    Uri = this.NotesExtUri
                };

                colorType2.AppendChild <A.RgbColorModelHex>(rgbColorModelHex2);
                log.Pass("Added RgbColorModelHex element. It SlideGuideList.");

                ExtendedGuide2.AppendChild <P15.ColorType>(colorType2);
                log.Pass("Added ColorType element. It SlideGuideList.");

                NotesGuideList.AppendChild <P15.ExtendedGuide>(ExtendedGuide2);
                log.Pass("Added ExtendedGuide element. It SlideGuideList.");

                presentationExtension2.AppendChild <P15.NotesGuideList>(NotesGuideList);
                log.Pass("Added SlideGuideList element. It SlideGuideList.");

                presentationExtensionList.AppendChild <PresentationExtension>(presentationExtension2);
                log.Pass("Added PresentationExtension element. It SlideGuideList.");

                package.PresentationPart.Presentation.Append(presentationExtensionList);
                log.Pass("Added PresentationExtensionList element. It SlideGuideList.");
            }
        }