fdo#81102: fix .doc import of blank even page header

Honour the "different odd & even pages" header/footer setting from the
doc file even if there is no content for an even page header or footer.

Conflicts:
	sw/qa/extras/ww8import/ww8import.cxx
Reviewed on:
	https://gerrit.libreoffice.org/10191

Change-Id: I963f7f7189e399b1d859db0788fbfd291e868c54
diff --git a/sw/qa/extras/ww8import/data/fdo81102.doc b/sw/qa/extras/ww8import/data/fdo81102.doc
new file mode 100755
index 0000000..e8a5507
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/fdo81102.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 58a3bc1..354e555 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -469,6 +469,22 @@ DECLARE_WW8IMPORT_TEST(testFdp80333, "fdo80333.doc")
    CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location);
}

DECLARE_WW8IMPORT_TEST(testFdo81102, "fdo81102.doc")
{
    // get page style at beginning of document
    uno::Reference<text::XTextDocument> textDocument(
        mxComponent, uno::UNO_QUERY);
    uno::Reference<text::XTextRange> start(
        textDocument->getText()->getStart(), uno::UNO_QUERY);
    OUString pageStyleName = getProperty<OUString>(start, "PageStyleName");
    uno::Reference<style::XStyle> pageStyle(
        getStyles("PageStyles")->getByName(pageStyleName), uno::UNO_QUERY);

    // check that left and right pages do not share the same header
    bool headerIsShared = getProperty<bool>(pageStyle, "HeaderIsShared");
    CPPUNIT_ASSERT(!headerIsShared);
}

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 885cf12..029cce8 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4318,15 +4318,12 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,

void wwSectionManager::SetUseOn(wwSection &rSection)
{
    bool bEven = (rSection.maSep.grpfIhdt & (WW8_HEADER_EVEN|WW8_FOOTER_EVEN)) ?
        true : false;

    bool bMirror = mrReader.pWDop->fMirrorMargins ||
        mrReader.pWDop->doptypography.f2on1;

    UseOnPage eUseBase = bMirror ? nsUseOnPage::PD_MIRROR : nsUseOnPage::PD_ALL;
    UseOnPage eUse = eUseBase;
    if (!bEven)
    if (!mrReader.pWDop->fFacingPages)
        eUse = (UseOnPage)(eUse | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE);
    if (!rSection.HasTitlePage())
        eUse = (UseOnPage)(eUse | nsUseOnPage::PD_FIRSTSHARE);