Exemple #1
0
        /// <summary>
        /// 设置一个形状中所有字符的上下标
        /// </summary>
        /// <param name="shp"></param>
        /// <param name="superScript">null 表示“正常”,true表示“上标”,false表示“下标”</param>
        private static void SuperOrSubScriptShape(Shape shp, bool?superScript)
        {
            List <Shape> nestedShapes = ShapeSearching.GetAllShapes(shp, includeMyself: true);

            foreach (Shape subShape in nestedShapes)
            {
                if (!string.IsNullOrEmpty(subShape.Text))
                {
                    // 如果前期对形状中的字符进行过上下标的单独设置,则这里如果仅仅只设置形状整体的上下标格式,可能会出现形状中部分字符不跟随设置而变化的情况。
                    if (superScript == null)
                    {
                        subShape.Characters.CharProps[(short)VisCellIndices.visCharacterPos] = (short)VisCellVals.visPosNormal;
                        subShape.CellsSRC[(short)VisSectionIndices.visSectionCharacter, (short)0, (short)VisCellIndices.visCharacterPos].FormulaU = VisCellVals.visPosNormal.GetHashCode().ToString();
                    }
                    else if (superScript.Value)
                    {
                        subShape.Characters.CharProps[(short)VisCellIndices.visCharacterPos] = (short)VisCellVals.visPosSuper;
                        subShape.CellsSRC[(short)VisSectionIndices.visSectionCharacter, (short)0, (short)VisCellIndices.visCharacterPos].FormulaU = VisCellVals.visPosSuper.GetHashCode().ToString();
                    }
                    else
                    {
                        subShape.Characters.CharProps[(short)VisCellIndices.visCharacterPos] = (short)VisCellVals.visPosSub;
                        subShape.CellsSRC[(short)VisSectionIndices.visSectionCharacter, (short)0, (short)VisCellIndices.visCharacterPos].FormulaU = VisCellVals.visPosSub.GetHashCode().ToString();
                    }
                }
            }
        }
Exemple #2
0
        // 开始具体的调试操作
        private static void DoSomething(Application vsoApp)
        {
            Document doc = vsoApp.ActiveDocument;

            if (doc != null)
            {
                var p    = vsoApp.ActivePage;
                var shps = ShapeSearching.GetAllShapes(p);
                foreach (Shape shp in shps)
                {
                    MessageBox.Show(shp.ID.ToString());
                }
            }
        }