[Libreoffice-commits] core.git: Branch 'feature/emfplusprimitiveparser' - emfio/source vcl/CppunitTest_vcl_filters_test.mk vcl/qa
Armin Le Grand
Armin.Le.Grand at cib.de
Mon Jun 26 08:11:52 UTC 2017
emfio/source/emfuno/xemfparser.cxx | 92 +++++++++++++-------------
vcl/CppunitTest_vcl_filters_test.mk | 1
vcl/qa/cppunit/graphicfilter/filters-test.cxx | 25 ++++++-
3 files changed, 74 insertions(+), 44 deletions(-)
New commits:
commit 08e26c35f2e118a1bb65901620b4faded3c05fa6
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date: Mon Jun 26 10:08:00 2017 +0200
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
Change-Id: Iea2b835408e919a8456e8f178cbfc782885ffebb
diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx
index ff4dcccb6589..5e14badcf654 100644
--- a/emfio/source/emfuno/xemfparser.cxx
+++ b/emfio/source/emfuno/xemfparser.cxx
@@ -146,52 +146,58 @@ namespace emfio
}
pStream->SetEndian(nOrigNumberFormat);
- Size aSize(aMtf.GetPrefSize());
- if (aMtf.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel)
- {
- aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapUnit::Map100thMM);
- }
- else
+ // Need to chec 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
+ const ErrCode aErrCode(pStream->GetError());
+
+ if (!aErrCode)
{
- 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
{
diff --git a/vcl/CppunitTest_vcl_filters_test.mk b/vcl/CppunitTest_vcl_filters_test.mk
index 7137ee13b96f..ca3c297ad111 100644
--- a/vcl/CppunitTest_vcl_filters_test.mk
+++ b/vcl/CppunitTest_vcl_filters_test.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_CppunitTest_use_components,vcl_filters_test,\
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
uui/util/uui \
+ emfio/emfio \
))
$(eval $(call gb_CppunitTest_use_configuration,vcl_filters_test))
diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
index 0b28c706fd84..d6a32f2875d5 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
@@ -57,7 +57,30 @@ bool VclFiltersTest::load(const OUString &,
{
SvFileStream aFileStream(rURL, StreamMode::READ);
Graphic aGraphic;
- return mGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream) == ERRCODE_NONE;
+ bool bRetval(ERRCODE_NONE == mGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream));
+
+ if (!bRetval)
+ {
+ // if error occurred, we are done
+ return bRetval;
+ }
+
+ // if not and we have an embedded Vector Graphic Data, trigger it's interpretation
+ // to check for error. Graphic with VectorGraphicData (Svg/Emf/Wmf) load without error
+ // as long as one of the three types gets detected. Thus, cycles like load/save in
+ // other format will work (what may be wanted). For the test framework it was indirectly
+ // intended to trigger an error when load in the sense of deep data interpretation fails,
+ // so we need to trigger this here
+ if (aGraphic.getVectorGraphicData().get())
+ {
+ if (aGraphic.getVectorGraphicData()->getRange().isEmpty())
+ {
+ // invalid file or file with no content
+ return false;
+ }
+ }
+
+ return true;
}
void VclFiltersTest::testScaling()
More information about the Libreoffice-commits
mailing list