Fix incorrect group calc state check.

And the code in the else block is pretty dangerous as it passes an empty
token array to the group interpreter whose effect is entirely unpredictable.

Also, declare the destructor of CompiledFormula class to be virtual as it
serves as a base class for DynamicKernel.

Change-Id: I4e191550a4437ad6ebac55fcdeee4f3654722ff1
(cherry picked from commit 95637452609260c97d8e5aaa7500531bb458a8bc)
Reviewed-on: https://gerrit.libreoffice.org/8468
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>