It's mostly question of cable's resistance. Complete resistance of line including the resistance of device connected on the end must not exceed some value.
Standard telephone wire is gauge 22 (AWG) copper wire. The typical resistance of such wire is 53 Ω/1km.
I know no exact resistance limit accepted by for SPA112, but I assume it would be something about 1000Ω. So 400m of 22AWG wire should fit the limits even with unknown resistance of your's analogue phone (most common resistance of standard phone is 200-300 Ω off-hook).
There should be no problems with 400m line. No warranties, of course.
Beware of lightnings in the case of outdoor installation. Use apropriate lightning arrester on boths end of line.