As always in music, it's very subjective. There is no one rule that applies to all and everything. This is particularly true for jazz, it is very free.
1. On triplet feeling
Swing feeling does not necessarily place the eighths exactly on where exact triplets would. Exact triplets make a song sound kind of stiff and not very "swingy" (again, subjective). It might fit for a dixie tune, or old swing. It wouldn't be good for another genre. My recommendation if you are writing this program is to give the user the opportunity to relax or tighten up the triplet feeling.
2. Which notes get affected?
So my answer is: it depends. If you have a group of four 16th, a human musician might very well want to play them long-short-long-short. There is no rule that always applies.
Also, am I correct to assume that, for eighth notes, I should only alter their durations if they fall directly on a beat or the "and" of a beat?
Are there any other cases? Do you mean 16th rest, 8th note, 16th rest? Deal with that case as you would a 16th.
3. What is swing feeling?
One definition of "swinging" a tune that I like better than just giving eighths a triplet rhythm, is that the accentuation is on the off-beat. In a group of eight 8th, you would play the second, fourth, sixth, and last note stronger that the other ones. This leads quite naturally to these notes starting a bit later, thus getting a more loose rhythm towards triplets. Try to give these off beat notes a little boost in velocity, I think that would be a nice effect.
This is also what would make the "triplet feeling" apply to the group of 16th I mentioned earlier. Weak-strong-weak-strong, and you naturally get this loose rhythm.
It is quite usual to hear musicians (often classical) who are new to jazz play with exact triplets and accents on the beats. It doesn't swing very well.
This all is of course a bit depressing for someone trying to write software.
Some more food for thought:
http://en.wikipedia.org/wiki/Swung_note#Swung_note
You had me read a great article about swing feeling:
http://jazzadvice.com/developing-a-concept-of-swing/
Yes, everyone is taught the standard “off beat” articulation of swing eighth notes, and you’re right, swing is much more complicated than that. It’s not even that it’s more complicated. It’s that swing cannot be defined by anything that you can write down.