Beispiel #1
0
        private void ShapeIsText(PageLayer _page, pp.Shape _shape, EAnimation _animation, string _idShape)
        {
            //Thiếu textindent và strike words
            DataDocument document = new DataDocument();

            document.Name = "TextEditor";
            List <DataParaPositionBullet> ListParaPosition   = new List <DataParaPositionBullet>();
            DataParaPositionBullet        paraPositionBullet = null;

            document.Blocks.Clear();
            document.Container = new DataTextContainer();

            if (_shape.Type == office.MsoShapeType.msoTextBox)
            {
                document.TypeTextContainer = TypeTextContainer.AutoChangeHeight;
            }
            else
            {
                document.TypeTextContainer = TypeTextContainer.ChangeSize;
            }


            //Lấy nội dung
            pp.BulletFormat hasBullet = _shape.TextFrame.TextRange.ParagraphFormat.Bullet;
            if (hasBullet.Visible == office.MsoTriState.msoCTrue || hasBullet.Visible == office.MsoTriState.msoTrue)
            {
                foreach (pp.TextRange paragraph in _shape.TextFrame.TextRange.Paragraphs())
                {
                    DataDocumentList docList = new DataDocumentList();
                    int level = paragraph.IndentLevel;
                    DataDocumentListItem docListItem = new DataDocumentListItem();
                    pp.BulletFormat      prgBullet   = paragraph.ParagraphFormat.Bullet;
                    docListItem.TypeWordBullet = new Text.ViewModels.Text.TypeWordBullet();

                    docListItem.TypeWordBullet.StarIndex = prgBullet.StartValue;
                    if (prgBullet.Visible == office.MsoTriState.msoCTrue || prgBullet.Visible == office.MsoTriState.msoTrue)
                    {
                        docListItem.TypeWordBullet            = new Text.ViewModels.Text.TypeWordBullet();
                        docListItem.TypeWordBullet.SizeOffset = 100;
                        if (prgBullet.Type == PpBulletType.ppBulletNumbered)
                        {
                            docListItem.TypeWordBullet.Fontfamily = "Arial";
                            docListItem.TypeWordBullet.Text       = "1.";
                            docListItem.TypeWordBullet.ListType   = Text.ListType.Decimal;
                            switch (prgBullet.Style)
                            {
                            case PpNumberedBulletStyle.ppBulletStyleMixed:
                                break;

                            case PpNumberedBulletStyle.ppBulletAlphaLCPeriod:
                                docListItem.TypeWordBullet.Fontfamily = "Arial";
                                docListItem.TypeWordBullet.Text       = "a.";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.LowerLatin;
                                break;

                            case PpNumberedBulletStyle.ppBulletAlphaUCPeriod:
                                docListItem.TypeWordBullet.Fontfamily = "Arial";
                                docListItem.TypeWordBullet.Text       = "A.";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.UpperLatin;
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicParenRight:
                                docListItem.TypeWordBullet.Fontfamily = "Arial";
                                docListItem.TypeWordBullet.Text       = "1)";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Decimal2;
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicPeriod:
                                docListItem.TypeWordBullet.Fontfamily = "Arial";
                                docListItem.TypeWordBullet.Text       = "1.";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Decimal;
                                break;

                            case PpNumberedBulletStyle.ppBulletRomanLCParenBoth:
                                break;

                            case PpNumberedBulletStyle.ppBulletRomanLCParenRight:
                                break;

                            case PpNumberedBulletStyle.ppBulletRomanLCPeriod:
                                docListItem.TypeWordBullet.Fontfamily = "Arial";
                                docListItem.TypeWordBullet.Text       = "i.";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.LowerRoman;
                                break;

                            case PpNumberedBulletStyle.ppBulletRomanUCPeriod:
                                docListItem.TypeWordBullet.Fontfamily = "Arial";
                                docListItem.TypeWordBullet.Text       = "I.";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.UpperRoman;
                                break;

                            case PpNumberedBulletStyle.ppBulletAlphaLCParenBoth:
                                break;

                            case PpNumberedBulletStyle.ppBulletAlphaLCParenRight:
                                docListItem.TypeWordBullet.Fontfamily = "Arial";
                                docListItem.TypeWordBullet.Text       = "a)";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.LowerLatin2;
                                break;

                            case PpNumberedBulletStyle.ppBulletAlphaUCParenBoth:
                                break;

                            case PpNumberedBulletStyle.ppBulletAlphaUCParenRight:
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicParenBoth:
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicPlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletRomanUCParenBoth:
                                break;

                            case PpNumberedBulletStyle.ppBulletRomanUCParenRight:
                                break;

                            case PpNumberedBulletStyle.ppBulletSimpChinPlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletSimpChinPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletCircleNumDBPlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletCircleNumWDWhitePlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletCircleNumWDBlackPlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletTradChinPlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletTradChinPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicAlphaDash:
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicAbjadDash:
                                break;

                            case PpNumberedBulletStyle.ppBulletHebrewAlphaDash:
                                break;

                            case PpNumberedBulletStyle.ppBulletKanjiKoreanPlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletKanjiKoreanPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicDBPlain:
                                break;

                            case PpNumberedBulletStyle.ppBulletArabicDBPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletThaiAlphaPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletThaiAlphaParenRight:
                                break;

                            case PpNumberedBulletStyle.ppBulletThaiAlphaParenBoth:
                                break;

                            case PpNumberedBulletStyle.ppBulletThaiNumPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletThaiNumParenRight:
                                break;

                            case PpNumberedBulletStyle.ppBulletThaiNumParenBoth:
                                break;

                            case PpNumberedBulletStyle.ppBulletHindiAlphaPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletHindiNumPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletKanjiSimpChinDBPeriod:
                                break;

                            case PpNumberedBulletStyle.ppBulletHindiNumParenRight:
                                break;

                            case PpNumberedBulletStyle.ppBulletHindiAlpha1Period:
                                break;

                            default:
                                break;
                            }
                        }
                        else if (prgBullet.Type == PpBulletType.ppBulletUnnumbered)
                        {
                            if (prgBullet.Character == 8226)
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Wingdings";
                                docListItem.TypeWordBullet.Text       = "l";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                            else if (prgBullet.Character == 111)
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Raleway";
                                docListItem.TypeWordBullet.Text       = "o";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                            else if (prgBullet.Character == 167)
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Wingdings";
                                docListItem.TypeWordBullet.Text       = ((char)167).ToString();
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                            else if (prgBullet.Character == 113)
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Wingdings";
                                docListItem.TypeWordBullet.Text       = "q";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                            else if (prgBullet.Character == 118)
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Wingdings";
                                docListItem.TypeWordBullet.Text       = "v";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                            else if (prgBullet.Character == 216)
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Wingdings";
                                docListItem.TypeWordBullet.Text       = ((char)216).ToString();
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                            else if (prgBullet.Character == 252)
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Wingdings";
                                docListItem.TypeWordBullet.Text       = ((char)252).ToString();
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                            else
                            {
                                docListItem.TypeWordBullet.Fontfamily = "Wingdings";
                                docListItem.TypeWordBullet.Text       = "l";
                                docListItem.TypeWordBullet.ListType   = Text.ListType.Bullet;
                            }
                        }
                    }
                    paraPositionBullet          = new DataParaPositionBullet();
                    paraPositionBullet.Para     = GetEParagraph(paragraph);
                    paraPositionBullet.ListType = docListItem.TypeWordBullet;
                    paraPositionBullet.Position = level;
                    ListParaPosition.Add(paraPositionBullet);
                }
            }
            else
            {
                foreach (pp.TextRange paragraph in _shape.TextFrame.TextRange.Paragraphs())
                {
                    /*
                     * var _para = GetEParagraph(paragraph);
                     * if (_para.Inlines?.Count > 0)
                     * {
                     *  if ((_para.Inlines.Last() as DataRun)?.Text != null)
                     *      (_para.Inlines.Last() as DataRun).Text = (_para.Inlines.Last() as DataRun).Text + "\r";
                     * }
                     * document.Blocks.Add(_para);*/
                    paraPositionBullet      = new DataParaPositionBullet();
                    paraPositionBullet.Para = GetEParagraph(paragraph);
                    if (paraPositionBullet.Para?.Inlines?.Count > 0)
                    {
                        if ((paraPositionBullet.Para.Inlines.Last() as DataRun)?.Text != null)
                        {
                            (paraPositionBullet.Para.Inlines.Last() as DataRun).Text = (paraPositionBullet.Para.Inlines.Last() as DataRun).Text + "\r";
                        }
                    }
                    paraPositionBullet.ListType = null;
                    paraPositionBullet.Position = 0;
                    ListParaPosition.Add(paraPositionBullet);
                }
                //goto addToDoc;
            }
            if (ListParaPosition?.Count == 0)
            {
                paraPositionBullet      = new DataParaPositionBullet();
                paraPositionBullet.Para = new DataParagraph();
                DataRun _run = new DataRun();
                _run.Text       = "\r";
                _run.FontSize   = 14;
                _run.Fontfamily = "Times New Roman";
                _run.Parent     = paraPositionBullet.Para;
                paraPositionBullet.Para.Inlines.Add(_run);
                ListParaPosition.Add(paraPositionBullet);
            }
            ConverterListParaToDataDocument(ListParaPosition, document);

            _page.Children.Add(document);
        }
Beispiel #2
0
        public void tsc_loadtheme()
        {
            System.Text.StringBuilder specification = new System.Text.StringBuilder();
            PowerPoint.Shape          selShape      = ppApp.ActiveWindow.Selection.ShapeRange[1];


            MsoShapeType shpType = selShape.Type;

            if (selShape.Type == MsoShapeType.msoTable)
            {
                float borderWidth = selShape.Table.Rows[1].Cells[1].Borders[PowerPoint.PpBorderType.ppBorderRight].Weight;
            }
            else
            {
                foreach (PowerPoint.Shape shp in ppApp.ActiveWindow.Selection.ShapeRange)
                {
                    MsoTriState vstatus    = shp.Line.Visible;                                                     //LineVisible
                    MsoTriState fillStatus = shp.Fill.Visible;                                                     //FillVisible
                                                                                                                   //str fillColor = shp.Fill.ForeColor.RGB;               //FillColor-----------------------Not
                    float       fillTrasn = shp.Fill.Transparency;                                                 //FillTransparency
                    MsoTriState sVisible  = shp.Shadow.Visible;                                                    //ShadowVisible
                    float       sleft     = shp.Left;                                                              //ShapeLeft
                    float       stop      = shp.Top;                                                               //ShapeTop
                    float       swidth    = shp.Width;                                                             //ShapeWidth
                    float       shpHeight = shp.Height;                                                            //ShapeHeight
                    float       rot       = shp.Rotation;                                                          //Rotaion
                    MsoTriState lrvalue   = shp.LockAspectRatio;                                                   //LockAspectRatio

                    MsoTextOrientation    txtOrientation = shp.TextFrame.Orientation;                              //Orientation
                    MsoVerticalAnchor     txtAnchor      = shp.TextFrame.VerticalAnchor;                           //VerticalAnchor
                    PowerPoint.PpAutoSize autosize       = shp.TextFrame.AutoSize;                                 //AutoSize
                    float       mgleft      = shp.TextFrame.MarginLeft;                                            //MarginLeft
                    float       mgRight     = shp.TextFrame.MarginLeft;                                            //MarginRight
                    float       mgtop       = shp.TextFrame.MarginTop;                                             //MarginTop
                    float       mgbottom    = shp.TextFrame.MarginBottom;                                          //MarginBottom
                    MsoTriState wWrap       = shp.TextFrame.WordWrap;                                              //WordWrap
                    string      dtext       = shp.TextFrame.TextRange.Text;                                        //DefaultText
                    string      fname       = shp.TextFrame.TextRange.Font.Name;                                   //FontName
                    MsoTriState txbold      = shp.TextFrame.TextRange.Font.Bold;                                   //Bold
                    MsoTriState txItalics   = shp.TextFrame.TextRange.Font.Italic;                                 //Italics
                    MsoTriState txUnderline = shp.TextFrame.TextRange.Font.Underline;                              //Underline
                    float       txsize      = shp.TextFrame.TextRange.Font.Size;                                   //FontSize
                                                                                                                   //FontColor
                    PowerPoint.ShadowFormat shadow = shp.Shadow;                                                   //Shadow
                                                                                                                   //PowerPoint.PpChangeCase txcase = shp.TextFrame.TextRange.ChangeCase;                //Case
                    PowerPoint.BulletFormat         txbuttlet = shp.TextFrame.TextRange.ParagraphFormat.Bullet;    //ParagraphBullet
                    PowerPoint.PpParagraphAlignment txtAlig   = shp.TextFrame.TextRange.ParagraphFormat.Alignment; //ParagraphAlignment
                    MsoTriState hPun = shp.TextFrame.TextRange.ParagraphFormat.HangingPunctuation;                 //ParagraphHangingPunctuation
                    float       psb  = shp.TextFrame.TextRange.ParagraphFormat.SpaceBefore;                        //ParagraphSpaceBefore
                    float       psa  = shp.TextFrame.TextRange.ParagraphFormat.SpaceAfter;                         //ParagraphSpaceAfter
                    float       psw  = shp.TextFrame.TextRange.ParagraphFormat.SpaceWithin;                        //ParagraphSpaceWithin
                    float       rlfm = shp.TextFrame.Ruler.Levels[1].FirstMargin;                                  //RulerLevel1FirstMargin
                    float       rllm = shp.TextFrame.Ruler.Levels[1].LeftMargin;                                   ////RulerLevel1LeftMargin
                    for (int i = 1; i <= shp.TextFrame.TextRange.Paragraphs().Count; i++)
                    {
                        string paraStr   = shp.TextFrame.TextRange.Paragraphs(i).Text;
                        int    indentVal = shp.TextFrame.TextRange.Paragraphs(i).IndentLevel;
                    }

                    specification.Append("LineVisible :" + vstatus + Environment.NewLine + "FillVisible :" + fillStatus + Environment.NewLine + "FillTransparency :" + fillTrasn + Environment.NewLine);
                    specification.Append("ShapeLeft :" + sleft + Environment.NewLine + "ShapeTop :" + stop + Environment.NewLine + "ShapeWeight :" + swidth + Environment.NewLine + "ShapeHeight :" + shpHeight + Environment.NewLine);


                    specification.Append("Rotaion :" + rot + Environment.NewLine + "LockAspectRatio :" + lrvalue + Environment.NewLine + "Orientation :" + txtOrientation + Environment.NewLine + "VerticalAnchor :" + txtAnchor + Environment.NewLine);
                    specification.Append("AutoSize :" + autosize + Environment.NewLine + "MarginLeft :" + mgleft + Environment.NewLine + "MarginRight :" + mgRight + Environment.NewLine + "MarginTop :" + mgtop + Environment.NewLine);
                    specification.Append("MarginBottom :" + mgbottom + Environment.NewLine + "WordWrap :" + wWrap + Environment.NewLine + "DefaultText :" + dtext + Environment.NewLine + "FontName :" + fname + Environment.NewLine);
                    specification.Append("Bold :" + txbold + Environment.NewLine + "Italics :" + txItalics + Environment.NewLine + "Underline :" + txUnderline + Environment.NewLine + "FontSize :" + txsize + Environment.NewLine);
                    specification.Append("Shadow :" + shadow + Environment.NewLine + "ParagraphBullet :" + txbuttlet + Environment.NewLine + "ParagraphAlignment :" + txtAlig + Environment.NewLine + "ParagraphHangingPunctuation :" + hPun + Environment.NewLine);
                    specification.Append("ParagraphSpaceBefore :" + psb + Environment.NewLine + "ParagraphSpaceAfter :" + psa + Environment.NewLine + "ParagraphSpaceWithin :" + psw + Environment.NewLine + "RulerLevel1FirstMargin :" + rlfm + Environment.NewLine);
                    specification.Append("RulerLevel1LeftMargin :" + rllm);
                    PPTAttribute.saveSpacification(specification, shp.Name);
                }
            }
        }