tdf#132667 - Grab focus on the last inserted property

On removing/adding custom document properties, grab the focus on the
last empty shown name box.

Change-Id: Ifd66566d4ae9fa57b9f1a9aae5f9cb93dbb74070
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115872
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 40bd42c..13349d3 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1492,7 +1492,6 @@ void CustomPropertiesWindow::CreateNewLine()
        pNewLine->m_xRemoveButton->get_buildable_name() + OString::number(nSize));

    pNewLine->DoTypeHdl(*pNewLine->m_xTypeBox);
    pNewLine->m_xNameBox->grab_focus();
}

bool CustomPropertiesWindow::AreAllLinesValid() const
@@ -1770,6 +1769,13 @@ void CustomPropertiesWindow::ReloadLinesContent()
        pLine->DoTypeHdl(*pLine->m_xTypeBox);
    }

    // tdf#132667 - grab focus on the last inserted property
    if (i > 0 && m_aCustomProperties[nDataModelPos + i - 1]->m_sName.isEmpty())
    {
        CustomPropertyLine* pLine = m_aCustomPropertiesLines[i - 1].get();
        pLine->m_xNameBox->grab_focus();
    }

    while (nDataModelPos + i >= GetTotalLineCount() && i < GetExistingLineCount())
    {
        CustomPropertyLine* pLine = m_aCustomPropertiesLines[i].get();