tdf#148380 doc: Import AUTHOR/CREATEDATE as FIXEDFLD

Writerfilter already did this earlier in the patch set.
So now change DOC format to do all the same things.

Change-Id: I8db2b4e3fc227b73c4d075ee624117e1b1f1d92e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132663
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/qa/extras/ww8export/data/tdf148380_createField.doc b/sw/qa/extras/ww8export/data/tdf148380_createField.doc
new file mode 100644
index 0000000..79c5e59
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf148380_createField.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index de913f30..5f0bf54 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -119,6 +119,19 @@ DECLARE_WW8EXPORT_TEST(testTdf147861_customField, "tdf147861_customField.doc")
    CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title (fixed)"), xField->getPresentation(true));
}

DECLARE_WW8EXPORT_TEST(testTdf148380_createField, "tdf148380_createField.doc")
{
    // Verify that these are fields, and not just plain text
    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
    auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
    uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY);
    // This should NOT be "Lorenzo Chavez", or a real date since the user hand-modified the result.
    CPPUNIT_ASSERT_EQUAL(OUString("Myself - that's who"), xField->getPresentation(false));
    xField.set(xFields->nextElement(), uno::UNO_QUERY);
    CPPUNIT_ASSERT_EQUAL(OUString("yesterday at noon"), xField->getPresentation(false));
}

DECLARE_WW8EXPORT_TEST(testTdf138345_paraCharHighlight, "tdf138345_paraCharHighlight.doc")
{
    uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(9), 1, "A side benefit is that "), uno::UNO_QUERY_THROW);
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 032c302..551152e8 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2939,8 +2939,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
                        eField = ww::eCREATEDATE;

                    // Create author/time are always imported as fixed. Safe to ignore on export
                    if (GetExport().GetExportFormat() != MSWordExportBase::DOC)
                        bWriteExpand = false;
                    bWriteExpand = false;
                    break;

                case DI_CHANGE:
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index fd19f6c..1029e98 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -1714,7 +1714,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
            nReg = DI_SUB_AUTHOR;
            break;
        case 21:
            nSub = DI_CREATE;
            nSub = DI_CREATE | DI_SUB_FIXED;
            nReg = DI_SUB_DATE;
            bDateTime = true;
            break;
@@ -1790,8 +1790,9 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
        aData = aData.replaceAll("\"", "");
    }

    SwDocInfoField aField( static_cast<SwDocInfoFieldType*>(
        m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DocInfo )), nSub|nReg, aData, nFormat );
    const auto pType(static_cast<SwDocInfoFieldType*>(
        m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo)));
    SwDocInfoField aField(pType, nSub|nReg, aData, GetFieldResult(pF), nFormat);
    if (bDateTime)
        ForceFieldLanguage(aField, nLang);
    m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
@@ -1799,12 +1800,12 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
    return eF_ResT::OK;
}

eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, OUString& )
eF_ResT SwWW8ImplReader::Read_F_Author(WW8FieldDesc* pF, OUString&)
{
        // SH: The SwAuthorField refers not to the original author but to the current user, better use DocInfo
    SwDocInfoField aField( static_cast<SwDocInfoFieldType*>(
                     m_rDoc.getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::DocInfo )),
                     DI_CREATE|DI_SUB_AUTHOR, OUString() );
                     DI_CREATE|DI_SUB_AUTHOR|DI_SUB_FIXED, OUString(), GetFieldResult(pF));
    m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) );
    return eF_ResT::OK;
}