Robusto's answer accounts quite clearly for Doyle's use, which reflects (I think tongue in cheek, but I could be wrong) the vices of contemporaneous journalism.
Your own examples, however, do indeed reflect "a special, dedicated way to express some relations between moments of time". To pin down what the differences are, try recasting your abstract actions—the do somethings—as concrete ones, and add temporal modifiers, thus:
I will do something if you have done something.
"I'm leaving for the office now. I will give your letter to the boss if you have finished it." Here the focus is on the moment of leaving. The letter must be finished (which is what 'perfect' means, literally) now; otherwise I cannot take it with me. And the letter is to be delivered in the future, with respect to that moment.
I did something when he had done something.
"I left for the office at eight o'clock. Ed had finished the letter, so I would give it to the boss when I arrived." As before, the focus is on a single moment of leaving; but that moment is now in the past, so the simple present is recast as a simple past; the simple perfect is recast as a past perfect by employing the past of the auxiliary; and in very old-fashioned writing, the future is also recast with the past of the auxiliary.
Today, however, practically nobody understands would to be the past tense of will; it is rarely used outside an "unreal" context. In effect, English has lost the future-in-the-past construction. Consequently, you must replace would with the past form of a different expression such as can—"so I could give, &c".
If, however, the "unreal" came into play, if what you intended didn't actually happen, you would revert to would. BUT: in this case, the loss of the future-in-the-past requires you to shift your focus to a subsequent time—the time at which the anticipated event failed to occur. So the future-in-the-past event becomes an unreal-perfect-in-the-past event: "I would have given it to the boss when I arrived, but he had already left."
I will do something if you do something.
"I'm leaving for the office now. If you bring me the letter before noon I will give it to the boss." Now the focus is on future events, so a future construction is employed in the indicative main clause; it could be used in the conditional as well, but the 'present' tense (which is actually not a present tense but a non-past tense) is ordinarily used in these constructions, since the conditional's 'modal' quality embraces futurity.
I did something when he did something.
"I left for the office at eight o'clock. I gave the letter to the boss when Ed brought it to me at eleven." Once more, all the events are in the past; in this case, however, there is no obnoxious future to express, and the sequence is made clear lexically, so the simple past construction can be used throughout.