diff options
74 files changed, 1042 insertions, 240 deletions
diff --git a/Repository.mk b/Repository.mk index 611240ff5e1d..b7afbb1e06b7 100644 --- a/Repository.mk +++ b/Repository.mk @@ -406,6 +406,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ storagefd \ $(call gb_Helper_optional,SCRIPTING,stringresource) \ svgio \ + emfio \ svl \ svt \ svx \ diff --git a/RepositoryModule_build.mk b/RepositoryModule_build.mk index 6837393dee9e..5f8cd46e68de 100644 --- a/RepositoryModule_build.mk +++ b/RepositoryModule_build.mk @@ -77,6 +77,7 @@ $(eval $(call gb_Module_add_moduledirs,cross_toolset,\ sfx2 \ sot \ svgio \ + emfio \ svl \ svtools \ svx \ diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk index 51feb0b9125f..58aa6959c6b7 100644 --- a/RepositoryModule_host.mk +++ b/RepositoryModule_host.mk @@ -126,6 +126,7 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\ svl \ svtools \ svgio \ + emfio \ svx \ sw \ swext \ diff --git a/accessibility/inc/pch/precompiled_acc.hxx b/accessibility/inc/pch/precompiled_acc.hxx index bebb30a6b92e..791b194aa1af 100644 --- a/accessibility/inc/pch/precompiled_acc.hxx +++ b/accessibility/inc/pch/precompiled_acc.hxx @@ -144,7 +144,7 @@ #include <vcl/seleng.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/unohelp2.hxx> diff --git a/basctl/inc/pch/precompiled_basctl.hxx b/basctl/inc/pch/precompiled_basctl.hxx index 802637ccf100..393f02def886 100644 --- a/basctl/inc/pch/precompiled_basctl.hxx +++ b/basctl/inc/pch/precompiled_basctl.hxx @@ -168,7 +168,7 @@ #include <vcl/spinfld.hxx> #include <vcl/status.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> diff --git a/bin/update_pch b/bin/update_pch index 7e789c1a1dda..10cac0f9f718 100755 --- a/bin/update_pch +++ b/bin/update_pch @@ -102,6 +102,7 @@ DEFAULTS = \ 'sot.sot' : ( 5, EXCLUDE, EXCLUDE, INCLUDE), # 3.1 'starmath.sm' : ( 5, EXCLUDE, EXCLUDE, INCLUDE), # 10.9 'svgio.svgio' : ( 8, EXCLUDE, EXCLUDE, INCLUDE), # 4.3 + 'emfio.emfio' : ( 8, EXCLUDE, EXCLUDE, INCLUDE), # 4.3 'svl.svl' : ( 6, EXCLUDE, EXCLUDE, EXCLUDE), # 7.6 'svtools.svt' : ( 4, EXCLUDE, INCLUDE, EXCLUDE), # 17.6 'svx.svx' : ( 3, EXCLUDE, EXCLUDE, INCLUDE), # 20.7 diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx b/chart2/inc/pch/precompiled_chartcontroller.hxx index f1ec816dd932..337b33a35b9f 100644 --- a/chart2/inc/pch/precompiled_chartcontroller.hxx +++ b/chart2/inc/pch/precompiled_chartcontroller.hxx @@ -155,7 +155,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/tabctrl.hxx> #include <vcl/tabdlg.hxx> diff --git a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx index d1f4b7ba9cc6..c21498f19420 100644 --- a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx +++ b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx @@ -121,7 +121,7 @@ #include <vcl/scheduler.hxx> #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx index 45f8e87d596c..ab2431181cc1 100644 --- a/cui/inc/pch/precompiled_cui.hxx +++ b/cui/inc/pch/precompiled_cui.hxx @@ -164,7 +164,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> diff --git a/dbaccess/inc/pch/precompiled_dba.hxx b/dbaccess/inc/pch/precompiled_dba.hxx index 157f1eef9530..5e0f6e33eb85 100644 --- a/dbaccess/inc/pch/precompiled_dba.hxx +++ b/dbaccess/inc/pch/precompiled_dba.hxx @@ -129,7 +129,7 @@ #include <vcl/salnativewidgets.hxx> #include <vcl/scheduler.hxx> #include <vcl/scopedbitmapaccess.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclptr.hxx> diff --git a/dbaccess/inc/pch/precompiled_dbmm.hxx b/dbaccess/inc/pch/precompiled_dbmm.hxx index cf33574c33d1..02ec793771e7 100644 --- a/dbaccess/inc/pch/precompiled_dbmm.hxx +++ b/dbaccess/inc/pch/precompiled_dbmm.hxx @@ -125,7 +125,7 @@ #include <vcl/scheduler.hxx> #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/desktop/inc/pch/precompiled_sofficeapp.hxx b/desktop/inc/pch/precompiled_sofficeapp.hxx index 95a52227dd26..f7b322eb66fb 100644 --- a/desktop/inc/pch/precompiled_sofficeapp.hxx +++ b/desktop/inc/pch/precompiled_sofficeapp.hxx @@ -148,7 +148,7 @@ #include <vcl/scheduler.hxx> #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index d0935fcc676e..fc4629b4ee21 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -78,7 +78,7 @@ namespace drawinglayer const GraphicObject& rGraphicObject = getGraphicObject(); Graphic aTransformedGraphic(rGraphicObject.GetGraphic()); - const bool isBitmap(GraphicType::Bitmap == aTransformedGraphic.GetType() && !aTransformedGraphic.getSvgData().get()); + const bool isBitmap(GraphicType::Bitmap == aTransformedGraphic.GetType() && !aTransformedGraphic.getVectorGraphicData().get()); const bool isAdjusted(getGraphicAttr().IsAdjusted()); const bool isDrawMode(GraphicDrawMode::Standard != getGraphicAttr().GetDrawMode()); diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx index 98192700264d..f78b53b101be 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -473,31 +473,31 @@ namespace drawinglayer rGraphic, rTransform); } - else if(rGraphic.getSvgData().get()) + else if(rGraphic.getVectorGraphicData().get()) { - // embedded Svg fill, create embed transform - const basegfx::B2DRange& rSvgRange(rGraphic.getSvgData()->getRange()); + // embedded Vector Graphic Data fill, create embed transform + const basegfx::B2DRange& rSvgRange(rGraphic.getVectorGraphicData()->getRange()); if(basegfx::fTools::more(rSvgRange.getWidth(), 0.0) && basegfx::fTools::more(rSvgRange.getHeight(), 0.0)) { // translate back to origin, scale to unit coordinates - basegfx::B2DHomMatrix aEmbedSvg( + basegfx::B2DHomMatrix aEmbedVectorGraphic( basegfx::tools::createTranslateB2DHomMatrix( -rSvgRange.getMinX(), -rSvgRange.getMinY())); - aEmbedSvg.scale( + aEmbedVectorGraphic.scale( 1.0 / rSvgRange.getWidth(), 1.0 / rSvgRange.getHeight()); // apply created object transformation - aEmbedSvg = rTransform * aEmbedSvg; + aEmbedVectorGraphic = rTransform * aEmbedVectorGraphic; - // add Svg primitives embedded + // add Vector Graphic Data primitives embedded aRetval.resize(1); aRetval[0] = new TransformPrimitive2D( - aEmbedSvg, - rGraphic.getSvgData()->getPrimitive2DSequence()); + aEmbedVectorGraphic, + rGraphic.getVectorGraphicData()->getPrimitive2DSequence()); } } else diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index f5a8745c4c13..5af036d3cced 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -397,13 +397,13 @@ namespace drawinglayer { // content is bitmap(ex) // - // for SVG support, force decomposition when SVG is present. This will lead to use - // the primitive representation of the svg directly. + // for Vector Graphic Data (SVG, EMF+) support, force decomposition when present. This will lead to use + // the primitive representation of the vector data directly. // // when graphic is animated, force decomposition to use the correct graphic, else // fill style will not be animated if(GraphicType::Bitmap == rFillGraphicAttribute.getGraphic().GetType() - && !rFillGraphicAttribute.getGraphic().getSvgData().get() + && !rFillGraphicAttribute.getGraphic().getVectorGraphicData().get() && !rFillGraphicAttribute.getGraphic().IsAnimated()) { // decompose matrix to check for shear, rotate and mirroring diff --git a/emfio/CppunitTest_emfio.mk b/emfio/CppunitTest_emfio.mk new file mode 100644 index 000000000000..8214bc87e794 --- /dev/null +++ b/emfio/CppunitTest_emfio.mk @@ -0,0 +1,67 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,emfio)) + +$(eval $(call gb_CppunitTest_set_componentfile,emfio,emfio/emfio)) + +$(eval $(call gb_CppunitTest_set_include,emfio,\ + $$(INCLUDE) \ + -I$(SRCDIR)/emfio/inc \ +)) + +$(eval $(call gb_CppunitTest_use_externals,emfio,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,emfio)) + +$(eval $(call gb_CppunitTest_use_library_objects,emfio,\ + emfio \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,emfio,\ + basegfx \ + drawinglayer \ + cppu \ + cppuhelper \ + comphelper \ + sal \ + svt \ + test \ + unotest \ + tl \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,emfio,\ + emfio/qa/cppunit/EmfImportTest \ +)) + +$(eval $(call gb_CppunitTest_use_ure,emfio)) +$(eval $(call gb_CppunitTest_use_vcl,emfio)) + +$(eval $(call gb_CppunitTest_use_components,emfio,\ + configmgr/source/configmgr \ + dtrans/util/mcnttype \ + framework/util/fwk \ + i18npool/util/i18npool \ + package/source/xstor/xstor \ + package/util/package2 \ + toolkit/util/tk \ + sfx2/util/sfx \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + unotools/util/utl \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,emfio)) + +# vim: set noet sw=4 ts=4: diff --git a/emfio/Library_emfio.mk b/emfio/Library_emfio.mk new file mode 100644 index 000000000000..c0a2dc2d42ff --- /dev/null +++ b/emfio/Library_emfio.mk @@ -0,0 +1,51 @@ +# +# 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 . +# + +$(eval $(call gb_Library_Library,emfio)) + +$(eval $(call gb_Library_set_componentfile,emfio,emfio/emfio)) + +$(eval $(call gb_Library_set_include,emfio,\ + $$(INCLUDE) \ + -I$(SRCDIR)/emfio/inc \ +)) + +$(eval $(call gb_Library_use_external,emfio,boost_headers)) + +$(eval $(call gb_Library_set_precompiled_header,emfio,$(SRCDIR)/emfio/inc/pch/precompiled_emfio)) + +$(eval $(call gb_Library_use_sdk_api,emfio)) + +$(eval $(call gb_Library_use_libraries,emfio,\ + basegfx \ + drawinglayer \ + cppu \ + cppuhelper \ + sal \ + tl \ + sax \ + vcl \ + svt \ +)) + +$(eval $(call gb_Library_add_exception_objects,emfio,\ + emfio/source/emfuno/emfuno \ + emfio/source/emfuno/xemfparser \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/emfio/Makefile b/emfio/Makefile new file mode 100644 index 000000000000..0997e628485b --- /dev/null +++ b/emfio/Makefile @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/emfio/Module_emfio.mk b/emfio/Module_emfio.mk new file mode 100644 index 000000000000..719bd0180628 --- /dev/null +++ b/emfio/Module_emfio.mk @@ -0,0 +1,29 @@ +# +# 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 . +# + +$(eval $(call gb_Module_Module,emfio)) + +$(eval $(call gb_Module_add_targets,emfio,\ + Library_emfio \ +)) + +$(eval $(call gb_Module_add_check_targets,emfio,\ + CppunitTest_emfio \ +)) + +# vim: set noet ts=4 sw=4: diff --git a/emfio/README b/emfio/README new file mode 100644 index 000000000000..c68aa72ec90b --- /dev/null +++ b/emfio/README @@ -0,0 +1 @@ +It contains emfio/source/emfeader which is used for "Insert->Picture->From File". diff --git a/emfio/emfio.component b/emfio/emfio.component new file mode 100644 index 000000000000..a0ea552950cd --- /dev/null +++ b/emfio/emfio.component @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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 . + --> + +<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" + prefix="emfio" xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="emfio::emfreader::XEmfParser"> + <service name="com.sun.star.graphic.EmfTools"/> + </implementation> +</component> diff --git a/emfio/inc/pch/precompiled_emfio.cxx b/emfio/inc/pch/precompiled_emfio.cxx new file mode 100644 index 000000000000..d87142820e5d --- /dev/null +++ b/emfio/inc/pch/precompiled_emfio.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_emfio.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/emfio/inc/pch/precompiled_emfio.hxx b/emfio/inc/pch/precompiled_emfio.hxx new file mode 100644 index 000000000000..fac038537e53 --- /dev/null +++ b/emfio/inc/pch/precompiled_emfio.hxx @@ -0,0 +1,29 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2017-06-09 17:33:30 using: + bin/update_pch emfio emfio --cutoff=8 --exclude:system --exclude:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./emfio/inc/pch/precompiled_emfio.hxx "make emfio.build" --find-conflicts +*/ + +#include <osl/diagnose.h> +#include <rtl/instance.hxx> +#include <rtl/unload.h> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/emfio/qa/cppunit/EmfImportTest.cxx b/emfio/qa/cppunit/EmfImportTest.cxx new file mode 100644 index 000000000000..f315fc8937d0 --- /dev/null +++ b/emfio/qa/cppunit/EmfImportTest.cxx @@ -0,0 +1,102 @@ +/* -*- 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/. + */ + +#include <sal/config.h> + +#include <test/bootstrapfixture.hxx> +#include <test/primitive2dxmldump.hxx> +#include <test/xmltesttools.hxx> + +#include <comphelper/processfactory.hxx> +#include <comphelper/seqstream.hxx> +#include <comphelper/sequence.hxx> + +#include <com/sun/star/graphic/EmfTools.hpp> +#include <com/sun/star/graphic/Primitive2DTools.hpp> +#include <com/sun/star/graphic/XPrimitive2D.hpp> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> + +#include <memory> + +namespace +{ + +using namespace css::uno; +using namespace css::io; +using namespace css::graphic; +using drawinglayer::primitive2d::Primitive2DSequence; +using drawinglayer::primitive2d::Primitive2DContainer; + +class Test : public test::BootstrapFixture, public XmlTestTools +{ + void checkRectPrimitive(Primitive2DSequence& rPrimitive); + + void testWorking(); + + Primitive2DSequence parseEmf(const char* aSource); + +public: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testWorking); + CPPUNIT_TEST_SUITE_END(); +}; + +Primitive2DSequence Test::parseEmf(const char* aSource) +{ + const Reference<XEmfParser> xEmfParser = EmfTools::create(m_xContext); + + OUString aUrl = m_directories.getURLFromSrc(aSource); + OUString aPath = m_directories.getPathFromSrc(aSource); + + SvFileStream aFileStream(aUrl, StreamMode::READ); + std::size_t nSize = aFileStream.remainingSize(); + std::unique_ptr<sal_Int8[]> pBuffer(new sal_Int8[nSize + 1]); + aFileStream.ReadBytes(pBuffer.get(), nSize); + pBuffer[nSize] = 0; + + Sequence<sal_Int8> aData(pBuffer.get(), nSize + 1); + Reference<XInputStream> aInputStream(new comphelper::SequenceInputStream(aData)); + + return xEmfParser->getDecomposition(aInputStream, aPath); +} + +void Test::checkRectPrimitive(Primitive2DSequence& rPrimitive) +{ + Primitive2dXmlDump dumper; + xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(rPrimitive)); + + CPPUNIT_ASSERT (pDocument); + + // emfio: add examples + // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00"); // rect background color + // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "height", "100"); // rect background height + // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "width", "100"); // rect background width + // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "minx", "10"); + // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "miny", "10"); + // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "maxx", "110"); + // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "maxy", "110"); + // assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#ff0000"); // rect stroke color + // assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "3"); // rect stroke width +} + +void Test::testWorking() +{ + Primitive2DSequence aSequenceRect = parseEmf("/emfio/qa/cppunit/data/fdo79679-2.emf"); + CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRect.getLength()); + checkRectPrimitive(aSequenceRect); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/emfio/qa/cppunit/data/fdo79679-2.emf b/emfio/qa/cppunit/data/fdo79679-2.emf Binary files differnew file mode 100644 index 000000000000..0962dc122152 --- /dev/null +++ b/emfio/qa/cppunit/data/fdo79679-2.emf diff --git a/emfio/source/emfuno/emfuno.cxx b/emfio/source/emfuno/emfuno.cxx new file mode 100644 index 000000000000..b027c5fe3cc2 --- /dev/null +++ b/emfio/source/emfuno/emfuno.cxx @@ -0,0 +1,46 @@ +/* -*- 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 . + */ + +#include <sal/config.h> + +#include <cppuhelper/factory.hxx> +#include <cppuhelper/implementationentry.hxx> +#include <sal/types.h> + +#include "xemfparser.hxx" + +namespace { + +static cppu::ImplementationEntry const services[] = { + { &emfio::emfreader::XEmfParser_createInstance, + &emfio::emfreader::XEmfParser_getImplementationName, + &emfio::emfreader::XEmfParser_getSupportedServiceNames, + &cppu::createSingleComponentFactory, nullptr, 0 }, + { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } }; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL emfio_component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) +{ + return cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, services); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx new file mode 100644 index 000000000000..ce18d4be3a3a --- /dev/null +++ b/emfio/source/emfuno/xemfparser.cxx @@ -0,0 +1,210 @@ +/* -*- 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 . + */ + +#include <sal/config.h> + +#include <com/sun/star/graphic/XEmfParser.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <comphelper/sequence.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> + +//#include <com/sun/star/xml/sax/XParser.hpp> +//#include <com/sun/star/xml/sax/Parser.hpp> +//#include <com/sun/star/xml/sax/InputSource.hpp> +//#include <drawinglayer/geometry/viewinformation2d.hxx> +//#include <svgdocumenthandler.hxx> + +#include "xemfparser.hxx" + +using namespace ::com::sun::star; + +namespace emfio +{ + namespace emfreader + { + class XEmfParser : public ::cppu::WeakAggImplHelper2< graphic::XEmfParser, lang::XServiceInfo > + { + private: + uno::Reference< uno::XComponentContext > context_; + + protected: + public: + explicit XEmfParser( + uno::Reference< uno::XComponentContext > const & context); + XEmfParser(const XEmfParser&) = delete; + XEmfParser& operator=(const XEmfParser&) = delete; + + // XEmfParser + virtual uno::Sequence< uno::Reference< ::graphic::XPrimitive2D > > SAL_CALL getDecomposition( + const uno::Reference< ::io::XInputStream >& xEmfStream, + const OUString& aAbsolutePath) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString&) override; + virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + }; + } // end of namespace emfreader +} // end of namespace emfio + +// uno functions +namespace emfio +{ + namespace emfreader + { + uno::Sequence< OUString > XEmfParser_getSupportedServiceNames() + { + return uno::Sequence< OUString > { "com.sun.star.graphic.EmfTools" }; + } + + OUString XEmfParser_getImplementationName() + { + return OUString( "emfio::emfreader::XEmfParser" ); + } + + uno::Reference< uno::XInterface > SAL_CALL XEmfParser_createInstance(const uno::Reference< uno::XComponentContext >& context) + { + return static_cast< ::cppu::OWeakObject* >(new XEmfParser(context)); + } + } // end of namespace emfreader +} // end of namespace emfio + +namespace emfio +{ + namespace emfreader + { + XEmfParser::XEmfParser( + uno::Reference< uno::XComponentContext > const & context): + context_(context) + { + } + + uno::Sequence< uno::Reference< ::graphic::XPrimitive2D > > XEmfParser::getDecomposition( + const uno::Reference< ::io::XInputStream >& xEmfStream, + const OUString& aAbsolutePath ) + { + drawinglayer::primitive2d::Primitive2DContainer aRetval; + + if (xEmfStream.is()) + { + static bool bTestCode(true); + + if (bTestCode) + { + // for test, just create some graphic data + 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 + { + // new parser here + bool bBla = true; + + + + + // // local document handler + // SvgDocHdl* pSvgDocHdl = new SvgDocHdl(aAbsolutePath); + // uno::Reference< xml::sax::XDocumentHandler > xSvgDocHdl(pSvgDocHdl); + // + // try + // { + // // prepare ParserInputSrouce + // xml::sax::InputSource myInputSource; + // myInputSource.aInputStream = xEmfStream; + // + // // get parser + // uno::Reference< xml::sax::XParser > xParser( + // xml::sax::Parser::create(context_)); + // // fdo#60471 need to enable internal entities because + // // certain ... popular proprietary products write SVG files + // // that use entities to define XML namespaces. + // uno::Reference<lang::XInitialization> const xInit(xParser, + // uno::UNO_QUERY_THROW); + // uno::Sequence<uno::Any> args(1); + // args[0] <<= OUString("DoSmeplease"); + // xInit->initialize(args); + // + // // connect parser and filter + // xParser->setDocumentHandler(xSvgDocHdl); + // + // // finally, parse the stream to a hierarchy of + // // SVGGraphicPrimitive2D which will be embedded to the + // // primitive sequence. Their decompositions will in the + // // end create local low-level primitives, thus SVG will + // // be processable from all our processors + // xParser->parseStream(myInputSource); + // } + // catch(const uno::Exception& e) + // { + // SAL_WARN( "svg", "Parse error! : " << e.Message); + // } + // + // // decompose to primitives + // const SvgNodeVector& rResults = pSvgDocHdl->getSvgDocument().getSvgNodeVector(); + // const sal_uInt32 nCount(rResults.size()); + // + // for(sal_uInt32 a(0); a < nCount; a++) + // { + // SvgNode* pCandidate = rResults[a]; + // + // if(Display_none != pCandidate->getDisplay()) + // { + // pCandidate->decomposeSvgNode(aRetval, false); + // } + // } + } + } + else + { + OSL_ENSURE(false, "Invalid stream (!)"); + } + + return comphelper::containerToSequence(aRetval); + } + + OUString SAL_CALL XEmfParser::getImplementationName() + { + return(XEmfParser_getImplementationName()); + } + + sal_Bool SAL_CALL XEmfParser::supportsService(const OUString& rServiceName) + { + return cppu::supportsService(this, rServiceName); + } + + uno::Sequence< OUString > SAL_CALL XEmfParser::getSupportedServiceNames() + { + return XEmfParser_getSupportedServiceNames(); + } + + } // end of namespace emfreader +} // end of namespace emfio + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/emfio/source/emfuno/xemfparser.hxx b/emfio/source/emfuno/xemfparser.hxx new file mode 100644 index 000000000000..da78322028dc --- /dev/null +++ b/emfio/source/emfuno/xemfparser.hxx @@ -0,0 +1,50 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_EMFIO_SOURCE_EMFUNO_XEMFARSER_HXX +#define INCLUDED_EMFIO_SOURCE_EMFUNO_XEMFARSER_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <sal/types.h> + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + class XInterface; + } +} } } + +namespace emfio { namespace emfreader { + +css::uno::Reference< css::uno::XInterface > SAL_CALL +XEmfParser_createInstance( css::uno::Reference< css::uno::XComponentContext > const &); + +OUString SAL_CALL XEmfParser_getImplementationName(); + +css::uno::Sequence< OUString > SAL_CALL +XEmfParser_getSupportedServiceNames(); + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwe.hxx b/framework/inc/pch/precompiled_fwe.hxx index a87d4036c208..984b6266f5ab 100644 --- a/framework/inc/pch/precompiled_fwe.hxx +++ b/framework/inc/pch/precompiled_fwe.hxx @@ -131,7 +131,7 @@ #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/framework/inc/pch/precompiled_fwi.hxx b/framework/inc/pch/precompiled_fwi.hxx index df8b9eb8fc01..05a4cac9e5c8 100644 --- a/framework/inc/pch/precompiled_fwi.hxx +++ b/framework/inc/pch/precompiled_fwi.hxx @@ -98,7 +98,7 @@ #include <vcl/region.hxx> #include <vcl/scheduler.hxx> #include <vcl/scopedbitmapaccess.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclptr.hxx> diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx index 971763caef8b..5863dbf7d55e 100644 --- a/framework/inc/pch/precompiled_fwk.hxx +++ b/framework/inc/pch/precompiled_fwk.hxx @@ -145,7 +145,7 @@ #include <vcl/settings.hxx> #include <vcl/status.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/toolbox.hxx> diff --git a/framework/inc/pch/precompiled_fwl.hxx b/framework/inc/pch/precompiled_fwl.hxx index 3529522da173..62f2594a632e 100644 --- a/framework/inc/pch/precompiled_fwl.hxx +++ b/framework/inc/pch/precompiled_fwl.hxx @@ -149,7 +149,7 @@ #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index e86673b74899..ecf9eeef927a 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -188,8 +188,8 @@ public: virtual void SetPage(SdrPage* pNewPage) override; virtual void SetModel(SdrModel* pNewModel) override; - bool isEmbeddedSvg() const; - GDIMetaFile getMetafileFromEmbeddedSvg() const; + bool isEmbeddedVectorGraphicData() const; + GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index 8dcf5925f87f..39fd594e878e 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -31,7 +31,7 @@ #include <vcl/gdimtf.hxx> #include <vcl/gfxlink.hxx> #include <com/sun/star/uno/Reference.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <basegfx/vector/b2dsize.hxx> @@ -118,7 +118,7 @@ public: Graphic( Graphic&& rGraphic ); Graphic( const Bitmap& rBmp ); Graphic( const BitmapEx& rBmpEx ); - Graphic( const SvgDataPtr& rSvgDataPtr ); + Graphic( const VectorGraphicDataPtr& rVectorGraphicDataPtr ); Graphic( const Animation& rAnimation ); Graphic( const GDIMetaFile& rMtf ); Graphic( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic ); @@ -219,7 +219,7 @@ public: public: - const SvgDataPtr& getSvgData() const; + const VectorGraphicDataPtr& getVectorGraphicData() const; void setPdfData(const css::uno::Sequence<sal_Int8>& rPdfData); const css::uno::Sequence<sal_Int8>& getPdfData() const; diff --git a/include/vcl/svgdata.hxx b/include/vcl/vectorgraphicdata.hxx index 7ab2d8ce89c8..f46be43489db 100644 --- a/include/vcl/svgdata.hxx +++ b/include/vcl/vectorgraphicdata.hxx @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_VCL_SVGDATA_HXX -#define INCLUDED_VCL_SVGDATA_HXX +#ifndef INCLUDED_VCL_VECTORGRAPHICDATA_HXX +#define INCLUDED_VCL_VECTORGRAPHICDATA_HXX #include <basegfx/range/b2drange.hxx> #include <com/sun/star/graphic/XPrimitive2D.hpp> @@ -27,7 +27,7 @@ #include <deque> -typedef css::uno::Sequence<sal_Int8> SvgDataArray; +typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray; // helper to convert any Primitive2DSequence to a good quality BitmapEx, @@ -39,39 +39,53 @@ BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( const sal_uInt32 nMaximumQuadraticPixels = 500000); -class VCL_DLLPUBLIC SvgData +enum class VectorGraphicDataType +{ + Svg = 0, + Emf = 1, + Wmf = 2 +}; + +class VCL_DLLPUBLIC VectorGraphicData { private: // the file and length - SvgDataArray maSvgDataArray; + VectorGraphicDataArray maVectorGraphicDataArray; // The absolute Path if available - OUString maPath; + OUString maPath; // on demand created content - basegfx::B2DRange maRange; + basegfx::B2DRange maRange; std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > - maSequence; - BitmapEx maReplacement; - size_t mNestedBitmapSize; + maSequence; + BitmapEx maReplacement; + size_t mNestedBitmapSize; + VectorGraphicDataType meVectorGraphicDataType; // on demand creators void ensureReplacement(); void ensureSequenceAndRange(); - SvgData(const SvgData&) = delete; - SvgData& operator=(const SvgData&) = delete; + VectorGraphicData(const VectorGraphicData&) = delete; + VectorGraphicData& operator=(const VectorGraphicData&) = delete; public: - SvgData(const SvgDataArray& rSvgDataArray, const OUString& rPath); - SvgData(const OUString& rPath); + VectorGraphicData( + const VectorGraphicDataArray& rVectorGraphicDataArray, + const OUString& rPath, + VectorGraphicDataType eVectorDataType); // = VectorGraphicDataType::Svg); + VectorGraphicData( + const OUString& rPath, + VectorGraphicDataType eVectorDataType); /// data read - const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; } - sal_uInt32 getSvgDataArrayLength() const { return maSvgDataArray.getLength(); } + const VectorGraphicDataArray& getVectorGraphicDataArray() const { return maVectorGraphicDataArray; } + sal_uInt32 getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray.getLength(); } enum class State { UNPARSED, PARSED }; std::pair<State, size_t> getSizeBytes(); const OUString& getPath() const { return maPath; } + const VectorGraphicDataType& getVectorGraphicDataType() const { return meVectorGraphicDataType; } /// data read and evtl. on demand creation const basegfx::B2DRange& getRange() const; @@ -79,8 +93,8 @@ public: const BitmapEx& getReplacement() const; }; -typedef std::shared_ptr< SvgData > SvgDataPtr; +typedef std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr; -#endif // INCLUDED_VCL_SVGDATA_HXX +#endif // INCLUDED_VCL_VECTORGRAPHICDATA_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index f3e0274777a7..14a80f5e7bd8 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -210,6 +210,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/graphic,\ GraphicProvider \ Primitive2DTools \ SvgTools \ + EmfTools \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/inspection,\ DefaultHelpProvider \ @@ -2705,6 +2706,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/graphic,\ XPrimitive3D \ XPrimitiveFactory2D \ XSvgParser \ + XEmfParser \ )) $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/i18n,\ AmPmValue \ diff --git a/offapi/com/sun/star/graphic/EmfTools.idl b/offapi/com/sun/star/graphic/EmfTools.idl new file mode 100644 index 000000000000..f258214117e6 --- /dev/null +++ b/offapi/com/sun/star/graphic/EmfTools.idl @@ -0,0 +1,39 @@ +/* -*- 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 . + */ + +#ifndef com_sun_star_graphic_EmfTools_idl +#define com_sun_star_graphic_EmfTools_idl + +#include <com/sun/star/graphic/XEmfParser.idl> + +module com { module sun { module star { module graphic +{ + +/** Service that describes the necessary interfaces and properties + to handle emf files. + Parses an WMF/EMF/EMF+ file to a sequence of B2DPrimitives for internal usage + */ + +service EmfTools : XEmfParser; + +} ; } ; } ; } ; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/graphic/XEmfParser.idl b/offapi/com/sun/star/graphic/XEmfParser.idl new file mode 100644 index 000000000000..6c55a8a0b963 --- /dev/null +++ b/offapi/com/sun/star/graphic/XEmfParser.idl @@ -0,0 +1,54 @@ +/* -*- 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 . + */ + +#ifndef __com_sun_star_graphic_XEmfParser_idl__ +#define __com_sun_star_graphic_XEmfParser_idl__ + +#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/io/XInputStream.idl> + +module com { module sun { module star { module graphic { + +interface XPrimitive2D; + +/** XEmfParser interface + + This interface allows to parse an WMF/EMF/EMF+ stream in form of a sequence of bytes + to be parsed into a sequence of XPrimitive2Ds + */ +interface XEmfParser : ::com::sun::star::uno::XInterface +{ + /** Retrieve decomposed list of simpler primitives + + @param xEmfStream + The file containing the WMF/EMF/EMF+ binary data + + @param aAbsolutePath + The path containing the WMF/EMF/EMF+ data + */ + sequence< XPrimitive2D > getDecomposition( + [in] io::XInputStream xEmfStream, + [in] string aAbsolutePath); +}; + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/pch/precompiled_oox.hxx b/oox/inc/pch/precompiled_oox.hxx index fc5b43d7cbc8..d84185b11bfc 100644 --- a/oox/inc/pch/precompiled_oox.hxx +++ b/oox/inc/pch/precompiled_oox.hxx @@ -85,7 +85,7 @@ #include <vcl/gfxlink.hxx> #include <vcl/graph.hxx> #include <vcl/mapmod.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <basegfx/basegfxdllapi.h> #include <basegfx/color/bcolor.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk index 1aef066f698f..31203f553343 100644 --- a/postprocess/Rdb_services.mk +++ b/postprocess/Rdb_services.mk @@ -81,6 +81,7 @@ $(eval $(call gb_Rdb_add_components,services,\ svl/util/svl \ svtools/util/svt \ svgio/svgio \ + emfio/emfio \ svx/util/svx \ svx/util/svxcore \ svx/util/textconversiondlgs \ diff --git a/reportdesign/inc/pch/precompiled_rpt.hxx b/reportdesign/inc/pch/precompiled_rpt.hxx index 9919e30508f5..c596f6e5a543 100644 --- a/reportdesign/inc/pch/precompiled_rpt.hxx +++ b/reportdesign/inc/pch/precompiled_rpt.hxx @@ -148,7 +148,7 @@ #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/reportdesign/inc/pch/precompiled_rptui.hxx b/reportdesign/inc/pch/precompiled_rptui.hxx index e441de4b64aa..bcbaff0a411b 100644 --- a/reportdesign/inc/pch/precompiled_rptui.hxx +++ b/reportdesign/inc/pch/precompiled_rptui.hxx @@ -167,7 +167,7 @@ #include <vcl/spinfld.hxx> #include <vcl/status.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/tabctrl.hxx> #include <vcl/tabdlg.hxx> diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index d0878a1d2be3..a4c1c77d3fe3 100644 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -159,7 +159,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> diff --git a/sc/inc/pch/precompiled_scfilt.hxx b/sc/inc/pch/precompiled_scfilt.hxx index b67942852e14..4430b8f68e95 100644 --- a/sc/inc/pch/precompiled_scfilt.hxx +++ b/sc/inc/pch/precompiled_scfilt.hxx @@ -94,7 +94,7 @@ #include <vcl/mapmod.hxx> #include <vcl/outdev.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/vclptr.hxx> #include <attrib.hxx> #include <basegfx/color/bcolor.hxx> diff --git a/sd/inc/pch/precompiled_sdui.hxx b/sd/inc/pch/precompiled_sdui.hxx index 04156e61e95f..8f4ecbba6edd 100644 --- a/sd/inc/pch/precompiled_sdui.hxx +++ b/sd/inc/pch/precompiled_sdui.hxx @@ -168,7 +168,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/tabctrl.hxx> #include <vcl/tabdlg.hxx> diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index c144cf9ea251..51bcc0a2388c 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -711,9 +711,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(mpDrawView->GetMarkedObjectByIndex(0)); - if(pSdrGrafObj && pSdrGrafObj->isEmbeddedSvg()) + if(pSdrGrafObj && pSdrGrafObj->isEmbeddedVectorGraphicData()) { - aGraphic = Graphic(pSdrGrafObj->GetGraphic().getSvgData()->getReplacement()); + aGraphic = Graphic(pSdrGrafObj->GetGraphic().getVectorGraphicData()->getReplacement()); bDone = true; } } @@ -2362,9 +2362,9 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) { nCount += pGraf->GetGraphic().GetGDIMetaFile().GetActionSize(); } - else if(pGraf->isEmbeddedSvg()) + else if(pGraf->isEmbeddedVectorGraphicData()) { - nCount += pGraf->getMetafileFromEmbeddedSvg().GetActionSize(); + nCount += pGraf->getMetafileFromEmbeddedVectorGraphicData().GetActionSize(); } } diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index d829639e0bae..3feab2fe0b0e 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1387,7 +1387,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) { case GraphicType::Bitmap : bFoundBitmap = true; - if(pSdrGrafObj->isEmbeddedSvg()) + if(pSdrGrafObj->isEmbeddedVectorGraphicData()) { bFoundMetafile = true; } diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 0e6be246b0f8..d634fa8d4d80 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -1015,7 +1015,7 @@ bool View::IsVectorizeAllowed() const if(pObj) { - if(GraphicType::Bitmap == pObj->GetGraphicType() && !pObj->isEmbeddedSvg()) + if(GraphicType::Bitmap == pObj->GetGraphicType() && !pObj->isEmbeddedVectorGraphicData()) { bRet = true; } diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx index 262cae606bad..f56e46145aac 100644 --- a/sfx2/source/appl/appmisc.cxx +++ b/sfx2/source/appl/appmisc.cxx @@ -142,11 +142,11 @@ bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWid OUString uri = "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER + aBaseName + ".svg"; rtl::Bootstrap::expandMacros( uri ); INetURLObject aObj( uri ); - SvgData aSvgData(aObj.PathToFileName()); + VectorGraphicData aVectorGraphicData(aObj.PathToFileName(), VectorGraphicDataType::Svg); // transform into [0,0,width,width*aspect] std dimensions - basegfx::B2DRange aRange(aSvgData.getRange()); + basegfx::B2DRange aRange(aVectorGraphicData.getRange()); const double fAspectRatio( aRange.getHeight() == 0.0 ? 1.0 : aRange.getWidth()/aRange.getHeight()); basegfx::B2DHomMatrix aTransform( @@ -160,7 +160,7 @@ bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWid const drawinglayer::primitive2d::Primitive2DReference xTransformRef( new drawinglayer::primitive2d::TransformPrimitive2D( aTransform, - aSvgData.getPrimitive2DSequence())); + aVectorGraphicData.getPrimitive2DSequence())); // UNO dance to render from drawinglayer diff --git a/slideshow/inc/pch/precompiled_slideshow.hxx b/slideshow/inc/pch/precompiled_slideshow.hxx index c281f02ed9f4..b71f00101ff1 100644 --- a/slideshow/inc/pch/precompiled_slideshow.hxx +++ b/slideshow/inc/pch/precompiled_slideshow.hxx @@ -130,7 +130,7 @@ #include <vcl/scheduler.hxx> #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index f29be571e22f..b60ab093113b 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -288,6 +288,7 @@ calc_constructor_list = [ draw_factory_list = [ ("libsdlo.a", "sd_component_getFactory"), ("libsvgiolo.a", "svgio_component_getFactory"), + ("libemfiolo.a", "emfio_component_getFactory"), ("libsvgfilterlo.a", "svgfilter_component_getFactory"), ("libdeployment.a", "deployment_component_getFactory"), ("libemboleobj.a", "emboleobj_component_getFactory"), diff --git a/solenv/qa/python/gbuildtojson.py b/solenv/qa/python/gbuildtojson.py index 69a4e3a1ae92..8866c52c4e05 100644 --- a/solenv/qa/python/gbuildtojson.py +++ b/solenv/qa/python/gbuildtojson.py @@ -123,7 +123,7 @@ class CheckGbuildToJsonModules(unittest.TestCase): shutil.rmtree(self.tempwork) def test_gbuildtojson(self): - modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'dtrans', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'mysqlc', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'rsc', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity'] + modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'dtrans', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'mysqlc', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'rsc', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'emfio', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity'] if os.environ['OS'] == 'WNT': # for now, use a limited subset for testing on windows as it is so annoyingly slow on this modules = ['chart2', 'cui', 'dbaccess', 'framework', 'oox', 'sfx2', 'svl', 'svtools', 'svx', 'toolkit', 'vcl', 'xmloff'] diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx index da26a83e2b6b..47e70177edf4 100644 --- a/svgio/source/svgreader/svgimagenode.cxx +++ b/svgio/source/svgreader/svgimagenode.cxx @@ -166,13 +166,13 @@ namespace svgio { if(GraphicType::Bitmap == rGraphic.GetType()) { - if(rGraphic.getSvgData().get()) + if(rGraphic.getVectorGraphicData().get()) { // embedded Svg - rEmbedded = rGraphic.getSvgData()->getPrimitive2DSequence(); + rEmbedded = rGraphic.getVectorGraphicData()->getPrimitive2DSequence(); // fill aViewBox - rViewBox = rGraphic.getSvgData()->getRange(); + rViewBox = rGraphic.getVectorGraphicData()->getRange(); } else { diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx index 4fbc04362a5c..6945de277d98 100644 --- a/svtools/source/graphic/grfcache.cxx +++ b/svtools/source/graphic/grfcache.cxx @@ -70,15 +70,15 @@ GraphicID::GraphicID( const GraphicObject& rObj ) { case GraphicType::Bitmap: { - if(rGraphic.getSvgData().get()) + if(rGraphic.getVectorGraphicData().get()) { - const SvgDataPtr& rSvgDataPtr = rGraphic.getSvgData(); - const basegfx::B2DRange& rRange = rSvgDataPtr->getRange(); + const VectorGraphicDataPtr& rVectorGraphicDataPtr = rGraphic.getVectorGraphicData(); + const basegfx::B2DRange& rRange = rVectorGraphicDataPtr->getRange(); - mnID1 |= rSvgDataPtr->getSvgDataArrayLength(); + mnID1 |= rVectorGraphicDataPtr->getVectorGraphicDataArrayLength(); mnID2 = basegfx::fround(rRange.getWidth()); mnID3 = basegfx::fround(rRange.getHeight()); - mnID4 = vcl_get_checksum(0, rSvgDataPtr->getSvgDataArray().getConstArray(), rSvgDataPtr->getSvgDataArrayLength()); + mnID4 = vcl_get_checksum(0, rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), rVectorGraphicDataPtr->getVectorGraphicDataArrayLength()); } else if( rGraphic.IsAnimated() ) { @@ -145,15 +145,15 @@ private: std::vector< GraphicObject* > maGraphicObjectList; - GraphicID maID; - GfxLink maGfxLink; - BitmapEx* mpBmpEx; - GDIMetaFile* mpMtf; - Animation* mpAnimation; - bool mbSwappedAll; + GraphicID maID; + GfxLink maGfxLink; + BitmapEx* mpBmpEx; + GDIMetaFile* mpMtf; + Animation* mpAnimation; + bool mbSwappedAll; - // SvgData support - SvgDataPtr maSvgData; + // VectorGraphicData support + VectorGraphicDataPtr maVectorGraphicData; uno::Sequence<sal_Int8> maPdfData; bool ImplInit( const GraphicObject& rObj ); @@ -229,9 +229,9 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj ) { case GraphicType::Bitmap: { - if(rGraphic.getSvgData().get()) + if(rGraphic.getVectorGraphicData().get()) { - maSvgData = rGraphic.getSvgData(); + maVectorGraphicData = rGraphic.getVectorGraphicData(); } else if( rGraphic.IsAnimated() ) { @@ -280,9 +280,9 @@ void GraphicCacheEntry::ImplFillSubstitute( Graphic& rSubstitute ) if( rSubstitute.IsLink() && ( GfxLinkType::NONE == maGfxLink.GetType() ) ) maGfxLink = rSubstitute.GetLink(); - if(maSvgData.get()) + if(maVectorGraphicData.get()) { - rSubstitute = maSvgData; + rSubstitute = maVectorGraphicData; } else if( mpBmpEx ) { @@ -381,8 +381,8 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut() delete mpAnimation; mpAnimation = nullptr; - // #119176# also reset SvgData - maSvgData.reset(); + // #119176# also reset VectorGraphicData + maVectorGraphicData.reset(); maPdfData = uno::Sequence<sal_Int8>(); } } diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index 0ebde979793a..6e3e7e930ed5 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -598,9 +598,9 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal } if ( rGraphic.GetType() == GraphicType::Bitmap ) { - if(rGraphic.getSvgData().get()) + if(rGraphic.getVectorGraphicData().get()) { - // embedded Svg, no need to scale. Also no method to apply crop data currently + // embedded Vector Graphic Data, no need to scale. Also no method to apply crop data currently } else { diff --git a/svx/inc/pch/precompiled_svxcore.hxx b/svx/inc/pch/precompiled_svxcore.hxx index 454ecd4aa586..c5f848d6af20 100644 --- a/svx/inc/pch/precompiled_svxcore.hxx +++ b/svx/inc/pch/precompiled_svxcore.hxx @@ -141,7 +141,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index e100af7b72b4..08fbfa0caffe 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -604,7 +604,7 @@ void SdrEditView::CheckPossibilities() const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj); const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj); - if(pSdrGrafObj && ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) || pSdrGrafObj->isEmbeddedSvg())) + if(pSdrGrafObj && ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) || pSdrGrafObj->isEmbeddedVectorGraphicData())) { bImportMtfPossible = true; } diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index b26b34cc48a6..b97868fbf485 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -2000,8 +2000,8 @@ namespace { if (pGraf->HasGDIMetaFile()) return pGraf->GetTransformedGraphic(SdrGrafObjTransformsAttrs::COLOR|SdrGrafObjTransformsAttrs::MIRROR).GetGDIMetaFile(); - assert(pGraf->isEmbeddedSvg()); - return pGraf->getMetafileFromEmbeddedSvg(); + assert(pGraf->isEmbeddedVectorGraphicData()); + return pGraf->getMetafileFromEmbeddedVectorGraphicData(); } } @@ -2039,7 +2039,7 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo) sal_uIntPtr nInsAnz=0; tools::Rectangle aLogicRect; - if (pGraf && (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedSvg())) + if (pGraf && (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedVectorGraphicData())) { GDIMetaFile aMetaFile(GetMetaFile(pGraf)); if(aMetaFile.GetActionSize()) diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index d0f042ca0b71..0bf050507bd5 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -285,12 +285,12 @@ void SdrGrafObj::onGraphicChanged() if (!pGraphic || pGraphic->IsSwappedOut()) // don't force swap-in for this return; - const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData(); + const VectorGraphicDataPtr& rVectorGraphicDataPtr = pGraphic->GetGraphic().getVectorGraphicData(); - if (!rSvgDataPtr.get()) + if (!rVectorGraphicDataPtr.get()) return; - const drawinglayer::primitive2d::Primitive2DContainer aSequence(rSvgDataPtr->getPrimitive2DSequence()); + const drawinglayer::primitive2d::Primitive2DContainer aSequence(rVectorGraphicDataPtr->getPrimitive2DSequence()); if (aSequence.empty()) return; @@ -432,11 +432,11 @@ const GraphicObject* SdrGrafObj::GetReplacementGraphicObject() const { if(!mpReplacementGraphic && pGraphic) { - const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData(); + const VectorGraphicDataPtr& rVectorGraphicDataPtr = pGraphic->GetGraphic().getVectorGraphicData(); - if(rSvgDataPtr.get()) + if(rVectorGraphicDataPtr.get()) { - const_cast< SdrGrafObj* >(this)->mpReplacementGraphic = new GraphicObject(rSvgDataPtr->getReplacement()); + const_cast< SdrGrafObj* >(this)->mpReplacementGraphic = new GraphicObject(rVectorGraphicDataPtr->getReplacement()); } else if (pGraphic->GetGraphic().getPdfData().hasElements()) { @@ -742,11 +742,11 @@ OUString SdrGrafObj::TakeObjNameSingul() const if (!pGraphic) return OUString(); - const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData(); + const VectorGraphicDataPtr& rVectorGraphicDataPtr = pGraphic->GetGraphic().getVectorGraphicData(); OUStringBuffer sName; - if(rSvgDataPtr.get()) + if(rVectorGraphicDataPtr.get()) { sName.append(ImpGetResStr(STR_ObjNameSingulGRAFSVG)); } @@ -795,11 +795,11 @@ OUString SdrGrafObj::TakeObjNamePlural() const if(!pGraphic) return OUString(); - const SvgDataPtr& rSvgDataPtr = pGraphic->GetGraphic().getSvgData(); + const VectorGraphicDataPtr& rVectorGraphicDataPtr = pGraphic->GetGraphic().getVectorGraphicData(); OUStringBuffer sName; - if(rSvgDataPtr.get()) + if(rVectorGraphicDataPtr.get()) { sName.append(ImpGetResStr(STR_ObjNamePluralGRAFSVG)); } @@ -1030,16 +1030,16 @@ bool SdrGrafObj::HasGDIMetaFile() const return( pGraphic->GetType() == GraphicType::GdiMetafile ); } -bool SdrGrafObj::isEmbeddedSvg() const +bool SdrGrafObj::isEmbeddedVectorGraphicData() const { - return GraphicType::Bitmap == GetGraphicType() && GetGraphic().getSvgData().get(); + return GraphicType::Bitmap == GetGraphicType() && GetGraphic().getVectorGraphicData().get(); } -GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedSvg() const +GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedVectorGraphicData() const { GDIMetaFile aRetval; - if(isEmbeddedSvg() && GetModel()) + if(isEmbeddedVectorGraphicData() && GetModel()) { ScopedVclPtrInstance< VirtualDevice > pOut; const tools::Rectangle aBoundRect(GetCurrentBoundRect()); @@ -1061,15 +1061,15 @@ GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedSvg() const GDIMetaFile SdrGrafObj::GetMetaFile(GraphicType &rGraphicType) const { - if (isEmbeddedSvg()) + if (isEmbeddedVectorGraphicData()) { - // Embedded Svg + // Embedded Vector Graphic Data // There is currently no helper to create SdrObjects from primitives (even if I'm thinking // about writing one for some time). To get the roundtrip to SdrObjects it is necessary to // use the old converter path over the MetaFile mechanism. Create Metafile from Svg // primitives here pretty directly rGraphicType = GraphicType::GdiMetafile; - return getMetafileFromEmbeddedSvg(); + return getMetafileFromEmbeddedVectorGraphicData(); } else if (GraphicType::GdiMetafile == rGraphicType) { diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 3a440970b953..f4b9a6482084 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -47,7 +47,7 @@ #include <vcl/virdev.hxx> #include <svl/style.hxx> #include <fmobj.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/primitive2d/groupprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> @@ -462,9 +462,9 @@ BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const { const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(GetMarkedObjectByIndex(0)); - if(pSdrGrafObj && pSdrGrafObj->isEmbeddedSvg()) + if(pSdrGrafObj && pSdrGrafObj->isEmbeddedVectorGraphicData()) { - aBmp = pSdrGrafObj->GetGraphic().getSvgData()->getReplacement(); + aBmp = pSdrGrafObj->GetGraphic().getVectorGraphicData()->getReplacement(); } } } @@ -608,10 +608,10 @@ Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* if(pSdrGrafObj) { - if(pSdrGrafObj->isEmbeddedSvg()) + if(pSdrGrafObj->isEmbeddedVectorGraphicData()) { // get Metafile for Svg content - aRet = pSdrGrafObj->getMetafileFromEmbeddedSvg(); + aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData(); } else { diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index a611baff4bf8..db5474ecf63c 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -147,11 +147,11 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, aURL.setBase( aName ); } - // #i121128# use shortcut to write SVG data in original form (if possible) - const SvgDataPtr& aSvgDataPtr(rGraphic.getSvgData()); + // #i121128# use shortcut to write Vector Graphic Data data in original form (if possible) + const VectorGraphicDataPtr& aVectorGraphicDataPtr(rGraphic.getVectorGraphicData()); - if(aSvgDataPtr.get() - && aSvgDataPtr->getSvgDataArrayLength() + if(aVectorGraphicDataPtr.get() + && aVectorGraphicDataPtr->getVectorGraphicDataArrayLength() && rFilterName.equalsIgnoreAsciiCase("svg")) { if(!(nFlags & XOutFlags::DontAddExtension)) @@ -165,7 +165,7 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, if(pOStm) { - pOStm->WriteBytes(aSvgDataPtr->getSvgDataArray().getConstArray(), aSvgDataPtr->getSvgDataArrayLength()); + pOStm->WriteBytes(aVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), aVectorGraphicDataPtr->getVectorGraphicDataArrayLength()); aMedium.Commit(); if(!aMedium.GetError()) diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx index e8daea6dc070..f45b2f48ecf0 100644 --- a/sw/inc/pch/precompiled_msword.hxx +++ b/sw/inc/pch/precompiled_msword.hxx @@ -162,7 +162,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/sw/inc/pch/precompiled_swui.hxx b/sw/inc/pch/precompiled_swui.hxx index 242d1f99a4b2..21004e75191f 100644 --- a/sw/inc/pch/precompiled_swui.hxx +++ b/sw/inc/pch/precompiled_swui.hxx @@ -173,7 +173,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx index b474070f6dc5..088d7c2922e1 100644 --- a/sw/inc/pch/precompiled_vbaswobj.hxx +++ b/sw/inc/pch/precompiled_vbaswobj.hxx @@ -161,7 +161,7 @@ #include <vcl/settings.hxx> #include <vcl/spinfld.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 5ab05d044bd5..c16c548ca626 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -332,11 +332,11 @@ void SwGrfNode::onGraphicChanged() OUString aName; OUString aTitle; OUString aDesc; - const SvgDataPtr& rSvgDataPtr = GetGrf().getSvgData(); + const VectorGraphicDataPtr& rVectorGraphicDataPtr = GetGrf().getVectorGraphicData(); - if(rSvgDataPtr.get()) + if(rVectorGraphicDataPtr.get()) { - const drawinglayer::primitive2d::Primitive2DContainer aSequence(rSvgDataPtr->getPrimitive2DSequence()); + const drawinglayer::primitive2d::Primitive2DContainer aSequence(rVectorGraphicDataPtr->getPrimitive2DSequence()); if(!aSequence.empty()) { @@ -394,11 +394,11 @@ const GraphicObject* SwGrfNode::GetReplacementGrfObj() const { if(!mpReplacementGraphic) { - const SvgDataPtr& rSvgDataPtr = GetGrfObj().GetGraphic().getSvgData(); + const VectorGraphicDataPtr& rVectorGraphicDataPtr = GetGrfObj().GetGraphic().getVectorGraphicData(); - if(rSvgDataPtr.get()) + if(rVectorGraphicDataPtr.get()) { - const_cast< SwGrfNode* >(this)->mpReplacementGraphic = new GraphicObject(rSvgDataPtr->getReplacement()); + const_cast< SwGrfNode* >(this)->mpReplacementGraphic = new GraphicObject(rVectorGraphicDataPtr->getReplacement()); } else if (GetGrfObj().GetGraphic().getPdfData().hasElements()) { diff --git a/vbahelper/inc/pch/precompiled_msforms.hxx b/vbahelper/inc/pch/precompiled_msforms.hxx index a2dcd3185c9d..0debc1add30d 100644 --- a/vbahelper/inc/pch/precompiled_msforms.hxx +++ b/vbahelper/inc/pch/precompiled_msforms.hxx @@ -138,7 +138,7 @@ #include <vcl/scopedbitmapaccess.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> #include <vcl/vclevent.hxx> diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index a0113a2e85d4..9735c606a1a8 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -298,7 +298,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/gdi/sallayout \ vcl/source/gdi/salmisc \ vcl/source/gdi/salnativewidgets-none \ - vcl/source/gdi/svgdata \ + vcl/source/gdi/vectorgraphicdata \ vcl/source/gdi/textlayout \ vcl/source/gdi/virdev \ vcl/source/gdi/wall \ diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index 6260a62e874e..f5982f84cb2d 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -48,7 +48,7 @@ private: mutable sal_uLong mnSizeBytes; bool mbSwapOut; bool mbDummyContext; - SvgDataPtr maSvgData; + VectorGraphicDataPtr maVectorGraphicData; css::uno::Sequence<sal_Int8> maPdfData; private: @@ -58,7 +58,7 @@ private: ImpGraphic( ImpGraphic&& rImpGraphic ); ImpGraphic( const Bitmap& rBmp ); ImpGraphic( const BitmapEx& rBmpEx ); - ImpGraphic(const SvgDataPtr& rSvgDataPtr); + ImpGraphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr); ImpGraphic( const Animation& rAnimation ); ImpGraphic( const GDIMetaFile& rMtf ); public: @@ -145,7 +145,7 @@ private: friend void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic); friend void ReadImpGraphic(SvStream& rIStm, ImpGraphic& rImpGraphic); - const SvgDataPtr& getSvgData() const { return maSvgData; } + const VectorGraphicDataPtr& getVectorGraphicData() const { return maVectorGraphicData; } }; #endif // INCLUDED_VCL_INC_IMPGRAPH_HXX diff --git a/vcl/source/app/brand.cxx b/vcl/source/app/brand.cxx index a4bf268739fe..0d3a7752e2fa 100644 --- a/vcl/source/app/brand.cxx +++ b/vcl/source/app/brand.cxx @@ -26,7 +26,7 @@ #include <tools/stream.hxx> #include <vcl/pngread.hxx> #include <vcl/svapp.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> namespace { bool loadPng( const OUString & rPath, BitmapEx &rBitmap) diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 3027c25062c8..98655baffa4a 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -35,7 +35,7 @@ #include <vcl/salctype.hxx> #include <vcl/pngread.hxx> #include <vcl/pngwrite.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> #include <osl/file.hxx> @@ -1679,7 +1679,7 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, if (!rIStream.GetError() && nMemoryLength >= 0) { - SvgDataArray aNewData(nMemoryLength); + VectorGraphicDataArray aNewData(nMemoryLength); aMemStream.Seek(STREAM_SEEK_TO_BEGIN); aMemStream.ReadBytes(aNewData.begin(), nMemoryLength); @@ -1690,22 +1690,22 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, if(!aMemStream.GetError() ) { - SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath)); - rGraphic = Graphic(aSvgDataPtr); + VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, rPath, VectorGraphicDataType::Svg)); + rGraphic = Graphic(aVectorGraphicDataPtr); bOkay = true; } } } else { - SvgDataArray aNewData(nStreamLength); + VectorGraphicDataArray aNewData(nStreamLength); rIStream.Seek(nStreamPosition); rIStream.ReadBytes(aNewData.begin(), nStreamLength); if(!rIStream.GetError()) { - SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath)); - rGraphic = Graphic(aSvgDataPtr); + VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, rPath, VectorGraphicDataType::Svg)); + rGraphic = Graphic(aVectorGraphicDataPtr); bOkay = true; } } @@ -1766,13 +1766,46 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, else if( aFilterName.equalsIgnoreAsciiCase( IMP_WMF ) || aFilterName.equalsIgnoreAsciiCase( IMP_EMF ) ) { - GDIMetaFile aMtf; - if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, nullptr, pExtHeader ) ) - nStatus = ERRCODE_GRFILTER_FORMATERROR; + static bool bCheckEmf = false; + if (bCheckEmf) + { + if (rGraphic.IsDummyContext()) + rGraphic.SetDummyContext(false); + + const sal_uInt32 nStreamPosition(rIStream.Tell()); + const sal_uInt32 nStreamLength(rIStream.Seek(STREAM_SEEK_TO_END) - nStreamPosition); + VectorGraphicDataArray aNewData(nStreamLength); + bool bOkay(false); + + rIStream.Seek(nStreamPosition); + rIStream.ReadBytes(aNewData.begin(), nStreamLength); + + if (!rIStream.GetError()) + { + VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, rPath, VectorGraphicDataType::Emf)); + rGraphic = Graphic(aVectorGraphicDataPtr); + bOkay = true; + } + + if (bOkay) + { + eLinkType = GfxLinkType::NativeSvg; + } + else + { + nStatus = ERRCODE_GRFILTER_FILTERERROR; + } + } else { - rGraphic = aMtf; - eLinkType = GfxLinkType::NativeWmf; + GDIMetaFile aMtf; + if (!ConvertWMFToGDIMetaFile(rIStream, aMtf, nullptr, pExtHeader)) + nStatus = ERRCODE_GRFILTER_FORMATERROR; + else + { + rGraphic = aMtf; + eLinkType = GfxLinkType::NativeWmf; + } } } else if( aFilterName.equalsIgnoreAsciiCase( IMP_SVSGF ) @@ -2163,12 +2196,12 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r { bool bDone(false); - // do we have a native SVG RenderGraphic, whose data can be written directly? - const SvgDataPtr& aSvgDataPtr(rGraphic.getSvgData()); + // do we have a native Vector Graphic Data RenderGraphic, whose data can be written directly? + const VectorGraphicDataPtr& aVectorGraphicDataPtr(rGraphic.getVectorGraphicData()); - if (aSvgDataPtr.get() && aSvgDataPtr->getSvgDataArrayLength()) + if (aVectorGraphicDataPtr.get() && aVectorGraphicDataPtr->getVectorGraphicDataArrayLength()) { - rOStm.WriteBytes(aSvgDataPtr->getSvgDataArray().getConstArray(), aSvgDataPtr->getSvgDataArrayLength()); + rOStm.WriteBytes(aVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), aVectorGraphicDataPtr->getVectorGraphicDataArrayLength()); if( rOStm.GetError() ) { diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index d863a2413506..b36c5300f4d5 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -211,8 +211,8 @@ Graphic::Graphic(const BitmapEx& rBmpEx) { } -Graphic::Graphic(const SvgDataPtr& rSvgDataPtr) - : mxImpGraphic(new ImpGraphic(rSvgDataPtr)) +Graphic::Graphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr) + : mxImpGraphic(new ImpGraphic(rVectorGraphicDataPtr)) { } @@ -581,9 +581,9 @@ void WriteGraphic( SvStream& rOStream, const Graphic& rGraphic ) WriteImpGraphic(rOStream, *rGraphic.mxImpGraphic); } -const SvgDataPtr& Graphic::getSvgData() const +const VectorGraphicDataPtr& Graphic::getVectorGraphicData() const { - return mxImpGraphic->getSvgData(); + return mxImpGraphic->getVectorGraphicData(); } void Graphic::setPdfData(const uno::Sequence<sal_Int8>& rPdfData) diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index f5f05e06f1a8..dfacf2ca49d5 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -114,7 +114,7 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic) , mnSizeBytes(rImpGraphic.mnSizeBytes) , mbSwapOut(rImpGraphic.mbSwapOut) , mbDummyContext(rImpGraphic.mbDummyContext) - , maSvgData(rImpGraphic.maSvgData) + , maVectorGraphicData(rImpGraphic.maVectorGraphicData) , maPdfData(rImpGraphic.maPdfData) { if( rImpGraphic.mpGfxLink ) @@ -139,7 +139,7 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) , mnSizeBytes(rImpGraphic.mnSizeBytes) , mbSwapOut(rImpGraphic.mbSwapOut) , mbDummyContext(rImpGraphic.mbDummyContext) - , maSvgData(std::move(rImpGraphic.maSvgData)) + , maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData)) , maPdfData(std::move(rImpGraphic.maPdfData)) { rImpGraphic.ImplClear(); @@ -164,12 +164,12 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) : { } -ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr) -: meType( rSvgDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ), +ImpGraphic::ImpGraphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr) +: meType( rVectorGraphicDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ), mnSizeBytes( 0UL ), mbSwapOut( false ), mbDummyContext ( false ), - maSvgData(rSvgDataPtr) + maVectorGraphicData(rVectorGraphicDataPtr) { } @@ -228,7 +228,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic ) if( rImpGraphic.mpGfxLink ) mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink ); - maSvgData = rImpGraphic.maSvgData; + maVectorGraphicData = rImpGraphic.maVectorGraphicData; maPdfData = rImpGraphic.maPdfData; } @@ -248,7 +248,7 @@ ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic) mbSwapOut = rImpGraphic.mbSwapOut; mpSwapFile = std::move(rImpGraphic.mpSwapFile); mpGfxLink = std::move(rImpGraphic.mpGfxLink); - maSvgData = std::move(rImpGraphic.maSvgData); + maVectorGraphicData = std::move(rImpGraphic.maVectorGraphicData); maPdfData = std::move(rImpGraphic.maPdfData); rImpGraphic.ImplClear(); @@ -280,20 +280,20 @@ bool ImpGraphic::operator==( const ImpGraphic& rImpGraphic ) const case GraphicType::Bitmap: { - if(maSvgData.get()) + if(maVectorGraphicData.get()) { - if(maSvgData == rImpGraphic.maSvgData) + if(maVectorGraphicData == rImpGraphic.maVectorGraphicData) { bRet = true; } - else if(rImpGraphic.maSvgData) + else if(rImpGraphic.maVectorGraphicData) { - if(maSvgData->getSvgDataArrayLength() == rImpGraphic.maSvgData->getSvgDataArrayLength()) + if(maVectorGraphicData->getVectorGraphicDataArrayLength() == rImpGraphic.maVectorGraphicData->getVectorGraphicDataArrayLength()) { if(0 == memcmp( - maSvgData->getSvgDataArray().getConstArray(), - rImpGraphic.maSvgData->getSvgDataArray().getConstArray(), - maSvgData->getSvgDataArrayLength())) + maVectorGraphicData->getVectorGraphicDataArray().getConstArray(), + rImpGraphic.maVectorGraphicData->getVectorGraphicDataArray().getConstArray(), + maVectorGraphicData->getVectorGraphicDataArrayLength())) { bRet = true; } @@ -339,7 +339,7 @@ void ImpGraphic::ImplClearGraphics() maMetaFile.Clear(); mpAnimation.reset(); mpGfxLink.reset(); - maSvgData.reset(); + maVectorGraphicData.reset(); maPdfData = uno::Sequence<sal_Int8>(); } @@ -393,7 +393,7 @@ bool ImpGraphic::ImplIsTransparent() const { bool bRet(true); - if( meType == GraphicType::Bitmap && !maSvgData.get()) + if( meType == GraphicType::Bitmap && !maVectorGraphicData.get()) { bRet = ( mpAnimation ? mpAnimation->IsTransparent() : maEx.IsTransparent() ); } @@ -405,7 +405,7 @@ bool ImpGraphic::ImplIsAlpha() const { bool bRet(false); - if(maSvgData.get()) + if(maVectorGraphicData.get()) { bRet = true; } @@ -435,10 +435,10 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) if( meType == GraphicType::Bitmap ) { - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // use maEx as local buffer for rendered svg - const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement(); + const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement(); } const BitmapEx& rRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx ); @@ -543,10 +543,10 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(const GraphicConversionParameters& rParamet if( meType == GraphicType::Bitmap ) { - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // use maEx as local buffer for rendered svg - const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement(); + const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement(); } aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx ); @@ -601,10 +601,10 @@ const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const // survive copying (change this if not wanted) ImpGraphic* pThat = const_cast< ImpGraphic* >(this); - if(maSvgData.get() && !maEx) + if(maVectorGraphicData.get() && !maEx) { // use maEx as local buffer for rendered svg - pThat->maEx = maSvgData->getReplacement(); + pThat->maEx = maVectorGraphicData->getReplacement(); } // #123983# directly create a metafile with the same PrefSize and PrefMapMode @@ -643,10 +643,10 @@ Size ImpGraphic::ImplGetPrefSize() const case GraphicType::Bitmap: { - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // svg not yet buffered in maEx, return size derived from range - const basegfx::B2DRange& rRange = maSvgData->getRange(); + const basegfx::B2DRange& rRange = maVectorGraphicData->getRange(); aSize = Size(basegfx::fround(rRange.getWidth()), basegfx::fround(rRange.getHeight())); } @@ -686,10 +686,10 @@ void ImpGraphic::ImplSetPrefSize( const Size& rPrefSize ) { // used when importing a writer FlyFrame with SVG as graphic, added conversion // to allow setting the PrefSize at the BitmapEx to hold it - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // use maEx as local buffer for rendered svg - maEx = maSvgData->getReplacement(); + maEx = maVectorGraphicData->getReplacement(); } // #108077# Push through pref size to animation object, @@ -728,7 +728,7 @@ MapMode ImpGraphic::ImplGetPrefMapMode() const case GraphicType::Bitmap: { - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // svg not yet buffered in maEx, return default PrefMapMode aMapMode = MapMode(MapUnit::Map100thMM); @@ -765,10 +765,10 @@ void ImpGraphic::ImplSetPrefMapMode( const MapMode& rPrefMapMode ) case GraphicType::Bitmap: { - if(maSvgData.get()) + if(maVectorGraphicData.get()) { - // ignore for Svg. If this is really used (except the grfcache) - // it can be extended by using maEx as buffer for maSvgData->getReplacement() + // ignore for Vector Graphic Data. If this is really used (except the grfcache) + // it can be extended by using maEx as buffer for maVectorGraphicData->getReplacement() } else { @@ -799,12 +799,12 @@ sal_uLong ImpGraphic::ImplGetSizeBytes() const { if( meType == GraphicType::Bitmap ) { - if(maSvgData.get()) + if(maVectorGraphicData.get()) { - std::pair<SvgData::State, size_t> tmp(maSvgData->getSizeBytes()); - if (SvgData::State::UNPARSED == tmp.first) + std::pair<VectorGraphicData::State, size_t> tmp(maVectorGraphicData->getSizeBytes()); + if (VectorGraphicData::State::UNPARSED == tmp.first) { - return tmp.second; // don't cache it until SVG is parsed + return tmp.second; // don't cache it until Vector Graphic Data is parsed } mnSizeBytes = tmp.second; } @@ -833,10 +833,10 @@ void ImpGraphic::ImplDraw( OutputDevice* pOutDev, const Point& rDestPt ) const case GraphicType::Bitmap: { - if(maSvgData.get() && !maEx) + if(maVectorGraphicData.get() && !maEx) { // use maEx as local buffer for rendered svg - const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement(); + const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement(); } if ( mpAnimation ) @@ -869,10 +869,10 @@ void ImpGraphic::ImplDraw( OutputDevice* pOutDev, case GraphicType::Bitmap: { - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // use maEx as local buffer for rendered svg - const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement(); + const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement(); } if( mpAnimation ) @@ -1004,10 +1004,10 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm ) { if( meType == GraphicType::Bitmap ) { - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // use maEx as local buffer for rendered svg - maEx = maSvgData->getReplacement(); + maEx = maVectorGraphicData->getReplacement(); } maEx.aBitmapSize = aSize; @@ -1351,10 +1351,10 @@ BitmapChecksum ImpGraphic::ImplGetChecksum() const case GraphicType::Bitmap: { - if(maSvgData.get() && maEx.IsEmpty()) + if(maVectorGraphicData.get() && maEx.IsEmpty()) { // use maEx as local buffer for rendered svg - const_cast< ImpGraphic* >(this)->maEx = maSvgData->getReplacement(); + const_cast< ImpGraphic* >(this)->maEx = maVectorGraphicData->getReplacement(); } if( mpAnimation ) @@ -1520,20 +1520,20 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic ) if (nSvgMagic == nMagic) { - sal_uInt32 nSvgDataArrayLength(0); - rIStm.ReadUInt32(nSvgDataArrayLength); + sal_uInt32 nVectorGraphicDataArrayLength(0); + rIStm.ReadUInt32(nVectorGraphicDataArrayLength); - if (nSvgDataArrayLength) + if (nVectorGraphicDataArrayLength) { - SvgDataArray aNewData(nSvgDataArrayLength); + VectorGraphicDataArray aNewData(nVectorGraphicDataArrayLength); - rIStm.ReadBytes(aNewData.getArray(), nSvgDataArrayLength); + rIStm.ReadBytes(aNewData.getArray(), nVectorGraphicDataArrayLength); OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet()); if (!rIStm.GetError()) { - SvgDataPtr aSvgDataPtr(new SvgData(aNewData, aPath)); - rImpGraphic = aSvgDataPtr; + VectorGraphicDataPtr aVectorGraphicDataPtr(new VectorGraphicData(aNewData, aPath, VectorGraphicDataType::Svg)); + rImpGraphic = aVectorGraphicDataPtr; } } } @@ -1604,7 +1604,7 @@ void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic) case GraphicType::Bitmap: { - if(rImpGraphic.getSvgData().get()) + if(rImpGraphic.getVectorGraphicData().get()) { // stream out Svg defining data (length, byte array and evtl. path) // this is used e.g. in swapping out graphic data and in transporting it over UNO API @@ -1613,10 +1613,10 @@ void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic) const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0')); rOStm.WriteUInt32( nSvgMagic ); - rOStm.WriteUInt32( rImpGraphic.getSvgData()->getSvgDataArrayLength() ); - rOStm.WriteBytes(rImpGraphic.getSvgData()->getSvgDataArray().getConstArray(), - rImpGraphic.getSvgData()->getSvgDataArrayLength()); - rOStm.WriteUniOrByteString(rImpGraphic.getSvgData()->getPath(), + rOStm.WriteUInt32( rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength() ); + rOStm.WriteBytes(rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray(), + rImpGraphic.getVectorGraphicData()->getVectorGraphicDataArrayLength()); + rOStm.WriteUniOrByteString(rImpGraphic.getVectorGraphicData()->getPath(), rOStm.GetStreamCharSet()); } else if (rImpGraphic.maPdfData.hasElements()) diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx index d15e56aa494a..bb18ccc925bf 100644 --- a/vcl/source/gdi/svgdata.cxx +++ b/vcl/source/gdi/vectorgraphicdata.cxx @@ -18,10 +18,11 @@ */ #include <tools/stream.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/graphic/SvgTools.hpp> +#include <com/sun/star/graphic/EmfTools.hpp> #include <com/sun/star/graphic/Primitive2DTools.hpp> #include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp> #include <com/sun/star/util/XAccounting.hpp> @@ -105,7 +106,7 @@ size_t estimateSize( return nRet; } -void SvgData::ensureReplacement() +void VectorGraphicData::ensureReplacement() { ensureSequenceAndRange(); @@ -115,15 +116,15 @@ void SvgData::ensureReplacement() } } -void SvgData::ensureSequenceAndRange() +void VectorGraphicData::ensureSequenceAndRange() { - if(maSequence.empty() && maSvgDataArray.hasElements()) + if(maSequence.empty() && maVectorGraphicDataArray.hasElements()) { // import SVG to maSequence, also set maRange maRange.reset(); // create stream - const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maSvgDataArray)); + const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maVectorGraphicDataArray)); if(myInputStream.is()) { @@ -131,9 +132,19 @@ void SvgData::ensureSequenceAndRange() try { uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext()); - const uno::Reference< graphic::XSvgParser > xSvgParser = graphic::SvgTools::create(xContext); - maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xSvgParser->getDecomposition(myInputStream, maPath)); + if (VectorGraphicDataType::Emf == getVectorGraphicDataType()) + { + const uno::Reference< graphic::XEmfParser > xEmfParser = graphic::EmfTools::create(xContext); + + maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xEmfParser->getDecomposition(myInputStream, maPath)); + } + else + { + const uno::Reference< graphic::XSvgParser > xSvgParser = graphic::SvgTools::create(xContext); + + maSequence = comphelper::sequenceToContainer<std::deque<css::uno::Reference< css::graphic::XPrimitive2D >>>(xSvgParser->getDecomposition(myInputStream, maPath)); + } } catch(const uno::Exception&) { @@ -169,35 +180,42 @@ void SvgData::ensureSequenceAndRange() } } -auto SvgData::getSizeBytes() -> std::pair<State, size_t> +auto VectorGraphicData::getSizeBytes() -> std::pair<State, size_t> { - if (maSequence.empty() && maSvgDataArray.hasElements()) + if (maSequence.empty() && maVectorGraphicDataArray.hasElements()) { - return std::make_pair(State::UNPARSED, maSvgDataArray.getLength()); + return std::make_pair(State::UNPARSED, maVectorGraphicDataArray.getLength()); } else { - return std::make_pair(State::PARSED, maSvgDataArray.getLength() + mNestedBitmapSize); + return std::make_pair(State::PARSED, maVectorGraphicDataArray.getLength() + mNestedBitmapSize); } } -SvgData::SvgData(const SvgDataArray& rSvgDataArray, const OUString& rPath) -: maSvgDataArray(rSvgDataArray), +VectorGraphicData::VectorGraphicData( + const VectorGraphicDataArray& rVectorGraphicDataArray, + const OUString& rPath, + VectorGraphicDataType eVectorDataType) +: maVectorGraphicDataArray(rVectorGraphicDataArray), maPath(rPath), maRange(), maSequence(), - maReplacement() -, mNestedBitmapSize(0) + maReplacement(), + mNestedBitmapSize(0), + meVectorGraphicDataType(eVectorDataType) { } -SvgData::SvgData(const OUString& rPath): - maSvgDataArray(), +VectorGraphicData::VectorGraphicData( + const OUString& rPath, + VectorGraphicDataType eVectorDataType) +: maVectorGraphicDataArray(), maPath(rPath), maRange(), maSequence(), - maReplacement() -, mNestedBitmapSize(0) + maReplacement(), + mNestedBitmapSize(0), + meVectorGraphicDataType(eVectorDataType) { SvFileStream rIStm(rPath, StreamMode::STD_READ); if(rIStm.GetError()) @@ -205,33 +223,33 @@ SvgData::SvgData(const OUString& rPath): const sal_uInt32 nStmLen(rIStm.remainingSize()); if (nStmLen) { - maSvgDataArray.realloc(nStmLen); - rIStm.ReadBytes(maSvgDataArray.begin(), nStmLen); + maVectorGraphicDataArray.realloc(nStmLen); + rIStm.ReadBytes(maVectorGraphicDataArray.begin(), nStmLen); if (rIStm.GetError()) { - maSvgDataArray = SvgDataArray(); + maVectorGraphicDataArray = VectorGraphicDataArray(); } } } -const basegfx::B2DRange& SvgData::getRange() const +const basegfx::B2DRange& VectorGraphicData::getRange() const { - const_cast< SvgData* >(this)->ensureSequenceAndRange(); + const_cast< VectorGraphicData* >(this)->ensureSequenceAndRange(); return maRange; } -const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& SvgData::getPrimitive2DSequence() const +const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& VectorGraphicData::getPrimitive2DSequence() const { - const_cast< SvgData* >(this)->ensureSequenceAndRange(); + const_cast< VectorGraphicData* >(this)->ensureSequenceAndRange(); return maSequence; } -const BitmapEx& SvgData::getReplacement() const +const BitmapEx& VectorGraphicData::getReplacement() const { - const_cast< SvgData* >(this)->ensureReplacement(); + const_cast< VectorGraphicData* >(this)->ensureReplacement(); return maReplacement; } diff --git a/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx b/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx index 18ecadddb2d1..cfb26d8593ae 100644 --- a/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx +++ b/xmlsecurity/inc/pch/precompiled_xmlsecurity.hxx @@ -150,7 +150,7 @@ #include <vcl/scopedbitmapaccess.hxx> #include <vcl/seleng.hxx> #include <vcl/settings.hxx> -#include <vcl/svgdata.hxx> +#include <vcl/vectorgraphicdata.hxx> #include <vcl/syswin.hxx> #include <vcl/timer.hxx> #include <vcl/vclenum.hxx> |