Planck intermediate results: XXVIII. Interstellar gas and dust in the Chamaeleon clouds as seen by Fermi LAT and Planck