Esempio n. 1
0
        /// <summary>
        /// テキストの変更箇所を識別する。
        /// </summary>
        /// <param name="range">変更箇所のレンジ</param>
        /// <returns>テキストの変更箇所</returns>
        public static new RevPos create(Word.Range range)
        {
            Word.Selection selection = range.Application.Selection;
            Position start = new Position(0, 0);
            Position end = new Position(0, 0);

            range.Select();

            //終了ページと開始位置の取得
            start.fHeight
                = range.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
            end.fPage
                = range.get_Information(Word.WdInformation.wdActiveEndPageNumber);

            //終了位置の取得
            int ret = selection.MoveStart(Word.WdUnits.wdCharacter, range.End - range.Start);
            if (ret == 0) {
                throw new System.Exception();
            }

            //ヘッダだとエラーコードが-1になる。
            float posInThePage = selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
            //ヘッダー以外の場合
            if (posInThePage != -1) {
                end.fHeight = posInThePage + selection.Font.Size * 1.5F;
            }
                //ヘッダーの場合
            else {
                end.fHeight = range.Document.PageSetup.TopMargin - 5.0F;
            }

            range.Select();

            //開始ページ番号取得
            selection.MoveEnd(Word.WdUnits.wdCharacter, range.Start - range.End);
            start.fPage
                = selection.get_Information(Word.WdInformation.wdActiveEndPageNumber);

            return new RevPosOfText(start, end, range);
        }
Esempio n. 2
0
 /// <summary>
 /// ワードのレンジオブジェクトから変更箇所の位置を同定する。
 /// </summary>
 /// <param name="range">変更箇所のレンジ</param>
 /// <returns>変更箇所</returns>
 public static RevPos create(Word.Range range)
 {
     //図の場合
     if (range.InlineShapes.Count > 0) {
         return RevPosOfFigure.create(range);
     }
         // 表の場合
     else if (range.get_Information(Word.WdInformation.wdWithInTable)) {
         return RevPosOfTable.create(range);
     }
         //文書等の場合
     else {
         return RevPosOfText.create(range);
     }
 }
        /// <summary>
        /// 図の変更箇所を識別する。
        /// </summary>
        /// <param name="range">変更箇所のレンジ</param>
        /// <returns>図の変更箇所</returns>
        public static new RevPos create(Word.Range range)
        {
            Word.Selection selection = range.Application.Selection;
            Position start = new Position(0, 0);
            Position end = new Position(0, 0);

            //終了ページと開始位置の取得
            start.fHeight = range.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
            end.fPage = range.get_Information(Word.WdInformation.wdActiveEndPageNumber);

            end.fHeight = range.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);

            //図の大きさ分だけ終了位置を移動
            range.Select();
            foreach (Word.InlineShape shp in selection.InlineShapes) {
                end.fHeight += shp.Height;
            }

            //開始ページ番号取得
            selection.MoveEnd(Word.WdUnits.wdCharacter, range.Start - range.End);
            start.fPage = selection.get_Information(Word.WdInformation.wdActiveEndPageNumber);

            return new RevPosOfFigure(start, end, range);
        }
        private void AddTabStops(Word.Selection sel)
        {
            float codeblock_width;
            // in a table tab stops should be placed only where the cell is located horizontally
            if (sel.get_Information(Word.WdInformation.wdWithInTable) == true)
            {
                sel.SelectColumn();
                codeblock_width = wordApp.Selection.Columns[1].Width;   // no too elegant... but there is no better solution in the Word API
            }
            else
            {
                codeblock_width = sel.PageSetup.PageWidth - sel.PageSetup.RightMargin - sel.PageSetup.LeftMargin;
            }

            sel.ParagraphFormat.TabStops.ClearAll();

            for (float j = indentLength; j < codeblock_width; j += indentLength)
            {
                Object alignmentType = Word.WdTabAlignment.wdAlignTabLeft;
                Object tabLeader = Word.WdTabLeader.wdTabLeaderSpaces;
                sel.ParagraphFormat.TabStops.Add(j, ref alignmentType, ref tabLeader);
            }
        }