Theory of 3d Core Level Spectra of CeO2 and Metallic Ce Compounds