Anomalous D-brane and orientifold couplings from the boundary state