The present perfect of any verb is composed of two elements : the appropriate form of the auxiliary verb to have (present tense), plus the past participle of the main verb. The past participle of a regular verb is base+ed, e.g. played, arrived, looked. For irregular verbs, see the Table of irregular verbs in the section called 'Verbs'.
The past perfect refers to a time earlier than before now. It is used to make it clear that one event happened before another in the past. It does not matter which event is mentioned first - the tense makes it clear which one happened first.
First part: John had gone out -- 2nd: when I arrived in the office.