Theory of core-level spectra in x-ray photoemission of pristine and doped graphene