Two events are referred to: Action A, followed by Action B:
She cooks the meal; He eats the meal >> When she had cooked the meal, he ate it.
He prepares a report; he sends a report >> When he had written the report, he sent it to the committee.
Jo writes a letter to Kay; Jo sends the letter> Jo had written to Kay about the holiday and sent it to him on his birthday.
See these links for more examples:
ENGLISH PAGE - Past Perfect Past Perfect 1 - An English-Zone.Com Quiz