diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-06-26 10:08:00 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-07-15 11:01:31 +0200 |
commit | a2e25af0ec427d9c86228ecec349ea2d303abbe1 (patch) | |
tree | 426d32afeb10c516899d96e46c390bdd3b8c3b5c /emfio | |
parent | 208e66185b634ebc131121158f93f4f3ae4bd18e (diff) |
emfplus: corrections for UnitTest in vcl
The CppunitTest_vcl_filters_test was not working due
to a wmf file now being loadable. This leaded to better
check errors on stream and react on it in test code.
Hrad to find since that test - for whatever reason - is
not executed on win. Also need to check result of
EmfReader. Added emfio to test's module list
Change-Id: Iea2b835408e919a8456e8f178cbfc782885ffebb
Diffstat (limited to 'emfio')
-rw-r--r-- | emfio/qa/cppunit/emf/EmfImportTest.cxx | 2 | ||||
-rw-r--r-- | emfio/source/emfuno/xemfparser.cxx | 99 |
2 files changed, 56 insertions, 45 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index ccef93ce673f..63b6eb51c2d7 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -83,7 +83,7 @@ void Test::checkRectPrimitive(Primitive2DSequence& rPrimitive) void Test::testWorking() { - Primitive2DSequence aSequenceRect = parseEmf("/emfio/qa/cppunit/data/fdo79679-2.emf"); + Primitive2DSequence aSequenceRect = parseEmf("/emfio/qa/cppunit/emf/data/fdo79679-2.emf"); CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRect.getLength()); checkRectPrimitive(aSequenceRect); } diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx index ff4dcccb6589..32a2bc1a86ef 100644 --- a/emfio/source/emfuno/xemfparser.cxx +++ b/emfio/source/emfuno/xemfparser.cxx @@ -136,62 +136,73 @@ namespace emfio pStream->ReadUInt32(nMetaType); pStream->Seek(nOrgPos); + bool bReadError(false); + if (nMetaType == 0x464d4520) { - emfio::EmfReader(*pStream, aMtf).ReadEnhWMF(); + // read and get possible failure/error, ReadEnhWMF returns success + bReadError = !emfio::EmfReader(*pStream, aMtf).ReadEnhWMF(); } else { emfio::WmfReader(*pStream, aMtf, bExternalHeaderUsed ? &aExternalHeader : nullptr).ReadWMF(); + + // Need to check for ErrCode at stream to not lose former work. + // This may contain important information and will behave the + // same as before. When we have an error, do not create content + ErrCode aErrCode(pStream->GetError()); + + bReadError = aErrCode.IsError(); } pStream->SetEndian(nOrigNumberFormat); - Size aSize(aMtf.GetPrefSize()); - if (aMtf.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel) - { - aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapUnit::Map100thMM); - } - else + if (!bReadError) { - aSize = OutputDevice::LogicToLogic(aSize, aMtf.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)); + Size aSize(aMtf.GetPrefSize()); + + if (aMtf.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel) + { + aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapUnit::Map100thMM); + } + else + { + aSize = OutputDevice::LogicToLogic(aSize, aMtf.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)); + } + + // use size + const basegfx::B2DHomMatrix aMetafileTransform( + basegfx::tools::createScaleB2DHomMatrix( + aSize.Width(), + aSize.Height())); + + // ...and create a single MetafilePrimitive2D containing the Metafile. + // CAUTION: Currently, ReadWindowMetafile uses the local VectorGraphicData + // and a MetafileAccessor hook at the MetafilePrimitive2D inside of + // ImpGraphic::ImplGetGDIMetaFile to get the Metafile. Thus, the first + // and only primitive in this case *has to be* a MetafilePrimitive2D. + aRetval.push_back( + new drawinglayer::primitive2d::MetafilePrimitive2D( + aMetafileTransform, + aMtf)); + + // // force to use decomposition directly to get rid of the metafile + // const css::uno::Sequence< css::beans::PropertyValue > aViewParameters; + // drawinglayer::primitive2d::MetafilePrimitive2D aMetafilePrimitive2D( + // aMetafileTransform, + // aMtf); + // aRetval.append(aMetafilePrimitive2D.getDecomposition(aViewParameters)); + + // if (aRetval.empty()) + // { + // // for test, just create some graphic data that will get visualized + // const basegfx::B2DRange aRange(1000, 1000, 5000, 5000); + // const basegfx::BColor aColor(1.0, 0.0, 0.0); + // const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); + // + // aRetval.push_back(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), aColor)); + // } } - - // use size - const basegfx::B2DHomMatrix aMetafileTransform( - basegfx::tools::createScaleB2DHomMatrix( - aSize.Width(), - aSize.Height())); - - // ...and create a single MetafilePrimitive2D containing the Metafile. - // CAUTION: Currently, ReadWindowMetafile uses the local VectorGraphicData - // and a MetafileAccessor hook at the MetafilePrimitive2D inside of - // ImpGraphic::ImplGetGDIMetaFile to get the Metafile. Thus, the first - // and only primitive in this case *has to be* a MetafilePrimitive2D. - aRetval.push_back( - new drawinglayer::primitive2d::MetafilePrimitive2D( - aMetafileTransform, - aMtf)); - - // // force to use decomposition directly to get rid of the metafile - // const css::uno::Sequence< css::beans::PropertyValue > aViewParameters; - // drawinglayer::primitive2d::MetafilePrimitive2D aMetafilePrimitive2D( - // aMetafileTransform, - // aMtf); - // aRetval.append(aMetafilePrimitive2D.getDecomposition(aViewParameters)); - - // if (aRetval.empty()) - // { - // // for test, just create some graphic data that will get visualized - // const basegfx::B2DRange aRange(1000, 1000, 5000, 5000); - // const basegfx::BColor aColor(1.0, 0.0, 0.0); - // const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); - // - // aRetval.push_back(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), aColor)); - // } - - - } else { |