/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void WmfTest::testEOFWmf()
{ // tdf#155887 Test META_EOF with size different than 3 // It should be properly displayed as MS Office do
SvFileStream aFileStream(getFullUrl(u"EOF.wmf"), StreamMode::READ);
GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile);
// These values come from changes done in tdf#88163
assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "x", u"16813");
assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "y", u"1004");
// Fails without the fix // With fix: 3272, without fix: ~ 8000 auto x = getXPath(pDoc, "/metafile/push[2]/font[1]", "height");
CPPUNIT_ASSERT_EQUAL(sal_Int32(3272), x.toInt32());
// Fails without the fix: Expected: 7359, Actual: 7336
assertXPath(pDoc, "/metafile/push[2]/textarray[1]", "x", u"7359"); // Fails without the fix: Expected: 4118, Actual: 4104
assertXPath(pDoc, "/metafile/push[2]/textarray[1]", "y", u"4118");
// Fails without the fix: Expected: 5989, Actual: 5971
assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "x", u"5989"); // Fails without the fix: Expected: 16264, Actual: 16208
assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "y", u"16264");
// Fails without the fix: Expected: 20769, Actual: 20705
assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "x", u"20769"); // Fails without the fix: Expected: 4077, Actual: 4062
assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "y", u"4077");
}
// The fix does not affect the font size auto x = getXPath(pDoc, "/metafile/push[2]/font[1]", "height");
CPPUNIT_ASSERT_EQUAL(sal_Int32(313), x.toInt32());
// Fails without the fix: Expected: 1900, Actual: 19818
assertXPath(pDoc, "/metafile", "height", u"1900");
// Fails without the fix: Expected: 704, Actual: 7336
assertXPath(pDoc, "/metafile/push[2]/textarray[1]", "x", u"704"); // Fails without the fix: Expected: 394, Actual: 4110
assertXPath(pDoc, "/metafile/push[2]/textarray[1]", "y", u"394");
// Fails without the fix: Expected: 573, Actual: 5971
assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "x", u"573"); // Fails without the fix: Expected: 1556, Actual: 16230
assertXPath(pDoc, "/metafile/push[2]/textarray[2]", "y", u"1556");
// Fails without the fix: Expected: 1987, Actual: 20706
assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "x", u"1987"); // Fails without the fix: Expected: 390, Actual: 4068
assertXPath(pDoc, "/metafile/push[2]/textarray[3]", "y", u"390");
}
// World transform should not affect font size. Rotating text for 90 degrees // should not exchange font width and height.
assertXPath(pDoc, "/metafile/font[4]", "color", u"#000000");
assertXPath(pDoc, "/metafile/font[4]", "width", u"0");
assertXPath(pDoc, "/metafile/font[4]", "height", u"530");
assertXPath(pDoc, "/metafile/font[4]", "orientation", u"900");
assertXPath(pDoc, "/metafile/font[4]", "weight", u"normal");
}
void WmfTest::testBigPPI()
{ // Test that PPI is reduced from 2540 to 96 (width from META_SETWINDOWEXT) to make the graphic // bigger
SvFileStream aFileStream(getFullUrl(u"TestBigPPI.wmf"), StreamMode::READ);
GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile);
// If the PPI was not reduced the width and height would be <100 which is too small // Related: tdf#150888
assertXPath(pDoc, "/metafile", "width", u"2540");
assertXPath(pDoc, "/metafile", "height", u"2143");
}
// The x position of the second text must take into account // the previous text's last Dx (previously was ~300) auto x = getXPath(pDoc, "/metafile/push[2]/textarray[2]", "x");
CPPUNIT_ASSERT_GREATER(sal_Int32(2700), x.toInt32());
}
// The x position of the second text must take into account // the previous text's last Dx (previously was ~300) auto x = getXPath(pDoc, "/metafile/push[2]/textarray[2]", "x");
CPPUNIT_ASSERT_GREATER(sal_Int32(2700), x.toInt32());
}
// The y position of following text // must be smaller than that of previous auto y1 = getXPath(pDoc, "/metafile/push[2]/textarray[1]", "y"); auto y2 = getXPath(pDoc, "/metafile/push[2]/textarray[2]", "y"); auto y3 = getXPath(pDoc, "/metafile/push[2]/textarray[3]", "y");
CPPUNIT_ASSERT(y2.toInt32() < y1.toInt32());
CPPUNIT_ASSERT(y3.toInt32() < y2.toInt32());
}
// The y position of following text // must be smaller than that of previous auto y1 = getXPath(pDoc, "/metafile/push[2]/textarray[1]", "y"); auto y2 = getXPath(pDoc, "/metafile/push[2]/textarray[2]", "y"); auto y3 = getXPath(pDoc, "/metafile/push[2]/textarray[3]", "y");
CPPUNIT_ASSERT(y2.toInt32() < y1.toInt32());
CPPUNIT_ASSERT(y3.toInt32() < y2.toInt32());
}
// Without the fix in place, this test would have failed with // - Expected: 1 // - Actual : 0 // - In <>, XPath '/metafile/push[2]/fillcolor[2]' number of nodes is incorrect
assertXPath(pDoc, "/metafile/push[2]/fillcolor[2]", "color", u"#000000");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.