tdf#116214 Allow for scientific notation in Custom Properties

To keep compatibility with OOXML format, it should be allowed
to use Scientific Format in Custom Properties.
The solution is backward compatible with standard numbers
(it is still possible to write integer numbers and fractions).

With that fix it is also possible to store very small and very big
numbers in scientific notation.

Change-Id: Ic788a6e3f4f748b905828f3d6c8c40dc7e46ba52
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104569
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit b73151c8f8fd4e67dc5674ebb6538783bdfb91df)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104842
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 0d1fac1..0d09643 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1408,15 +1408,16 @@ bool CustomPropertiesWindow::IsLineValid( CustomPropertyLine* pLine ) const
    if ( sValue.isEmpty() )
        return true;

    sal_uInt32 nIndex = 0xFFFFFFFF;
    sal_uInt32 nIndex = NUMBERFORMAT_ENTRY_NOT_FOUND;
    if ( CUSTOM_TYPE_NUMBER == nType )
        // tdf#116214 Scientific format allows to use also standard numbers
        nIndex = const_cast< SvNumberFormatter& >(
            m_aNumberFormatter ).GetFormatIndex( NF_NUMBER_SYSTEM );
            m_aNumberFormatter ).GetFormatIndex( NF_SCIENTIFIC_000E00 );
    else if ( CUSTOM_TYPE_DATE == nType )
        nIndex = const_cast< SvNumberFormatter& >(
            m_aNumberFormatter).GetFormatIndex( NF_DATE_SYS_DDMMYYYY );

    if ( nIndex != 0xFFFFFFFF )
    if ( nIndex != NUMBERFORMAT_ENTRY_NOT_FOUND )
    {
        sal_uInt32 nTemp = nIndex;
        double fDummy = 0.0;
diff --git a/sw/qa/extras/ooxmlexport/data/custom-properties.docx b/sw/qa/extras/ooxmlexport/data/custom-properties.docx
index 4d104cb..01db349 100644
--- a/sw/qa/extras/ooxmlexport/data/custom-properties.docx
+++ b/sw/qa/extras/ooxmlexport/data/custom-properties.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 5f160fa..8149a44 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -94,14 +94,14 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testCustomProperties, "custom-properties.doc
    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:Manager", "ffffmenadzer;iiiiisecondmanager");
    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", 8);
    assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property", 9);
    assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[1]",
                "name", "testDateProperty");
    assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[1]/vt:filetime",
@@ -119,22 +119,26 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testCustomProperties, "custom-properties.doc
    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[6]/vt:lpwstr",
                       "testPropertyValue");
                "name", "testScientificNumber");
    assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[6]/vt:r8",
                       "1.23456789E+023");
    assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[7]",
                "name", "testTextProperty");
    assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[7]/vt:lpwstr",
                       "testPropertyValue");
    assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[8]",
                "name", "testYesNoProperty");
    assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[7]/vt:bool",
    assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[8]/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]",
    assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[9]",
                "name", "_MarkAsFinal");
    assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[8]/vt:bool",
    assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[9]/vt:bool",
                       "1");

    // Core file properties - common for all packages (eg. creation date, modify date)
    pXmlDoc = parseExport("docProps/core.xml");
    assertXPathContent(pXmlDoc, "/cp:coreProperties/dc:creator", "Bartosz Kosiorek");
    assertXPathContent(pXmlDoc, "/cp:coreProperties/dc:creator", "Bartosz Kosiorek;secondauthor");
    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");