Calculations of X-ray Emission Spectra of Molecules and Surface Adsorbates by Means of Density Functional Theory