diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2020-10-15 19:57:45 +0200 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2020-10-22 14:42:27 +0200 |
commit | a87af93ff874a55b81e55b46b63798fde4cefc4f (patch) | |
tree | d2fc3f044c06e522bcb8ee8cdeb5dce532ff7286 /sw | |
parent | cb310560a887ba08ea4234ea6cdd217151ca0728 (diff) |
tdf#103987 Avoid duplication of the Custom Properties during OOXML export
The MS Office is case insensitive for Properties.
As a result properties names: ContentType and contentType
are treated as the same properties.
Additionally some Core and Extended File Properties does not exist
in LibreOffice standard.
To resolve that such properties are stored in LibreOffice Custom File Properties.
For example:
- category
- contentStatus
- contentType
- identifier
- version
Unfortunately if user specify Custom Property which differ only with case,
there will be conflict. To solve that the properties were renamed to be unique:
- OOXMLCorePropertiesCategory
- OOXMLCorePropertiesContentStatus
- OOXMLCorePropertiesContentType
- OOXMLCorePropertiesIdentifier
- OOXMLCorePropertiesVersion
Additionally if internal property have default value, then the value will
not be imported into Custom File Property.
During export to OOXML (eg. docx) The values which are already stored
in Core or Extended File Properties, are not stored
into Custom File Properties to avoid duplication.
Change-Id: Ifc2b88ab74aa41d12ba968fff199062ce8dc96ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104384
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/custom-properties.docx | bin | 12892 -> 13191 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 51 |
2 files changed, 35 insertions, 16 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/custom-properties.docx b/sw/qa/extras/ooxmlexport/data/custom-properties.docx Binary files differindex 33cce91f7ec4..4d104cb26824 100644 --- a/sw/qa/extras/ooxmlexport/data/custom-properties.docx +++ b/sw/qa/extras/ooxmlexport/data/custom-properties.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index a77d41b64094..6906989d645b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -86,42 +86,57 @@ DECLARE_OOXMLEXPORT_TEST(testPageGraphicBackground, "page-graphic-background.odt } -DECLARE_OOXMLEXPORT_TEST(testCustomProperties, "custom-properties.docx") +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testCustomProperties, "custom-properties.docx") { - // tdf#133377 FILESAVE XLSX: Make sure the custom/core/application file properties - // are stored correctly after roundtrip to .docx + // tdf#133377 tdf#103987 FILESAVE XLSX: Make sure the custom/core/application + // file properties are stored correctly after roundtrip to .docx // Extended file properties - specific to Office package, // eg. docx - Number of Pages, pptx - Number of Slides xmlDocUniquePtr pXmlDoc = parseExport("docProps/app.xml"); - if (!pXmlDoc) - return; - assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", "1"); //assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Lines", "1"); assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Pages", "1"); assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Words", "3"); - assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Characters", "21"); - assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:CharactersWithSpaces", "23"); + assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Characters", "22"); + assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:CharactersWithSpaces", "24"); assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Company", "hhhhkompany"); + assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Manager", "ffffmenadzer"); + assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:HyperlinkBase", "gggghiperlink"); + //assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:DocSecurity", "2"); + assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:AppVersion", "15.0000"); // Custom file properties - defined by user xmlDocUniquePtr pCustomXml = parseExport("docProps/custom.xml"); - assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[12]", + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property", 8); + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[1]", "name", "testDateProperty"); - assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[12]/vt:filetime", + assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[1]/vt:filetime", "1982-04-19T10:00:00Z"); - assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[14]", + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[3]", "name", "testNegativeNumberProperty"); - assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[14]/vt:i4", + assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[3]/vt:r8", "-100"); - assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[17]", + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[4]", + "name", "testNumberProperty"); + //assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[4]/vt:i4", + // "256"); + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[5]", + "name", "testRealNumberProperty"); + assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[5]/vt:r8", + "-128.1"); + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[6]", "name", "testTextProperty"); - assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[17]/vt:lpwstr", + assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[6]/vt:lpwstr", "testPropertyValue"); - assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[18]", + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[7]", "name", "testYesNoProperty"); - assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[18]/vt:bool", + assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[7]/vt:bool", + "1"); + // Hidden Custom File Property. With Final set, MS Office notifies recipients that the document is final, and sets the document to read-only. + assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[8]", + "name", "_MarkAsFinal"); + assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[8]/vt:bool", "1"); // Core file properties - common for all packages (eg. creation date, modify date) @@ -130,6 +145,10 @@ DECLARE_OOXMLEXPORT_TEST(testCustomProperties, "custom-properties.docx") assertXPathContent(pXmlDoc, "/cp:coreProperties/dc:description", "cccckomentarzglowny"); assertXPathContent(pXmlDoc, "/cp:coreProperties/cp:lastPrinted", "2020-10-15T07:42:00Z"); assertXPathContent(pXmlDoc, "/cp:coreProperties/dcterms:created", "2020-10-14T16:23:00Z"); + assertXPathContent(pXmlDoc, "/cp:coreProperties/cp:category", "eeeetokategoria"); + assertXPathContent(pXmlDoc, "/cp:coreProperties/cp:version", "xxxxversion"); + assertXPathContent(pXmlDoc, "/cp:coreProperties/cp:contentStatus", "ddddstatusnieznany"); + assertXPathContent(pXmlDoc, "/cp:coreProperties/dc:identifier", "zzzzidentifier"); } DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx") |