Modelling the incomplete Paschen-Back effect in the spectra of magnetic Ap stars