[Libreoffice-commits] .: sw/qa writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Nov 5 07:51:35 PST 2012


 sw/qa/extras/rtfimport/data/fdo52989.rtf       |   12 ++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   11 +++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    7 +++++--
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    3 ++-
 4 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit ebc61e11cdb02f5cc33aeabead3d191eaf0d23d3
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Nov 5 16:35:59 2012 +0100

    fdo#52989 ignore provided size of JPEG files during RTF import
    
    See commit 66fa759b for rationale, this fix just does the same for JPEG
    files as well.
    
    Change-Id: I6a9ead5f4b4b9c4661cae99501bd7c14a2a79409

diff --git a/sw/qa/extras/rtfimport/data/fdo52989.rtf b/sw/qa/extras/rtfimport/data/fdo52989.rtf
new file mode 100644
index 0000000..513f868
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo52989.rtf
@@ -0,0 +1,12 @@
+{\rtf1
+{\*\shppict
+{\pict\picw1\pich2\jpegblip 
+89504e470d0a1a0a0000000d4948445200000010000000100802000000909168360000015049444154789c9592c14a02511486bf99714ccb322d7521140541cb
+6a11448b164150fb8a363d41f4083d40cba0655044d0a637a837682fd1a6a2488b10b23475bcb77b671c491dc1cee23077e67cf7fcff39139252f29f08b59e3e
+1dae8b4c45998ff501a82e070f5cbd3366733acb5c6fa609fc0872651236df0deeca7d002a6cc33d1b941a146ab49ca937e37610e0c590c5c92b67f926a07243
+b293613f8b1108a8a84aadb01575c9799edd0c895010a0ae71048e77b99b6a92e53861a387a48a6033c5d208c297a43ca8a3697601d217b010632dd9a9f34be0
+9968021698bea4c76ab72f5dd0d6216c3211e1bec2a0c5e59bce9303baa770c7bd38aca7d729692bcd4d512b53bb3b7cc2f45dd604ab098e67b499366025ce5e
+96a317fd2162e2d76bbbb725bdcd80b12a603aca4581e7aade97e14ec2916ca719ed96e4c54692f5241f755de7019641eacfaff10b469261dc6a800dd30000000049454e44ae426082
+}
+}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 4da71c6..b0e3ab3 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -122,6 +122,7 @@ public:
     void testLeftmarginDefault();
     void testDppolyline();
     void testFdo56512();
+    void testFdo52989();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -195,6 +196,7 @@ void Test::run()
         {"leftmargin-default.rtf", &Test::testLeftmarginDefault},
         {"dppolyline.rtf", &Test::testDppolyline},
         {"fdo56512.rtf", &Test::testFdo56512},
+        {"fdo52989.rtf", &Test::testFdo52989},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -895,6 +897,15 @@ void Test::testFdo56512()
     CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
 }
 
+void Test::testFdo52989()
+{
+    // Same as n#192129, but for JPEG files.
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(423), xShape->getSize().Width);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index a5ee8f5..4393aa0 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -647,9 +647,9 @@ int RTFDocumentImpl::resolvePict(bool bInline)
         pExtHeader = 0;
     OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream, pExtHeader);
 
-    if (m_aStates.top().aPicture.nStyle == BMPSTYLE_PNG)
+    if (m_aStates.top().aPicture.nStyle != BMPSTYLE_NONE)
     {
-        // In case of PNG, the real size is known, don't use the values
+        // In case of PNG/JPEG, the real size is known, don't use the values
         // provided by picw and pich.
         OString aURLBS(OUStringToOString(aGraphicUrl, RTL_TEXTENCODING_UTF8));
         const char aURLBegin[] = "vnd.sun.star.GraphicObject:";
@@ -2261,6 +2261,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_PNGBLIP:
             m_aStates.top().aPicture.nStyle = BMPSTYLE_PNG;
             break;
+        case RTF_JPEGBLIP:
+            m_aStates.top().aPicture.nStyle = BMPSTYLE_JPEG;
+            break;
         case RTF_POSYT: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_top); break;
         case RTF_POSYB: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_bottom); break;
         case RTF_POSYC: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center); break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index c0956f7..4942fac 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -222,7 +222,8 @@ namespace writerfilter {
         enum RTFBmpStyles
         {
             BMPSTYLE_NONE,
-            BMPSTYLE_PNG
+            BMPSTYLE_PNG,
+            BMPSTYLE_JPEG
         };
 
         enum RTFFieldStatus


More information about the Libreoffice-commits mailing list