Analytical formalism for heavy-ion-induced direct nuclear reactions: elastic and inelastic scattering