コード例 #1
0
        private void ReadPictureBullets(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp, SlidePart slidePart)
        {
            this.SetBulletProperties(baseProperties, bulletProp);
            var picBul = baseProperties.GetFirstChild <PictureBullet>();

            if (picBul != null)
            {
                string embed = picBul.Blip.Embed.Value;

                string projectDir = System.IO.Path.GetDirectoryName(
                    System.IO.Path.GetDirectoryName(Environment.CurrentDirectory));
                string storageDir = System.IO.Path.Combine(projectDir, Globals.STORAGE_DIR);
                string path       = "";
                if (slide.slideIndex >= 1)
                {
                    path = slide.fileName + "_" + slide.slideIndex;
                }
                else
                {
                    path = slide.fileName;
                }
                string pictureBulletDir = System.IO.Path.Combine(storageDir, path);
                bulletProp.Text = path + "\\" + embed + ".png";
                try
                {
                    bulletProp.bulletSize = this.ExtractPictureBulletImage(bulletProp, embed, pictureBulletDir, slidePart);
                }
                catch (IOException iex)
                {
                    Console.WriteLine(iex.Message);
                }
            }
        }
コード例 #2
0
        private void ReadBulletFont(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
        {
            BulletFont font = baseProperties.GetFirstChild <BulletFont>();

            if (font != null)
            {
                if (font.Typeface != null)
                {
                    bulletProp.FontFamily = font.Typeface;
                }
                if (font.PitchFamily != null)
                {
                    bulletProp.FontSize = font.PitchFamily;
                }
                else
                {
                    var latinFonts = font.GetFirstChild <LatinFont>();
                    if (latinFonts != null)
                    {
                        bulletProp.ReadFontFamilyFromTheme(latinFonts);
                    }
                }
            }
            else
            {
                bulletProp.FontSize = defaultRunProperties.FontSize;
            }
        }
コード例 #3
0
 private void SetBulletProperties(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
 {
     this.ReadBulletFont(baseProperties, bulletProp);
     this.ReadBulletColor(baseProperties, bulletProp);
     this.ReadBulletSizePercentage(baseProperties, bulletProp);
     bulletProp.Left = marginLeft;
     bullet          = bulletProp;
 }
コード例 #4
0
        public void SetParagraphProperties(Paragraph paragraph, SlidePart slidePart,
                                           DocumentFormat.OpenXml.Drawing.ListStyle shapeListStyleMaster,
                                           DocumentFormat.OpenXml.Drawing.ListStyle shapeListStyleLayout)
        {
            TextListStyleType listStyleType = this.slide.defaultTextStyle;

            if (slide.textStyles != null)
            {
                if (placeholder != null)
                {
                    if (placeholder.Type.Value.Equals(PlaceholderValues.Body) ||
                        placeholder.Type.Value.Equals(PlaceholderValues.SubTitle))
                    {
                        listStyleType = slide.textStyles.BodyStyle;
                    }
                    else if (placeholder.Type.Value.Equals(PlaceholderValues.Title) ||
                             placeholder.Type.Value.Equals(PlaceholderValues.CenteredTitle))
                    {
                        listStyleType = slide.textStyles.TitleStyle;
                    }
                    else
                    {
                        listStyleType = slide.textStyles.OtherStyle;
                    }
                }
                //Check what should we add here for all placeholder values.
                //Should we take it by placeholder value or there is another property?
            }
            TextParagraphPropertiesType baseProperties       = getParagraphPropFromTextListStyle(listStyleType, Level);
            TextParagraphPropertiesType basePropertiesMaster = getParagraphPropFromTextListStyle(shapeListStyleMaster, Level);
            TextParagraphPropertiesType basePropertiesLayout = getParagraphPropFromTextListStyle(shapeListStyleLayout, Level);

            defaultRunProperties = new PPTRunProperties(slide);


            if (baseProperties != null)
            {
                this.FillParagraphProperties(baseProperties, slidePart);
            }
            if (basePropertiesMaster != null)
            {
                this.FillParagraphProperties(basePropertiesMaster, slidePart);
            }
            if (basePropertiesLayout != null)
            {
                this.FillParagraphProperties(basePropertiesLayout, slidePart);
            }
            if (paragraph.ParagraphProperties != null)
            {
                this.FillParagraphProperties(paragraph.ParagraphProperties, slidePart);
            }
        }
コード例 #5
0
        private int CreateImage(PPTRunProperties bulletProp, string embed, string realDir, int imageSize, OpenXmlPart sldPart)
        {
            if (!System.IO.Directory.Exists(realDir))
            {
                System.IO.Directory.CreateDirectory(realDir);
            }

            Image image       = Image.FromStream(sldPart.GetStream());
            Image scaledImage = Globals.ScaleByPercent(image, (int)bulletProp.FontSize);

            imageSize = scaledImage.Height;
            string imageName = System.IO.Path.Combine(realDir, embed + ".png");

            scaledImage.Save(imageName);
            return(imageSize);
        }
コード例 #6
0
 public PPTRunProperties(PPTRunProperties copy)
 {
     this.FontColor  = copy.FontColor;
     this.FontFamily = copy.FontFamily;
     this.FontSize   = copy.FontSize;
     this.Top        = copy.Top;
     this.Left       = copy.Left;
     this.Italic     = copy.Italic;
     this.Bold       = copy.Bold;
     this.Invisible  = copy.Invisible;
     this.isBreak    = copy.isBreak;
     this.Animatable = copy.Animatable;
     this.Spacing    = copy.Spacing;
     this.Text       = copy.Text;
     this.slide      = copy.slide;
 }
コード例 #7
0
        private void FillParagraphProperties(TextParagraphPropertiesType baseProperties, SlidePart slidePart)
        {
            if (baseProperties.LineSpacing != null)
            {
                lineSpacing = baseProperties.LineSpacing;
            }
            if (baseProperties.SpaceAfter != null)
            {
                spaceAfter = baseProperties.SpaceAfter;
            }
            if (baseProperties.SpaceBefore != null)
            {
                spaceBefore = baseProperties.SpaceBefore;
            }
            if (baseProperties.Alignment != null)
            {
                Align = baseProperties.Alignment.Value.ToString();
            }
            if (baseProperties.FontAlignment != null)
            {
                FontAlign = baseProperties.FontAlignment.Value.ToString();
            }

            if (baseProperties.LeftMargin != null)
            {
                marginLeft = baseProperties.LeftMargin.Value / Globals.LEAST_COMMON_MULTIPLE_100_254;
            }
            if (baseProperties.RightMargin != null)
            {
                marginRight = baseProperties.RightMargin.Value / Globals.LEAST_COMMON_MULTIPLE_100_254;
            }

            if (baseProperties.Indent != null)
            {
                Indent = baseProperties.Indent.Value / Globals.LEAST_COMMON_MULTIPLE_100_254;
            }

            defaultRunProperties.ReadDefaultRunProperties(baseProperties);
            this.ReadBullets(baseProperties, slidePart);

            if (baseProperties.GetFirstChild <NoBullet>() != null)
            {
                bullet = null;
            }
        }
コード例 #8
0
        private void ReadBullets(TextParagraphPropertiesType baseProperties, SlidePart slidePart)
        {
            var bulletProp = new PPTRunProperties(slide);

            bulletProp.isBullet = true;

            if (baseProperties != null)
            {
                if (baseProperties.GetFirstChild <CharacterBullet>() != null)
                {
                    this.ReadCharacterBullets(baseProperties, bulletProp);
                }
                else if (baseProperties.GetFirstChild <PictureBullet>() != null)
                {
                    this.ReadPictureBullets(baseProperties, bulletProp, slidePart);
                }
            }
        }
コード例 #9
0
        private void ReadBulletColor(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
        {
            BulletColor buCol = baseProperties.GetFirstChild <BulletColor>();

            if (buCol != null)
            {
                if (buCol.RgbColorModelHex != null)
                {
                    bulletProp.FontColor = "#" + buCol.RgbColorModelHex.Val.Value;
                }
                else
                {
                    if (buCol.GetFirstChild <SchemeColor>() != null)
                    {
                        bulletProp.ReadThemeSchemeColor(buCol.GetFirstChild <SchemeColor>());
                    }
                }
            }
        }
コード例 #10
0
        private int ExtractPictureBulletImage(PPTRunProperties bulletProp, string embed,
                                              string realDir, SlidePart slidePart)
        {
            int imageSize = 0;

            try
            {
                OpenXmlPart masterPart = slide.SlideLayoutPart.SlideMasterPart.GetPartById(embed);
                if (masterPart != null)
                {
                    if (masterPart.ContentType.Equals("image/png"))
                    {
                        imageSize = CreateImage(bulletProp, embed, realDir, imageSize, masterPart);
                    }
                    else
                    {
                        OpenXmlPart sldPart = slidePart.GetPartById(embed);
                        if (sldPart != null)
                        {
                            if (sldPart.ContentType.Equals("image/png"))
                            {
                                imageSize = CreateImage(bulletProp, embed, realDir, imageSize, sldPart);
                            }
                        }
                    }
                }
            }
            catch (ArgumentOutOfRangeException aoex)
            {
                Console.WriteLine(aoex.Message);
            }
            catch (ArgumentException aex)
            {
                Console.WriteLine(aex.Message);
            }
            return(imageSize);
        }
コード例 #11
0
 private void ReadBulletSizePercentage(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
 {
     if (baseProperties.GetFirstChild <BulletSizePercentage>() != null)
     {
         BulletSizePercentage pct = baseProperties.GetFirstChild <BulletSizePercentage>();
         if (bulletProp.bulletSize != 0)
         {
             bulletProp.bulletSize = bulletProp.bulletSize * pct.Val / Globals.PercentageConstant;
         }
         else
         {
             bulletProp.bulletSize = ClearSlideLibrary.HtmlController.HtmlText.DefaultBulletSize;
             bulletProp.bulletSize = bulletProp.bulletSize * pct.Val / Globals.PercentageConstant;
         }
     }
 }
コード例 #12
0
 private void ReadCharacterBullets(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
 {
     bulletProp.Text = "" + baseProperties.GetFirstChild <CharacterBullet>().Char;
     this.SetBulletProperties(baseProperties, bulletProp);
 }