Oil leak on 2002 Volvo S40

Car became sluggish. When I stopped and checked under thee hood, there was oil thrown all over the engine. What could this be and how much to fix? The car has 140,000 miles on it check engine light is on

Asked by for the 2002 Volvo S40
Oil fill cap in place and in good shape?