Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
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;
         }
     }
 }
Exemplo n.º 6
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;
            }
        }
Exemplo n.º 7
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);
                }
            }
        }
Exemplo n.º 8
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>());
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void ReadDefaultRunProperties(TextParagraphPropertiesType baseProperties)
        {
            var defRun = baseProperties.GetFirstChild <DefaultRunProperties>();

            if (defRun != null)
            {
                if (defRun.FontSize != null)
                {
                    FontSize = defRun.FontSize / Globals.FontPoint;
                    //Console.WriteLine("The def font size is:" + fontProp.FontSize);
                }
                if (defRun.Bold != null)
                {
                    if (!Bold)
                    {
                        Bold = defRun.Bold;
                    }
                }
                if (defRun.Italic != null)
                {
                    if (!Italic)
                    {
                        Italic = defRun.Italic;
                    }
                }
                if (defRun.Spacing != null)
                {
                    Spacing = defRun.Spacing;
                }
                var solidFill = defRun.GetFirstChild <SolidFill>();

                if (solidFill != null)
                {
                    this.ReadSolidFillColors(solidFill);
                }
                var latinFonts = defRun.GetFirstChild <LatinFont>();
                this.ReadFontFamilyFromTheme(latinFonts);
            }
        }
Exemplo n.º 10
0
 private void ReadCharacterBullets(TextParagraphPropertiesType baseProperties, PPTRunProperties bulletProp)
 {
     bulletProp.Text = "" + baseProperties.GetFirstChild <CharacterBullet>().Char;
     this.SetBulletProperties(baseProperties, bulletProp);
 }
 public OpenXmlParagraphTextStyle(TextParagraphPropertiesType properties)
 {
     this.properties = properties;
 }