diff options
author | Justin Luth <justin_luth@sil.org> | 2022-04-06 11:44:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-04-13 09:57:33 +0200 |
commit | 55c7691fadfb9b3a4869cc14432ec57c858f693f (patch) | |
tree | 21c4e506bf57d9aba7b87cb351d6bf42b22cd177 /sw | |
parent | ada2d449175afd9a6aa1db9281739e5ad6ac6fef (diff) |
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>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf148380_createField.doc | bin | 0 -> 10240 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export3.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 11 |
4 files changed, 20 insertions, 7 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf148380_createField.doc b/sw/qa/extras/ww8export/data/tdf148380_createField.doc Binary files differnew file mode 100644 index 000000000000..79c5e59c5ecd --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf148380_createField.doc diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index de913f30c451..5f0bf54078cd 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 032c302460c6..551152e875f8 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 fd19f6c11630..1029e98fabe7 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; } |