First-principles modeling of x-ray Raman scattering spectra