Ahh... I realize that my explanation didn't answer to the first part of your question.

But that part should be clear already from the documentation:

General discount factor for year * y*:

*r(y)=1/(1+d(y))*

Present
value factor for costs occurring in year * y*,

*discounted to the beginning of year*

*z**:*

DISC(y,z) =∏_{u=z to y-1}r(u)

Therefore,
you can immediately see the answer to your question* "Is an investment made
in 2040 discounted for 10 years by 3% and then by 4% until the baseyear or is
the discount rate of 3% used for the entire timespan to the baseyear?” *The answer is, of course, that the present value factor
*DISC(y,z)*
for e.g. costs occurring in *y*=2040 does indeed
include the impact of the 3% rate for 10 (or 9) years, and the impact of the 4% rate for all the preceding years.

And the answer to your final question should be equally clear: the
present value factor *DISC(2035,z)* for investment payments occurring in year 2035 does include the impact of the 3% rate for several years.