TSCP: Fix crash when no header/footer is present yet

Change-Id: I681920347e01ccbc1e18348d00c1e29dac5a8e64
Reviewed-on: https://gerrit.libreoffice.org/44441
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index a6dc65b..ec84aec 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -777,7 +777,6 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
        if (xHeaderText.is())
            removeAllClassificationFields(sPolicy, xHeaderText);

        equaliseNumberOfParagraph(rResults, xHeaderText);

        // FOOTER
        bool bFooterIsOn = false;
@@ -787,8 +786,6 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
            xPageStyle->getPropertyValue(UNO_NAME_FOOTER_TEXT) >>= xFooterText;
        if (xFooterText.is())
            removeAllClassificationFields(sPolicy, xFooterText);

        equaliseNumberOfParagraph(rResults, xFooterText);
    }

    // Clear properties
@@ -822,6 +819,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
            xPageStyle->setPropertyValue(UNO_NAME_HEADER_IS_ON, uno::makeAny(true));
        uno::Reference<text::XText> xHeaderText;
        xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT) >>= xHeaderText;
        equaliseNumberOfParagraph(rResults, xHeaderText);

        // FOOTER
        bool bFooterIsOn = false;
@@ -830,6 +828,7 @@ void SwEditShell::ApplyAdvancedClassification(std::vector<svx::ClassificationRes
            xPageStyle->setPropertyValue(UNO_NAME_FOOTER_IS_ON, uno::makeAny(true));
        uno::Reference<text::XText> xFooterText;
        xPageStyle->getPropertyValue(UNO_NAME_FOOTER_TEXT) >>= xFooterText;
        equaliseNumberOfParagraph(rResults, xFooterText);

        uno::Reference<text::XParagraphCursor> xHeaderParagraphCursor(xHeaderText->createTextCursor(), uno::UNO_QUERY);
        uno::Reference<text::XParagraphCursor> xFooterParagraphCursor(xFooterText->createTextCursor(), uno::UNO_QUERY);