It appears that the cast iron under the floor is in good condition. I believe I would stub the pipe off just about where that rust spot is and replace with a banded coupler, a short piece of PVC, PVC closet bend, another short piece of PVC, and a new flange. I would not cut the PVC coming up from the closet bend nor attach the flange until the finished floor was down. You obviously need to do some repair on the sub floor, and the flange should set on top of the finish floor (not flush) The new flange will need to be screwed through the finished floor and into the sub floor. The current flange did not need to be screwed down because it was leaded to the cast iron so it was very solid, but the new flange could flex a little. Now, this is not the only way the job can be done, but it is something you could probably do yourself. The most difficult part of it is cutting the cast iron pipe. Best to rent a chain pipe cutter, but a grinder will also work. I have never had success using a recip saw although some guy apparently have cut cast with a special blade.