Before I even look at the code (its late and I'd probably talk rot if I started to understand anyone elses code right now - bad day, too much on mind.. bleh)
If you had a picture as class, which allowed moving (as zoomed in you see less of the picture etc) you would have
current rect viewport - area of pic to display
current scale
So, when the pic zooms in you use the scale to select a relevant size box centred over either the click on the picture or the centre of the box..
move will tell you how much to move in conjunction with the scale
zoom out does kinda the same only of course it means you see a bigger area of the original image..
The math still seems relatively simple to me.. should I be raiding the teapot (dont drink coffee) again?