6th place is already UEFA Cup.
If Middlesbrough win the UEFA Cup and reach the FA Cup final then 7th is UEFA Cup spot. If the situation is as in your question 5th and 6th are still UEFA Cup spots
If West Ham beats Middlebrough, they gets a place through FA Cup.
If Middlebrough wins the Uefa Cup, will they be given a place to defend the champion? (Liverpool case last year)
And if they both finish outside the top 6, that means only the team finishing at 5th can get into Uefa Cup because only 3 places are available.
A place through the league (5th), a place through the FA Cup and a place through the Carling Cup. The Carling Cup place has already gone to the league (i.e. 6th). There is a space already available for the UEFA Cup winners whoever they be so if Boro win the UEFA Cup, they don't take a spot from the Premiership, there is already a space available for the winners of the competition.