Esempio n. 1
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public RevPos()
 {
     fStart = new Position(0, 0);
     fEnd = new Position(0, 0);
     fRange = null;
     fKind = KIND.TEXT;//デフォルト
 }
Esempio n. 2
0
        public RevPosOfTable(Position start, Position end, Word.Range rng)
        {
            if (start >= end) {
                throw new ArgumentOutOfRangeException(
                    this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
            }

            fStart = start;
            fEnd = end;
            fRange = rng;
            fKind = KIND.TABLE;
        }
Esempio n. 3
0
        public RevPosOfText(Position start, Position end, Word.Range rng)
        {
            //TODO:startとendが逆転するケースが有るらしい。
            if (start >= end) {
                //throw new ArgumentOutOfRangeException(
                //	this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
            }

            fStart = start;
            fEnd = end;
            fRange = rng;
            fKind = KIND.TEXT;
        }
Esempio n. 4
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);

            int i = 0;
            foreach (Word.Row row in range.Rows) {
                if (i == 0) {
                    row.Select();
                    start.fHeight
                        = selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);

                    if (row.IsFirst) {
                        row.Parent.Select();
                        selection.MoveEnd(Word.WdUnits.wdCharacter,
                            selection.Start - selection.End);
                    } else {
                        row.Previous.Select();
                    }
                    start.fPage = selection.get_Information(Word.WdInformation.wdActiveEndPageNumber);
                }

                row.Select();
                end.fPage = selection.get_Information(Word.WdInformation.wdActiveEndPageNumber);

                //末尾の取得
                if (row.IsLast) {
                    row.Parent.Select();
                    selection.MoveStart(Word.WdUnits.wdCharacter,
                        selection.End - selection.Start);
                    end.fHeight = selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
                } else {
                    row.Next.Select();
                    end.fHeight = selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage);
                }

                ++i;
            }

            return new RevPosOfTable(start, end, range);
        }
Esempio n. 5
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);
        }
        /// <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);
        }
Esempio n. 7
0
 public static bool isSamePage(Position x, Position y)
 {
     return (x.fPage == y.fPage);
 }
Esempio n. 8
0
 private static RevPos create(Position start, Position end, Word.Range rng, KIND kind)
 {
     switch (kind) {
         case KIND.FIGURE:
             return new RevPosOfFigure(start, end, rng);
         case KIND.TABLE:
             return new RevPosOfTable(start, end, rng);
         case KIND.TEXT:
             return new RevPosOfText(start, end, rng);
         default:
             return null;
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 複数ページにわたる変更箇所をページごとに分割する。
        /// </summary>
        /// <param name="revPos">変更箇所のリスト</param>
        /// <param name="offset">ページオフセット(40.0F程度が妥当?)</param>
        /// <returns></returns>
        public static List<RevPos> spliteRevPosition(List<RevPos> revPos, float offset)
        {
            List<RevPos> splitedPos = new List<RevPos>();
            foreach (RevPos pos in revPos) {
                //ページ分割不要な場合
                if (pos.fEnd.fPage == pos.fStart.fPage) {
                    splitedPos.Add(pos);
                } else {
                    for (int i = pos.fStart.fPage; i <= pos.fEnd.fPage; ++i) {

                        Word.Range rng = pos.fRange.Document.GoTo(Word.WdGoToItem.wdGoToPage, Type.Missing, Type.Missing, i);

                        Position start, end;
                        //1ページ目
                        if (i == pos.fStart.fPage) {
                            start = new Position(i, pos.fStart.fHeight);
                            end = new Position(i, pos.fRange.Document.PageSetup.PageHeight - offset);
                        }
                            //最終ページ目
                        else if (i == pos.fEnd.fPage) {
                            start = new Position(i, offset);
                            end = new Position(i, pos.fEnd.fHeight);
                        }
                            //途中のページ
                        else {
                            start = new Position(i, offset);
                            end = new Position(i, pos.fRange.Document.PageSetup.PageHeight - offset);
                        }
                        splitedPos.Add(RevPos.create(start, end, rng, pos.fKind));
                    }
                }
            }

            return splitedPos;
        }