Apache OpenOffice (AOO) Bugzilla – Issue 128398
autotest fvt.uno.sd.file.CheckFileProperties loses some DocumentProperties when saving
Last modified: 2020-07-31 03:00:17 UTC
$ cd test/ $ ant -Dtest.args='-tc fvt.uno.sd.file.CheckFileProperties' Several unit tests will fail, including: testGeneralRevisionNumber testGeneralEditingDuration testGeneralPrintBy testGeneralPrintDate The values set by the test for those document properties end up getting lost while saving, and when the document is reloaded, the value read back is different. For example testGeneralRevisionNumber sets editing cycles to 10, but it ends up as 1 in the .odp file. When read back, 1 and 10 differ, hence the test fails. This was tested in the latest trunk.
Patching the test to sleep a bit: diff --git a/test/testuno/source/fvt/uno/sd/file/CheckFileProperties.java b/test/testuno/source/fvt/uno/sd/file/CheckFileProperties.java index 8e169a5df4..5c17b90489 100644 --- a/test/testuno/source/fvt/uno/sd/file/CheckFileProperties.java +++ b/test/testuno/source/fvt/uno/sd/file/CheckFileProperties.java @@ -313,10 +313,12 @@ public class CheckFileProperties { XDocumentProperties xDocPro = getDocumentProperties(); + Thread.sleep(15000); xDocPro.setEditingCycles(revisionNumber); app.saveDocument(m_xSDComponent, m_filePath); allows attaching a debugger to AOO. Then: (gdb) bt #0 (anonymous namespace)::SfxDocumentMetaData::serialize(com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler> const&, com::sun::star::uno::Sequence<com::sun::star::beans::StringPair> const&) (this=0x80e6891b0, i_xHandler=..., i_rNamespaces=...) at source/doc/SfxDocumentMetaData.cxx:2309 #1 0x0000000804f94cb1 in SvXMLMetaExport::Export() (this=0x80e8ded30) at source/meta/xmlmetae.cxx:369 #2 0x0000000804ebd20e in SvXMLExport::_ExportMeta() (this=0x80e659c50) at source/core/xmlexp.cxx:1588 #3 0x0000000804ef81c5 in SdXMLExport::_ExportMeta() (this=0x80e659c50) at source/draw/sdxmlexp.cxx:1894 #4 0x0000000804ebcdc2 in SvXMLExport::exportDoc(xmloff::token::XMLTokenEnum) (this=0x80e659c50, eClass=xmloff::token::XML_PRESENTATION) at source/core/xmlexp.cxx:1521 #5 0x0000000804ebafb4 in SvXMLExport::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (this=0x80e659c50, aDescriptor=...) at source/core/xmlexp.cxx:938 #6 0x000000080ad267cf in SdXMLFilter::Export() (this=0x7fffdfdfab28) at source/filter/xml/sdxmlwrp.cxx:1085 #7 0x000000080ac96684 in sd::DrawDocShell::SaveAs(SfxMedium&) (this=0x80a3f3ae0, rMedium=...) at source/ui/docshell/docshel4.cxx:606 #8 0x00000008015ac8e6 in SfxObjectShell::SaveAsOwnFormat(SfxMedium&) (this=0x80a3f3ae0, rMedium=...) at source/doc/objstor.cxx:3270 #9 0x000000080ac97c21 in sd::DrawDocShell::SaveAsOwnFormat(SfxMedium&) (this=0x80a3f3ae0, rMedium=...) at source/ui/docshell/docshel4.cxx:1211 #10 0x00000008015a1027 in SfxObjectShell::SaveTo_Impl(SfxMedium&, SfxItemSet const*) (this=0x80a3f3ae0, rMedium=..., pSet=0x0) at source/doc/objstor.cxx:1469 #11 0x00000008015ab374 in SfxObjectShell::PreDoSaveAs_Impl(String const&, String const&, SfxItemSet*) (this=0x80a3f3ae0, rFileName=..., aFilterName=..., pParams=0x80e6b7c60) at source/doc/objstor.cxx:2995 #12 0x00000008015aa70d in SfxObjectShell::CommonSaveAs_Impl(INetURLObject const&, String const&, SfxItemSet*) (this=0x80a3f3ae0, aURL=..., aFilterName=..., aParams=0x80e6b74f0) at source/doc/objstor.cxx:2846 #13 0x000000080159227c in SfxObjectShell::APISaveAs_Impl(String const&, SfxItemSet*) (this=0x80a3f3ae0, aFileName=..., aParams=0x80e6b74f0) at source/doc/objserv.cxx:338 #14 0x00000008015f92a8 in SfxBaseModel::impl_store(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, unsigned char) (this=0x80a3f1840, sURL=..., seqArguments=..., bSaveTo=1 '\001') at source/doc/sfxbasemodel.cxx:2923
2919 m_pData->m_xDocumentProperties = xNewDocProps; (gdb) print xNewDocProps->getEditingCycles() $2 = 10 (gdb) n 2920 } (gdb) print m_pData->m_xDocumentProperties->getEditingCycles() $3 = 10 (gdb) n 2921 } (gdb) print m_pData->m_xDocumentProperties->getEditingCycles() $4 = 10 (gdb) n 2923 sal_Bool bRet = m_pData->m_pObjectShell->APISaveAs_Impl( sURL, aParams ); editing cycles remains 10 throughout frame #14 SfxBaseModel::impl_store() in source/doc/sfxbasemodel.cxx, but within line 2923, as the functions from above are called, by frame #0, editing cycles has returned to 1. Somewhere in the 13 stack frames between, the editing cycles values changes. But where?
The value went bad by frame #7: Thread 10 hit Breakpoint 1, sd::DrawDocShell::SaveAs (this=0x80a3f3ae0, rMedium=...) at source/ui/docshell/docshel4.cxx:606 606 bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Export(); (gdb) print getDocProperties()->getEditingCycles() $1 = 1
Frame #10 is still good: Thread 10 hit Breakpoint 1, SfxObjectShell::SaveTo_Impl (this=0x80a3f3ae0, rMedium=..., pSet=0x0) at source/doc/objstor.cxx:1469 1469 bOk = SaveAsOwnFormat( rMedium ); (gdb) print getDocProperties()->getEditingCycles() $1 = 10 Frame #9 is good: Thread 10 hit Breakpoint 2, sd::DrawDocShell::SaveAsOwnFormat (this=0x80a3f3ae0, rMedium=...) at source/ui/docshell/docshel4.cxx:1211 1211 return SfxObjectShell::SaveAsOwnFormat(rMedium); (gdb) print getDocProperties()->getEditingCycles() $2 = 10 Frame #8 is good: Thread 10 hit Breakpoint 3, SfxObjectShell::SaveAsOwnFormat (this=0x80a3f3ae0, rMedium=...) at source/doc/objstor.cxx:3270 3270 return SaveAs( rMedium ); (gdb) print getDocProperties()->getEditingCycles() $3 = 10 Only frame #7 is bad: Thread 10 hit Breakpoint 4, sd::DrawDocShell::SaveAs (this=0x80a3f3ae0, rMedium=...) at source/ui/docshell/docshel4.cxx:606 606 bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Export(); (gdb) print getDocProperties()->getEditingCycles() $4 = 1 So the bug is somewhere within the frame #7 function, sd::DrawDocShell::SaveAs() in source/ui/docshell/docshel4.cxx
This line in sd::DrawDocShell::SaveAs() in source/ui/docshell/docshel4.cxx causes editing cycles to change to 1: 605 UpdateDocInfoForSave(); Stepping into it, it breaks after running line 197: 193 // clear user data if recommend (see 'Tools - Options - Open/StarOffice - Security') 194 if ( SvtSecurityOptions().IsOptionSet( 195 SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO ) ) 196 { 197 xDocProps->resetUserData( ::rtl::OUString() ); 198 } Disabling "Remove personal information on saving" under Tools - Options - Security - Options gets the editing cycles to get written successfully. Thus it's not a bug, but a feature. However the unit test has a bug then, as it expects editing cycles to be written. The unit test should be patched to disable that security setting during the test.
Found out how to disable that security setting. Also, in a prior commit, fixed a major bug that was breaking registry modifications in all tests. commit ce8ed6d52e206eeb0bf9eb7547f3b52546514d5e (HEAD -> trunk, origin/trunk, origin/HEAD) Date: Fri Jul 31 04:45:12 2020 +0200 Add the registry modification that will disable clearing user personal info on saving, so that saving and reloading fields like revision number can be tested. Closes #i128398# - autotest fvt.uno.sd.file.CheckFileProperties loses some DocumentProperties when saving Patch by: me