[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Feb 6 22:54:58 UTC 2017


 sw/qa/extras/rtfexport/data/custom-doc-props.rtf |    3 ++
 sw/qa/extras/rtfexport/rtfexport.cxx             |    2 +
 sw/source/filter/ww8/rtfexport.cxx               |   25 ++++++++++++++++-------
 sw/source/filter/ww8/rtfexport.hxx               |    2 +
 writerfilter/source/rtftok/rtfdispatchvalue.cxx  |    3 ++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx   |    2 +
 6 files changed, 30 insertions(+), 7 deletions(-)

New commits:
commit 6a537b3c44e79a389a8a8b7c10e53579c7ecf389
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Dec 8 12:19:27 2016 +0100

    tdf#104082 RTF filter: handle user-defined document properties of type number
    
    Previously only strings were handled, which resulted in not being able
    to open the bugdoc.
    
    (cherry picked from commit fc8c4606e0834cd2128a228c2c95fc7c8f9eb7b1)
    
    Change-Id: I2452cbabf48bfaa9f1a3044be4b8cbe4aa9dd0d9
    Reviewed-on: https://gerrit.libreoffice.org/33952
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf
index b36d864..3e6eee8 100644
--- a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf
+++ b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf
@@ -6,5 +6,8 @@
 {\propname urn:bails:IntellectualProperty:Authorization:StopValidity}
 \proptype30
 {\staticval None}
+{\propname n}
+\proptype3
+{\staticval 42}
 }
 }
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 1c827db..18a2a0e 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1008,6 +1008,8 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
     uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocumentProperties->getUserDefinedProperties();
     CPPUNIT_ASSERT_EQUAL(OUString("2016-03-08T10:55:18,531376147"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StartValidity"));
     CPPUNIT_ASSERT_EQUAL(OUString("None"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StopValidity"));
+    // Test roundtrip of numbers. This failed as getProperty() did not find "n".
+    CPPUNIT_ASSERT_EQUAL(42.0, getProperty<double>(xUserDefinedProperties, "n"));
 }
 
 DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf")
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index bf5c61c..edf7281 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -469,6 +469,13 @@ void RtfExport::WriteInfo()
     Strm().WriteChar('}');
 }
 
+void RtfExport::WriteUserPropValue(const OUString& rValue)
+{
+    Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " ");
+    Strm().WriteCharPtr(msfilter::rtfutil::OutString(rValue, m_eDefaultEncoding).getStr());
+    Strm().WriteChar('}');
+}
+
 void RtfExport::WriteUserProps()
 {
     Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_USERPROPS);
@@ -507,18 +514,22 @@ void RtfExport::WriteUserProps()
                 Strm().WriteCharPtr(msfilter::rtfutil::OutString(rProperty.Name, m_eDefaultEncoding).getStr());
                 Strm().WriteChar('}');
 
-                // Property value type.
+                // Property value.
                 OUString aValue;
-                if (xPropertySet->getPropertyValue(rProperty.Name) >>= aValue)
+                double fValue;
+                uno::Any aAny = xPropertySet->getPropertyValue(rProperty.Name);
+                if (aAny >>= aValue)
                 {
                     Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE);
                     OutULong(30);
+                    WriteUserPropValue(aValue);
+                }
+                else if (aAny >>= fValue)
+                {
+                    Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE);
+                    OutULong(3);
+                    WriteUserPropValue(OUString::number(fValue));
                 }
-
-                // Property value.
-                Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " ");
-                Strm().WriteCharPtr(msfilter::rtfutil::OutString(aValue, m_eDefaultEncoding).getStr());
-                Strm().WriteChar('}');
             }
         }
 
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index 81d18c1..80b4e35 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -204,6 +204,8 @@ private:
     void WriteFootnoteSettings();
     void WriteMainText();
     void WriteInfo();
+    /// Writes a single user property value.
+    void WriteUserPropValue(const OUString& rValue);
     /// Writes the userprops group: user defined document properties.
     void WriteUserProps();
     /// Writes the writer-specific \pgdsctbl group.
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 9de22b7..1c0ec1b 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1391,6 +1391,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     {
         switch (nParam)
         {
+        case 3:
+            m_aStates.top().aPropType = cppu::UnoType<sal_Int32>::get();
+            break;
         case 30:
             m_aStates.top().aPropType = cppu::UnoType<OUString>::get();
             break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index ddede57..2264493 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2687,6 +2687,8 @@ RTFError RTFDocumentImpl::popState()
             uno::Any aAny;
             if (m_aStates.top().aPropType == cppu::UnoType<OUString>::get())
                 aAny = uno::makeAny(aStaticVal);
+            else if (m_aStates.top().aPropType == cppu::UnoType<sal_Int32>::get())
+                aAny = uno::makeAny(aStaticVal.toInt32());
 
             xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny);
         }


More information about the Libreoffice-commits mailing list