hello somebody can explain divorce law in spain.

i am non eu civil partner to british national for more than 3 years we lived together in spain for a year since we separated for more than 2 years i was not working in spain and i am flying in and out to uk and spain as i have new relationship in the uk . and applying divorce or dissulotion in the uk cause we got married in the uk with my ex partner . concern is.

1. Will my residence still valid when my dissulotion came through?
2.Can apply uk fiance visa from uk embassy in madrid ?

Advice and explanation would be appreciate.

Pads