My friend had a cat who started peeing everywhere, she thought it was because of her new baby, but it turned out it was totally unconnected to the baby: they found out the cat had cystitis, from stress / nerves at a male, territorial cat being around and invading her territory.
My friend was told that when cats have cystitis from stress they can't wee until they feel relaxed, so that's why the cat was weeing in odd places. She'd relax when on the sofa for example, then the wee would come out. She was stressed as a Tom had invaded her house, and she was scared of him. Her fear was being made worse by the placement of the litter tray and the catflap: apparently cats like to be able to see all around them when they're going to the toilet. They're vulnerable then, and so they like to know what's creeping up on them. Of course as humans we like privacy and so we often stick a cat's litter tray somewhere private, thinking we're being nice when in fact the cat hates it!
The other thing was the cat flap - when she went through it, she couldn't see what was on the other side before going through the flap, but it was very exposed on the other side, leaving her feeling vulnerable. The trick there was to put plants around the catflap, so she came out into cover and could survey the scene before jumping into it IYSWIM.
I have no idea if any of this applies to your cat, but posting just in case it rings a bell!