We consider a magnetic field $\bf B$ occupying the simply connected domain $D$ and having all its field lines tied to the boundary $S$ of $D$. We assume here that $\bf B$ has a simple topology, i.e., the mapping $\bf M$ from positive to negative polarity areas of $S$ associating to each other the two footpoints of any magnetic line, is continuous. We first present new formulae for the helicity $H$ of $\bf B$ relative to a reference field $\bf B$$_r$ having the same normal component $B$$_n$ on $S$, and for its field line helicity $h$ relative to a reference vector potential $\bf C$$_r$ of $\bf B$$_r$. These formulae make immediately apparent the well known invariance of these quantities under all the ideal MHD deformations that preserve the ...