If that article of the civil code is applied equally to all marriages between Spaniards and foreigners then there's no problem, unless that part of the code was established just to cover same sex marriages. Sounds like all the gentleman from India has to do is become a Spanish citizen. He's already a resident. Unless (again) there are roadblocks that apply only to GLTB individuals applying for Spanish citizenship.