Fixing perspective on a document or a building
Perspective Crop in Paint by Zaweba flattens a tilted document to a rectangle, and Perspective Warp and Wide Angle Correction fix leaning buildings.

For a document, a sign or a painting shot at an angle, Perspective Crop is the answer: mark its four corners and Paint by Zaweba flattens it into a rectangle. For buildings whose walls lean inwards, Edit > Perspective Warp squares up the verticals, and Filter > Wide Angle Correction straightens lines bent by a wide lens. All three are in the free, offline editor for Windows.
Perspective problems come from the camera not facing the subject square on. Point a phone down at a letter on a desk and the page comes out as a trapezium. Tilt a camera up at a church and the towers lean towards each other. Rotating the picture won't fix either, because the lines aren't tilted, they're converging.
Flattening a document with Perspective Crop
Perspective Crop lives in the crop group of tools. Open the photo and place a corner point on each of the four corners of the page, sign or canvas. Take care here, because the corners decide everything. Zoom in to put each point exactly on the corner of the paper rather than its shadow.
Then set the size. Paint can work out the output size from the sides you marked, or you can type a width and height, which is better when you know the real proportions, such as an A4 page. Apply it and the four corners are pulled out to a clean rectangle, cropped to the object. It works on all layers, so a layered document stays in line.
For scanned looking results from a phone photo of paper, follow up with Levels or Curves to whiten the background, and the page looks almost as if it came off a scanner.
Squaring up buildings with Perspective Warp
Perspective Warp works in two stages. First, lay out quads over the flat planes in the picture, such as the front and side of a building. Quads that touch at the corners join up, so a corner of a building can be covered by two planes sharing an edge.
Then switch to warping and drag the corners to change the perspective. To make walls truly vertical, Shift+click an edge, or use the option to straighten verticals and horizontals. This is the classic architectural fix: the towers stop leaning and the building stands up straight.
Leave a little room around the building before you start, since correcting converging verticals pulls in the top of the frame and you will need to crop.
Bent lines from a wide lens
A very wide lens, and especially a fisheye, bends straight lines near the edges into curves. Filter > Wide Angle Correction handles this. Trace constraint lines along edges that should be straight, such as a doorframe or a roofline, and choose a fit: Auto, Fisheye, Perspective or Full Spherical. The picture is remapped so those lines come out straight.
Trace only lines you are sure were straight in real life. Two or three good lines usually do more than many doubtful ones.
Getting a good result
Don't overcorrect. Buildings with perfectly parallel sides can look top heavy, because our eyes expect a little convergence when we look up. Many photographers correct most of the lean and leave a hint of it. For documents the opposite is true: flatten fully so text lines run straight.
Check edges after any of these changes. Stretching a corner of the picture can soften it, and you may want to crop slightly tighter or fill the gaps.
Which tool to use
Use Perspective Crop when the thing you want is a flat rectangle and the surroundings don't matter. Use Perspective Warp when you want to keep the scene and fix how it leans. Use Wide Angle Correction when lines curve rather than lean. With those three, Paint by Zaweba covers nearly every perspective problem a camera can make.