forms/source/component/imgprod.cxx | 6 ++--- include/vcl/graph.hxx | 3 -- vcl/Library_vcl.mk | 1 vcl/inc/graphic/GraphicReader.hxx | 37 ---------------------------------- vcl/inc/impgraph.hxx | 3 -- vcl/source/filter/graphicfilter.cxx | 18 +++------------- vcl/source/filter/igif/gifread.cxx | 4 --- vcl/source/filter/ixbm/xbmread.cxx | 4 --- vcl/source/filter/ixpm/xpmread.cxx | 3 -- vcl/source/filter/jpeg/JpegReader.cxx | 6 ----- vcl/source/filter/jpeg/JpegReader.hxx | 6 +---- vcl/source/gdi/graph.cxx | 10 --------- vcl/source/gdi/impgraph.cxx | 12 ----------- vcl/source/graphic/GraphicReader.cxx | 29 -------------------------- 14 files changed, 12 insertions(+), 130 deletions(-)
New commits: commit 374a76adc567ad9fe4fa09099f7038c0f388a28e Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Mar 23 22:56:53 2024 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Jun 27 16:07:20 2024 +0200 vcl: Remove graph. reader context from {Imp}Graph and GraphicReader This removes the mpContext member variable from ImpGraph, which also make {Get,Set}ReaderContext on Graphic obsolete and is also removed. GraphicFilter and other code is adjusted and simplified. Change-Id: Icd1927d7b1bd4624b523d0f49a4343911ec6cd0a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165214 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index bec815b91343..47f9f13e3425 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -125,7 +125,7 @@ void ImageProducer::setImage( css::uno::Reference< css::io::XInputStream > const void ImageProducer::NewDataAvailable() { - if( ( GraphicType::NONE == moGraphic->GetType() ) || moGraphic->GetReaderContext() ) + if (GraphicType::NONE == moGraphic->GetType()) startProduction(); } @@ -138,11 +138,11 @@ void ImageProducer::startProduction() bool bNotifyEmptyGraphics = false; // valid stream or filled graphic? => update consumers - if( mpStm || ( moGraphic->GetType() != GraphicType::NONE ) ) + if (mpStm || moGraphic->GetType() != GraphicType::NONE) { // if we already have a graphic, we don't have to import again; // graphic is cleared if a new Stream is set - if( ( moGraphic->GetType() == GraphicType::NONE ) || moGraphic->GetReaderContext() ) + if (moGraphic->GetType() == GraphicType::NONE) { if ( ImplImportGraphic( *moGraphic ) ) maDoneHdl.Call( &*moGraphic ); diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index 74261bb84e6f..9d1499ea98c1 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -47,7 +47,6 @@ class GDIMetaFile; class SvStream; class ImpGraphic; class OutputDevice; -class GraphicReader; class SAL_WARN_UNUSED VCL_DLLPUBLIC GraphicConversionParameters { @@ -174,8 +173,6 @@ public: SAL_DLLPRIVATE OString getUniqueID() const; - std::shared_ptr<GraphicReader>& GetReaderContext(); - SAL_DLLPRIVATE void SetReaderContext( const std::shared_ptr<GraphicReader> &pReader ); SAL_DLLPRIVATE void SetDummyContext(bool value); SAL_DLLPRIVATE bool IsDummyContext() const; diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 361d55a0ae2c..dd3d9d48c8e3 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -319,7 +319,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/graphic/GraphicLoader \ vcl/source/graphic/GraphicObject \ vcl/source/graphic/GraphicObject2 \ - vcl/source/graphic/GraphicReader \ vcl/source/graphic/Manager \ vcl/source/graphic/UnoBinaryDataContainer \ vcl/source/graphic/UnoGraphic \ diff --git a/vcl/inc/graphic/GraphicReader.hxx b/vcl/inc/graphic/GraphicReader.hxx deleted file mode 100644 index 0faf5a7fe9d0..000000000000 --- a/vcl/inc/graphic/GraphicReader.hxx +++ /dev/null @@ -1,37 +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 . - */ - -#pragma once - -#include <rtl/ustring.hxx> - -class GraphicReader -{ -public: - virtual ~GraphicReader(); - - const OUString& GetUpperFilterName() const { return maUpperName; } - -protected: - OUString maUpperName; - - GraphicReader(); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index fd6446e1972a..e15845c9d99a 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -70,7 +70,6 @@ private: Size maExPrefSize; ImpSwapInfo maSwapInfo; std::unique_ptr<Animation> mpAnimation; - std::shared_ptr<GraphicReader> mpContext; std::shared_ptr<ImpSwapFile> mpSwapFile; std::shared_ptr<GfxLink> mpGfxLink; std::shared_ptr<VectorGraphicData> maVectorGraphicData; @@ -189,8 +188,6 @@ private: bool swapOutGraphic(SvStream& rStream); // end swapping - std::shared_ptr<GraphicReader>& getContext() { return mpContext;} - void setContext( const std::shared_ptr<GraphicReader>& pReader ); void setDummyContext( bool value ) { mbDummyContext = value; } bool isDummyContext() const { return mbDummyContext; } void setGfxLink( const std::shared_ptr<GfxLink>& ); diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index a7b125760107..e4a9f97f3188 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -91,7 +91,6 @@ #include "FilterConfigCache.hxx" #include <graphic/GraphicFormatDetector.hxx> -#include <graphic/GraphicReader.hxx> // Support for GfxLinkType::NativeWebp is so far disabled, // as enabling it would write .webp images e.g. to .odt documents, @@ -640,7 +639,7 @@ void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGra if (!rContext.mAlphaMask.IsEmpty()) // Need to move the AlphaMask back to the BitmapEx. *rContext.m_pGraphic = BitmapEx( rContext.m_pGraphic->GetBitmapExRef().GetBitmap(), rContext.mAlphaMask ); - if (rContext.m_nStatus == ERRCODE_NONE && (rContext.m_eLinkType != GfxLinkType::NONE) && !rContext.m_pGraphic->GetReaderContext()) + if (rContext.m_nStatus == ERRCODE_NONE && rContext.m_eLinkType != GfxLinkType::NONE) { BinaryDataContainer aGraphicContent; @@ -1281,10 +1280,8 @@ ErrCode GraphicFilter::ImportGraphic(Graphic& rGraphic, std::u16string_view rPat ResetLastError(); - std::shared_ptr<GraphicReader> pContext = rGraphic.GetReaderContext(); - bool bDummyContext = rGraphic.IsDummyContext(); - if( !pContext || bDummyContext ) { + bool bDummyContext = rGraphic.IsDummyContext(); if( bDummyContext ) { rGraphic.SetDummyContext( false ); @@ -1313,13 +1310,6 @@ ErrCode GraphicFilter::ImportGraphic(Graphic& rGraphic, std::u16string_view rPat aFilterName = pConfig->GetImportFilterName( nFormat ); } - else - { - aFilterName = pContext->GetUpperFilterName(); - - nStreamBegin = 0; - nStatus = ERRCODE_NONE; - } // read graphic { @@ -1423,7 +1413,7 @@ ErrCode GraphicFilter::ImportGraphic(Graphic& rGraphic, std::u16string_view rPat nStatus = ERRCODE_GRFILTER_FILTERERROR; } - if( nStatus == ERRCODE_NONE && ( eLinkType != GfxLinkType::NONE ) && !rGraphic.GetReaderContext() && !bLinkSet ) + if (nStatus == ERRCODE_NONE && eLinkType != GfxLinkType::NONE && !bLinkSet) { if (aGraphicContent.isEmpty()) { @@ -1854,7 +1844,7 @@ IMPL_LINK( GraphicFilter, FilterCallback, ConvertData&, rData, bool ) default: break; } - if( GraphicType::NONE == rData.maGraphic.GetType() || rData.maGraphic.GetReaderContext() ) // Import + if (GraphicType::NONE == rData.maGraphic.GetType()) // Import { // Import nFormat = GetImportFormatNumberForShortName( aShortName ); diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 67af603218d4..6f96131a7908 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -23,7 +23,6 @@ #include "gifread.hxx" #include <memory> #include <vcl/BitmapWriteAccess.hxx> -#include <graphic/GraphicReader.hxx> namespace { @@ -53,7 +52,7 @@ class SvStream; namespace { -class GIFReader : public GraphicReader +class GIFReader { Animation aAnimation; sal_uInt64 nAnimationByteSize; @@ -155,7 +154,6 @@ GIFReader::GIFReader( SvStream& rStm ) , cNonTransIndex1 ( 0 ) , nPaletteSize( 0 ) { - maUpperName = "SVIGIF"; aSrcBuf.resize(256); // Memory buffer for ReadNextBlock ClearImageExtensions(); } diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx index 5b6ae9dd7d07..2a701e4ce025 100644 --- a/vcl/source/filter/ixbm/xbmread.cxx +++ b/vcl/source/filter/ixbm/xbmread.cxx @@ -24,7 +24,6 @@ #include <rtl/character.hxx> #include <vcl/BitmapWriteAccess.hxx> -#include <graphic/GraphicReader.hxx> #include "xbmread.hxx" @@ -43,7 +42,7 @@ enum ReadState XBMREAD_ERROR }; -class XBMReader : public GraphicReader +class XBMReader { SvStream& mrStream; Bitmap maBitmap; @@ -74,7 +73,6 @@ XBMReader::XBMReader(SvStream& rStream) : mrStream(rStream) , mnLastPosition(rStream.Tell()) { - maUpperName = "SVIXBM"; InitTable(); } diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx index 1ad06483a712..6c9d226a3f32 100644 --- a/vcl/source/filter/ixpm/xpmread.cxx +++ b/vcl/source/filter/ixpm/xpmread.cxx @@ -23,7 +23,6 @@ #include <tools/stream.hxx> #include <vcl/BitmapWriteAccess.hxx> -#include <graphic/GraphicReader.hxx> #include "rgbtable.hxx" @@ -63,7 +62,7 @@ class Graphic; namespace { -class XPMReader : public GraphicReader +class XPMReader { private: SvStream& mrStream; diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index 7e4b3dc25f63..81f1a1688cdd 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -174,18 +174,12 @@ JPEGReader::JPEGReader( SvStream& rStream, GraphicFilterImportFlags nImportFlags mnLastPos ( rStream.Tell() ), mbSetLogSize ( nImportFlags & GraphicFilterImportFlags::SetLogsizeForJpeg ) { - maUpperName = "SVIJPEG"; - if (!(nImportFlags & GraphicFilterImportFlags::UseExistingBitmap)) { mpBitmap.emplace(); } } -JPEGReader::~JPEGReader() -{ -} - bool JPEGReader::CreateBitmap(JPEGCreateBitmapParam const & rParam) { if (rParam.nWidth > SAL_MAX_INT32 / 8 || rParam.nHeight > SAL_MAX_INT32 / 8) diff --git a/vcl/source/filter/jpeg/JpegReader.hxx b/vcl/source/filter/jpeg/JpegReader.hxx index 0e541c75916f..58d8f8315054 100644 --- a/vcl/source/filter/jpeg/JpegReader.hxx +++ b/vcl/source/filter/jpeg/JpegReader.hxx @@ -23,7 +23,6 @@ #include <vcl/bitmap.hxx> #include <vcl/BitmapWriteAccess.hxx> -#include <graphic/GraphicReader.hxx> enum class GraphicFilterImportFlags; @@ -44,7 +43,7 @@ struct JPEGCreateBitmapParam bool bGray; }; -class JPEGReader : public GraphicReader +class JPEGReader { SvStream& mrStream; std::optional<Bitmap> mpBitmap; @@ -52,8 +51,7 @@ class JPEGReader : public GraphicReader bool mbSetLogSize; public: - JPEGReader( SvStream& rStream, GraphicFilterImportFlags nImportFlags ); - virtual ~JPEGReader() override; + JPEGReader( SvStream& rStream, GraphicFilterImportFlags nImportFlags ); ReadState Read(Graphic& rGraphic, GraphicFilterImportFlags nImportFlags, BitmapScopedWriteAccess* ppAccess); diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 2c3e05235225..f90adeb24703 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -474,16 +474,6 @@ sal_uInt32 Graphic::GetAnimationLoopCount() const return mxImpGraphic->getAnimationLoopCount(); } -std::shared_ptr<GraphicReader>& Graphic::GetReaderContext() -{ - return mxImpGraphic->getContext(); -} - -void Graphic::SetReaderContext( const std::shared_ptr<GraphicReader> &pReader ) -{ - mxImpGraphic->setContext( pReader ); -} - void Graphic::SetDummyContext( bool value ) { mxImpGraphic->setDummyContext( value ); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 8bdcfb4146f6..d801fd14b8e2 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -92,7 +92,6 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic) , maMetaFile(rImpGraphic.maMetaFile) , maBitmapEx(rImpGraphic.maBitmapEx) , maSwapInfo(rImpGraphic.maSwapInfo) - , mpContext(rImpGraphic.mpContext) , mpSwapFile(rImpGraphic.mpSwapFile) , mpGfxLink(rImpGraphic.mpGfxLink) , maVectorGraphicData(rImpGraphic.maVectorGraphicData) @@ -119,7 +118,6 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept , maBitmapEx(std::move(rImpGraphic.maBitmapEx)) , maSwapInfo(std::move(rImpGraphic.maSwapInfo)) , mpAnimation(std::move(rImpGraphic.mpAnimation)) - , mpContext(std::move(rImpGraphic.mpContext)) , mpSwapFile(std::move(rImpGraphic.mpSwapFile)) , mpGfxLink(std::move(rImpGraphic.mpGfxLink)) , maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData)) @@ -207,7 +205,6 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic ) updateCurrentSizeInBytes(mnSizeBytes); maSwapInfo = rImpGraphic.maSwapInfo; - mpContext = rImpGraphic.mpContext; mbDummyContext = rImpGraphic.mbDummyContext; maGraphicExternalLink = rImpGraphic.maGraphicExternalLink; @@ -244,7 +241,6 @@ ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic) meType = rImpGraphic.meType; mnSizeBytes = rImpGraphic.mnSizeBytes; maSwapInfo = std::move(rImpGraphic.maSwapInfo); - mpContext = std::move(rImpGraphic.mpContext); mbDummyContext = rImpGraphic.mbDummyContext; mpAnimation = std::move(rImpGraphic.mpAnimation); maBitmapEx = std::move(rImpGraphic.maBitmapEx); @@ -1120,12 +1116,6 @@ sal_uInt32 ImpGraphic::getAnimationLoopCount() const return mpAnimation ? mpAnimation->GetLoopCount() : 0; } -void ImpGraphic::setContext( const std::shared_ptr<GraphicReader>& pReader ) -{ - mpContext = pReader; - mbDummyContext = false; -} - bool ImpGraphic::swapInContent(SvStream& rStream) { bool bRet = false; @@ -1759,8 +1749,6 @@ sal_Int32 ImpGraphic::getPageNumber() const bool ImpGraphic::canReduceMemory() const { - if (mpContext) - return false; return !isSwappedOut(); } diff --git a/vcl/source/graphic/GraphicReader.cxx b/vcl/source/graphic/GraphicReader.cxx deleted file mode 100644 index 9137ebd8a246..000000000000 --- a/vcl/source/graphic/GraphicReader.cxx +++ /dev/null @@ -1,29 +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 . - */ - -#include <graphic/GraphicReader.hxx> - -#include <sal/config.h> -#include <sal/log.hxx> - -GraphicReader::GraphicReader() {} - -GraphicReader::~GraphicReader() {} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */