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

tdf#125281 DOC import: fix size of lazy-loaded metafiles

Metafiles may have an external header, so once graphic data is read, we
need to set the size explicitly. Otherwise the width of the EMF image in
the bugdoc will be too small.

Change-Id: I2441eda61278b0f4973db5d9aa14618ccd17c397
Reviewed-on: https://gerrit.libreoffice.org/73064
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst d0d9acc7
...@@ -6610,6 +6610,11 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool ...@@ -6610,6 +6610,11 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool
// size to the size of this record. // size to the size of this record.
sal_uInt64 maxSize = pGrStream == &rBLIPStream ? nLength : 0; sal_uInt64 maxSize = pGrStream == &rBLIPStream ? nLength : 0;
Graphic aGraphic = rGF.ImportUnloadedGraphic(*pGrStream, maxSize); Graphic aGraphic = rGF.ImportUnloadedGraphic(*pGrStream, maxSize);
// Size available in metafile header, set that here.
if (aMtfSize100.getWidth() && aMtfSize100.getHeight())
aGraphic.SetPrefSize(aMtfSize100);
if (!aGraphic.IsNone()) if (!aGraphic.IsNone())
{ {
rData = aGraphic; rData = aGraphic;
......
This diff was suppressed by a .gitattributes entry.
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/graphic/XGraphic.hpp>
#include <viscrs.hxx> #include <viscrs.hxx>
#include <wrtsh.hxx> #include <wrtsh.hxx>
#include <ndgrf.hxx>
#include <editeng/boxitem.hxx> #include <editeng/boxitem.hxx>
#include <editeng/lrspitem.hxx> #include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx> #include <editeng/ulspitem.hxx>
...@@ -204,6 +205,22 @@ DECLARE_WW8IMPORT_TEST(testTdf121734, "tdf121734.doc") ...@@ -204,6 +205,22 @@ DECLARE_WW8IMPORT_TEST(testTdf121734, "tdf121734.doc")
} }
} }
DECLARE_WW8IMPORT_TEST(testTdf125281, "tdf125281.doc")
{
// Load a .doc file which has an embedded .emf image.
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
SwNode* pNode = pDoc->GetNodes()[6];
CPPUNIT_ASSERT(pNode->IsGrfNode());
SwGrfNode* pGrfNode = pNode->GetGrfNode();
const Graphic& rGraphic = pGrfNode->GetGrf();
// Without the accompanying fix in place, this test would have failed, as pref size was 0 till
// an actual Paint() was performed (and even then, it was wrong).
long nExpected = 25664;
CPPUNIT_ASSERT_EQUAL(nExpected, rGraphic.GetPrefSize().getWidth());
}
DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc") DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc")
{ {
// This is for header text in case we use a hack for fixed-height headers // This is for header text in case we use a hack for fixed-height headers
......
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