Kaydet (Commit) ebc61e11 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst bbf0a6cf
{\rtf1
{\*\shppict
{\pict\picw1\pich2\jpegblip
89504e470d0a1a0a0000000d4948445200000010000000100802000000909168360000015049444154789c9592c14a02511486bf99714ccb322d7521140541cb
6a11448b164150fb8a363d41f4083d40cba0655044d0a637a837682fd1a6a2488b10b23475bcb77b671c491dc1cee23077e67cf7fcff39139252f29f08b59e3e
1dae8b4c45998ff501a82e070f5cbd3366733acb5c6fa609fc0872651236df0deeca7d002a6cc33d1b941a146ab49ca937e37610e0c590c5c92b67f926a07243
b293613f8b1108a8a84aadb01575c9799edd0c895010a0ae71048e77b99b6a92e53861a387a48a6033c5d208c297a43ca8a3697601d217b010632dd9a9f34be0
9968021698bea4c76ab72f5dd0d6216c3211e1bec2a0c5e59bce9303baa770c7bd38aca7d729692bcd4d512b53bb3b7cc2f45dd604ab098e67b499366025ce5e
96a317fd2162e2d76bbbb725bdcd80b12a603aca4581e7aade97e14ec2916ca719ed96e4c54692f5241f755de7019641eacfaff10b469261dc6a800dd30000000049454e44ae426082
}
}
}
...@@ -122,6 +122,7 @@ public: ...@@ -122,6 +122,7 @@ public:
void testLeftmarginDefault(); void testLeftmarginDefault();
void testDppolyline(); void testDppolyline();
void testFdo56512(); void testFdo56512();
void testFdo52989();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -195,6 +196,7 @@ void Test::run() ...@@ -195,6 +196,7 @@ void Test::run()
{"leftmargin-default.rtf", &Test::testLeftmarginDefault}, {"leftmargin-default.rtf", &Test::testLeftmarginDefault},
{"dppolyline.rtf", &Test::testDppolyline}, {"dppolyline.rtf", &Test::testDppolyline},
{"fdo56512.rtf", &Test::testFdo56512}, {"fdo56512.rtf", &Test::testFdo56512},
{"fdo52989.rtf", &Test::testFdo52989},
}; };
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{ {
...@@ -895,6 +897,15 @@ void Test::testFdo56512() ...@@ -895,6 +897,15 @@ void Test::testFdo56512()
CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); 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_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -647,9 +647,9 @@ int RTFDocumentImpl::resolvePict(bool bInline) ...@@ -647,9 +647,9 @@ int RTFDocumentImpl::resolvePict(bool bInline)
pExtHeader = 0; pExtHeader = 0;
OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream, pExtHeader); 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. // provided by picw and pich.
OString aURLBS(OUStringToOString(aGraphicUrl, RTL_TEXTENCODING_UTF8)); OString aURLBS(OUStringToOString(aGraphicUrl, RTL_TEXTENCODING_UTF8));
const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; const char aURLBegin[] = "vnd.sun.star.GraphicObject:";
...@@ -2261,6 +2261,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) ...@@ -2261,6 +2261,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_PNGBLIP: case RTF_PNGBLIP:
m_aStates.top().aPicture.nStyle = BMPSTYLE_PNG; m_aStates.top().aPicture.nStyle = BMPSTYLE_PNG;
break; 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_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_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; case RTF_POSYC: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center); break;
......
...@@ -222,7 +222,8 @@ namespace writerfilter { ...@@ -222,7 +222,8 @@ namespace writerfilter {
enum RTFBmpStyles enum RTFBmpStyles
{ {
BMPSTYLE_NONE, BMPSTYLE_NONE,
BMPSTYLE_PNG BMPSTYLE_PNG,
BMPSTYLE_JPEG
}; };
enum RTFFieldStatus enum RTFFieldStatus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment