diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-07-10 12:26:37 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-07-10 22:20:00 +0200 |
commit | 37217909f2e7c042eab9a8b5eb1ab0a88cdda513 (patch) | |
tree | 40b360914dd3a1cd353b9cfa822eb6669eab403e /svx/source/unodraw | |
parent | b2cb093d8bd8fbfa4204cb10daec52ec6c283e04 (diff) |
tdf#161979: Render GDI metafile using drawinglayer in XOutBitmap
After the changes related to EMF+ reworking, much of the code was removed
from VCL, e.g. commit 217ad59a412ebab07a106b14c8976d20bddb9356 (tdf#111486
Removed not used EMF+ code, 2018-12-07). EMF+ code is now in drawinglayer
(see EmfPlusHelperData::processEmfPlusData). Unfortunately, we can't make
ImpGraphic::draw in VCL to use drawinglayer for rendering, because VCL is
lower in dependency tree (it only can use drawinglayercore).
Change-Id: I08f8c8ec66baf3dde1f35481144d5e1819bb5fc1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170311
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svx/source/unodraw')
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.cxx | 69 | ||||
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.hxx | 33 | ||||
-rw-r--r-- | svx/source/unodraw/tableshape.cxx | 2 |
3 files changed, 38 insertions, 66 deletions
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 451b95b0e58b..72ae293ee4e2 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -66,7 +66,7 @@ #include <comphelper/sequenceashashmap.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/sequence.hxx> -#include "UnoGraphicExporter.hxx" +#include <UnoGraphicExporter.hxx> #include <memory> // #i102251# #include <editeng/editstat.hxx> @@ -171,37 +171,6 @@ namespace { SdrModel* mpDoc; }; - /** creates a bitmap that is optionally transparent from a metafile - */ - BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, const Size* pSize ) - { - // use new primitive conversion tooling - basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0)); - sal_uInt32 nMaximumQuadraticPixels(500000); - - if(pSize) - { - // use 100th mm for primitive bitmap converter tool, input is pixel - // use a real OutDev to get the correct DPI, the static LogicToLogic assumes 72dpi which is wrong (!) - const Size aSize100th(Application::GetDefaultDevice()->PixelToLogic(*pSize, MapMode(MapUnit::Map100thMM))); - - aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); - - // when explicitly pixels are requested from the GraphicExporter, use a *very* high limit - // of 16gb (4096x4096 pixels), else use the default for the converters - nMaximumQuadraticPixels = std::min(sal_uInt32(4096 * 4096), sal_uInt32(pSize->Width() * pSize->Height())); - } - else - { - // use 100th mm for primitive bitmap converter tool - const Size aSize100th(OutputDevice::LogicToLogic(rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MapMode(MapUnit::Map100thMM))); - - aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); - } - - return convertMetafileToBitmapEx(rMtf, aRange, nMaximumQuadraticPixels); - } - Size* CalcSize( sal_Int32 nWidth, sal_Int32 nHeight, const Size& aBoundSize, Size& aOutSize ) { if( (nWidth == 0) && (nHeight == 0) ) @@ -1289,6 +1258,42 @@ Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames( ) } +/** creates a bitmap that is optionally transparent from a metafile + */ +BitmapEx GetBitmapFromMetaFile(const GDIMetaFile& rMtf, const Size* pSize) +{ + // use new primitive conversion tooling + basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0)); + sal_uInt32 nMaximumQuadraticPixels; + + if (pSize) + { + // use 100th mm for primitive bitmap converter tool, input is pixel + // use a real OutDev to get the correct DPI, the static LogicToLogic assumes 72dpi which is wrong (!) + const Size aSize100th( + Application::GetDefaultDevice()->PixelToLogic(*pSize, MapMode(MapUnit::Map100thMM))); + + aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); + + // when explicitly pixels are requested from the GraphicExporter, use a *very* high limit + // of 16gb (4096x4096 pixels) + nMaximumQuadraticPixels = 4096 * 4096; + } + else + { + // use 100th mm for primitive bitmap converter tool + const Size aSize100th(OutputDevice::LogicToLogic(rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), + MapMode(MapUnit::Map100thMM))); + + aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); + + // limit to 2048x2048 pixels, as in ImpGraphic::getBitmap (vcl/source/gdi/impgraph.cxx): + nMaximumQuadraticPixels = 2048 * 2048; + } + + return convertMetafileToBitmapEx(rMtf, aRange, nMaximumQuadraticPixels); +} + Graphic SvxGetGraphicForShape( SdrObject& rShape ) { Graphic aGraphic; diff --git a/svx/source/unodraw/UnoGraphicExporter.hxx b/svx/source/unodraw/UnoGraphicExporter.hxx deleted file mode 100644 index ace0db252919..000000000000 --- a/svx/source/unodraw/UnoGraphicExporter.hxx +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- 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_SVX_SOURCE_UNODRAW_UNOGRAPHICEXPORTER_HXX -#define INCLUDED_SVX_SOURCE_UNODRAW_UNOGRAPHICEXPORTER_HXX - -#include <sal/config.h> - -#include <vcl/graph.hxx> - -class SdrObject; - -Graphic SvxGetGraphicForShape(SdrObject& rShape); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/unodraw/tableshape.cxx b/svx/source/unodraw/tableshape.cxx index c0df40ddc9f2..ebefa12fec3f 100644 --- a/svx/source/unodraw/tableshape.cxx +++ b/svx/source/unodraw/tableshape.cxx @@ -19,7 +19,7 @@ #include <sal/config.h> -#include "UnoGraphicExporter.hxx" +#include <UnoGraphicExporter.hxx> #include "shapeimpl.hxx" #include <svx/unodraw/SvxTableShape.hxx> #include <svx/unoshprp.hxx> |