A good rapport with coworkers and management can help mitigate a lot of distractions. Read: It can allow you to get away with some passive-aggressive stuff, yet not draw the ire of the office. ;)
There are the basics which you and others have already mentioned:
Presently, I have a private office; however, the walls are thin, floors are tile and so office sounds/conversations carry far. Previously, I shared a large office with two coworkers, but there were constant distractions between chatter, foot traffic, impromptu in-office meetings, etc. As much as I espouse the importance of not interrupting a developer's "flow"; the distractions persist...
So, when I really need to buckle down and get some work down, I break out the big guns: Once my headphones go on, if someone disturbs my train of thought, I shoot them a dirty look of disapproval. Works great! Most people immediately assume that you're in a nasty mood and will give you plenty of space thereafter. When finished with the work, my headphones come off and I carry on with officemates as if everything is normal.
At times when the dirty look strategy has not done the trick, I've been known to print a "do not disturb" ("leave me alone, or else") sign for my door/desk/monitor. Combined with the headphones and grumpy face, all but the most insensitive coworker will get the hint.
Sure, this strategy does nothing about ambient office noise, but it can greatly reduce the frequency of direct interruptions. However, as I remarked initially, you need to have a good rapport with your officemates first, else you could end up looking like a jerk!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.