The Barcelona local government has outsourced their all film licensing and other governing tasks to an outside agency called the Barcelona and Catalunya Film Commission, which works on subsidies and service fees.
The aim of the commission is support and govern film activities in Catalunya. They offer information, a directory on local film related companies and a list of film locations. To legally film in any public location you will need to apply for a film license, which can be arranged through the commission.
For protecting the rights for your work (.e. a script or other piece of creative work), you can apply for copyrights under Spanish law at the Spanish Registry for Interlectual Property rights, which has an office in Barcelona.