cppcheck: fix Division by zero + move some lines

See http://nabble.documentfoundation.org/Cppcheck-reports-quot-Division-by-zero-quot-in-new-cxx-sfx2-module-td4102613.html

Change-Id: I71433bcb20575016ee2e993a67c6e09646672f9b