Created private functions to avoid duplicated code in Document

Status Job ID Name Coverage
  Build
canceled #15749
build_ubuntu_18_04

canceled #15748
linux kf5-qt5 qt5.12