From 5e636747faf919e36bfd015c6dfcf0aea0c41938 Mon Sep 17 00:00:00 2001 From: offtkp Date: Sat, 30 Jul 2022 01:47:54 +0300 Subject: Prepare GraphicDescriptor and GraphicFormatDetector for merging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make GraphicFormatDetector return GraphicFileFormat instead of a string and various variable changes so that the two can be combined in future patches. Change-Id: I6e184b3ba52289db02e0d4eebeeadde0ce0433b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137627 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- include/vcl/graphic/GraphicMetadata.hxx | 61 ++++++++++++++++++++++++++++ include/vcl/graphicfilter.hxx | 72 +++++++-------------------------- 2 files changed, 75 insertions(+), 58 deletions(-) create mode 100644 include/vcl/graphic/GraphicMetadata.hxx (limited to 'include') diff --git a/include/vcl/graphic/GraphicMetadata.hxx b/include/vcl/graphic/GraphicMetadata.hxx new file mode 100644 index 000000000000..da27fde01514 --- /dev/null +++ b/include/vcl/graphic/GraphicMetadata.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ +#ifndef INCLUDED_VCL_GRAPHIC_GRAPHICMETADATA_HXX +#define INCLUDED_VCL_GRAPHIC_GRAPHICMETADATA_HXX +// Info class for all supported file formats +enum class GraphicFileFormat +{ + NOT = 0x0000, + BMP = 0x0001, + GIF = 0x0002, + JPG = 0x0003, + PCD = 0x0004, + PCX = 0x0005, + PNG = 0x0006, + TIF = 0x0007, + XBM = 0x0008, + XPM = 0x0009, + PBM = 0x000a, + PGM = 0x000b, + PPM = 0x000c, + RAS = 0x000d, + TGA = 0x000e, + PSD = 0x000f, + EPS = 0x0010, + WEBP = 0x0011, + MOV = 0x00e0, + PDF = 0x00e1, + DXF = 0x00f1, + MET = 0x00f2, + PCT = 0x00f3, + // retired SGF = 0x00f4, + SVM = 0x00f5, + WMF = 0x00f6, + // retired SGV = 0x00f7, + EMF = 0x00f8, + SVG = 0x00f9, + WMZ = 0x00fa, + EMZ = 0x00fb, + SVGZ = 0x00fc +}; +struct GraphicMetadata +{ + Size maPixSize{}; + Size maLogSize{}; + std::optional maPreferredLogSize = std::nullopt; + std::optional maPreferredMapMode = std::nullopt; + sal_uInt16 mnBitsPerPixel = 0; + sal_uInt16 mnPlanes = 0; + GraphicFileFormat mnFormat = GraphicFileFormat::NOT; + sal_uInt8 mnNumberOfImageComponents = 0; + bool mbIsTransparent = false; + bool mbIsAlpha = false; +}; +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index fb237bc780a4..8985b09eab32 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -25,9 +25,9 @@ #include #include #include +#include #include -#include namespace com::sun::star::beans { struct PropertyValue; } namespace com::sun::star::uno { template class Sequence; } @@ -124,56 +124,12 @@ inline constexpr OUStringLiteral SVG_SHORTNAME = u"SVG"; inline constexpr OUStringLiteral PDF_SHORTNAME = u"PDF"; inline constexpr OUStringLiteral WEBP_SHORTNAME = u"WEBP"; -// Info class for all supported file formats - -enum class GraphicFileFormat -{ - NOT = 0x0000, - BMP = 0x0001, - GIF = 0x0002, - JPG = 0x0003, - PCD = 0x0004, - PCX = 0x0005, - PNG = 0x0006, - TIF = 0x0007, - XBM = 0x0008, - XPM = 0x0009, - PBM = 0x000a, - PGM = 0x000b, - PPM = 0x000c, - RAS = 0x000d, - TGA = 0x000e, - PSD = 0x000f, - EPS = 0x0010, - WEBP = 0x0011, - DXF = 0x00f1, - MET = 0x00f2, - PCT = 0x00f3, - // retired SGF = 0x00f4, - SVM = 0x00f5, - WMF = 0x00f6, - // retired SGV = 0x00f7, - EMF = 0x00f8, - SVG = 0x00f9 -}; - - class VCL_DLLPUBLIC GraphicDescriptor final { - SvStream* pFileStm; - - OUString aPathExt; - Size aPixSize; - Size aLogSize; - std::optional maPreferredLogSize; - std::optional maPreferredMapMode; - sal_uInt16 nBitsPerPixel; - sal_uInt16 nPlanes; - GraphicFileFormat nFormat; - bool bOwnStream; - sal_uInt8 mnNumberOfImageComponents; - bool bIsTransparent; - bool bIsAlpha; + SvStream* pFileStm; + OUString aPathExt; + GraphicMetadata aMetadata; + bool bOwnStream; void ImpConstruct(); @@ -230,37 +186,37 @@ public: bool Detect( bool bExtendedInfo = false ); /** @return the file format, GraphicFileFormat::NOT if no format was recognized */ - GraphicFileFormat GetFileFormat() const { return nFormat; } + GraphicFileFormat GetFileFormat() const { return aMetadata.mnFormat; } /** @return graphic size in pixels or 0 size */ - const Size& GetSizePixel() const { return aPixSize; } + const Size& GetSizePixel() const { return aMetadata.maPixSize; } /** @return the logical graphic size in 1/100mm or 0 size */ - const Size& GetSize_100TH_MM() const { return aLogSize; } + const Size& GetSize_100TH_MM() const { return aMetadata.maLogSize; } /** * Returns the logic size, according to the map mode available via GetPreferredMapMode(). Prefer * this size over GetSize_100TH_MM(). */ - const std::optional& GetPreferredLogSize() const { return maPreferredLogSize; } + const std::optional& GetPreferredLogSize() const { return aMetadata.maPreferredLogSize; } /** * If available, this returns the map mode the graphic prefers, which may be other than pixel or * 100th mm. Prefer this map mode over just assuming MapUnit::Map100thMM. */ - const std::optional& GetPreferredMapMode() const { return maPreferredMapMode; } + const std::optional& GetPreferredMapMode() const { return aMetadata.maPreferredMapMode; } /** @return bits/pixel or 0 **/ - sal_uInt16 GetBitsPerPixel() const { return nBitsPerPixel; } + sal_uInt16 GetBitsPerPixel() const { return aMetadata.mnBitsPerPixel; } /** @return number of color channels */ - sal_uInt8 GetNumberOfImageComponents() const { return mnNumberOfImageComponents; } + sal_uInt8 GetNumberOfImageComponents() const { return aMetadata.mnNumberOfImageComponents; } /** @return whether image supports transparency */ - bool IsTransparent() const { return bIsTransparent; } + bool IsTransparent() const { return aMetadata.mbIsTransparent; } /** @return whether image supports alpha values for translucent colours */ - bool IsAlpha() const { return bIsAlpha; } + bool IsAlpha() const { return aMetadata.mbIsAlpha; } /** @return filter number that is needed by the GraphFilter to read this format */ static OUString GetImportFormatShortName( GraphicFileFormat nFormat ); -- cgit