The cohomology of orthogonal locally symmetric spaces and the theta-correspondence