Avoid potential nullptr access for Document, use reference instead
Summary:
Using a TermGenerator without backing document is pointless and can
even crash when the document has been initialized with a nullptr.
Test Plan: ctest
Reviewers: Baloo, Frameworks, astippich, ngraham
Reviewed By: astippich
Subscribers: kde-frameworks-devel
Tags: Frameworks, Baloo
Differential Revision: https://phabricator.kde.org/D17315