  We introduce the notion of cofoliation on a stack. A cofoliation is a change
of the differentiable structure which amounts to giving a full representable
smooth epimorphism. Cofoliations are uniquely determined by their associated
Lie algebroids.
  Cofoliations on stacks arise from flat connections on groupoids. Connections
on groupoids generalize connections on gerbes and bundles in a natural way. A
flat connection on a groupoid is an integrable distribution of the morphism
space compatible with the groupoid structure and complementary to both source
and target fibres. A cofoliation of a stack determines the flat groupoid up to
etale equivalence.
  We show how a cofoliation on a stack gives rise to a refinement of the Hodge
to De Rham spectral sequence, where the E1-term consists entirely of vector
bundle valued cohomology groups.
  Our theory works for differentiable, holomorphic and algebraic stacks.
