From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- sdext/source/minimizer/graphiccollector.hxx | 95 +++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 sdext/source/minimizer/graphiccollector.hxx (limited to 'sdext/source/minimizer/graphiccollector.hxx') diff --git a/sdext/source/minimizer/graphiccollector.hxx b/sdext/source/minimizer/graphiccollector.hxx new file mode 100644 index 000000000..f989a95ad --- /dev/null +++ b/sdext/source/minimizer/graphiccollector.hxx @@ -0,0 +1,95 @@ +/* -*- 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_SDEXT_SOURCE_MINIMIZER_GRAPHICCOLLECTOR_HXX +#define INCLUDED_SDEXT_SOURCE_MINIMIZER_GRAPHICCOLLECTOR_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +struct GraphicSettings +{ + bool mbJPEGCompression; + sal_Int32 mnJPEGQuality; + bool mbRemoveCropArea; + sal_Int32 mnImageResolution; + bool mbEmbedLinkedGraphics; + + GraphicSettings( bool bJPEGCompression, sal_Int32 nJPEGQuality, bool bRemoveCropArea, + sal_Int32 nImageResolution, bool bEmbedLinkedGraphics ) + : mbJPEGCompression( bJPEGCompression ) + , mnJPEGQuality( nJPEGQuality ) + , mbRemoveCropArea( bRemoveCropArea ) + , mnImageResolution( nImageResolution ) + , mbEmbedLinkedGraphics( bEmbedLinkedGraphics ) {}; +}; + +class GraphicCollector +{ + public: + + struct GraphicUser + { + css::uno::Reference< css::drawing::XShape > mxShape; // if mbFillBitmap is false the xShape has + css::uno::Reference< css::beans::XPropertySet > mxPropertySet; // to be used otherwise the PropertySet + css::uno::Reference< css::beans::XPropertySet > mxPagePropertySet; + css::uno::Reference< css::graphic::XGraphic > mxGraphic; + + css::text::GraphicCrop maGraphicCropLogic; + css::awt::Size maLogicalSize; + bool mbFillBitmap; + + GraphicUser() : mxShape(), maGraphicCropLogic( 0, 0, 0, 0 ), mbFillBitmap( false ) {}; + }; + + struct GraphicEntity + { + css::awt::Size maLogicalSize; // the biggest logical size the graphic will be displayed + bool mbRemoveCropArea; + css::text::GraphicCrop maGraphicCropLogic; + std::vector< GraphicUser > maUser; + + explicit GraphicEntity( const GraphicUser& rUser ) + : maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( false ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); }; + }; + + static const css::awt::DeviceInfo& GetDeviceInfo( const css::uno::Reference< css::uno::XComponentContext >& rxFact ); + static css::awt::Size GetOriginalSize( const css::uno::Reference< css::uno::XComponentContext >& rxMSF, + const css::uno::Reference< css::graphic::XGraphic >& rxGraphic ); + + // collecting graphic instances, the downside of this method is that every graphic is swapped in + static void CollectGraphics( const css::uno::Reference< css::uno::XComponentContext >& rxMSF, const css::uno::Reference< css::frame::XModel >& rxModel, + const GraphicSettings& rGraphicSettings, std::vector< GraphicEntity >& io_rGraphicList ); + // counting graphics without swapping in graphics + static void CountGraphics( const css::uno::Reference< css::uno::XComponentContext >& rxMSF, const css::uno::Reference< css::frame::XModel >& rxModel, + const GraphicSettings& rGraphicSettings, sal_Int32& rGraphics ); +}; + + +#endif // INCLUDED_SDEXT_SOURCE_MINIMIZER_GRAPHICCOLLECTOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3