diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /vcl/inc/graphic | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/graphic')
-rw-r--r-- | vcl/inc/graphic/DetectorTools.hxx | 65 | ||||
-rw-r--r-- | vcl/inc/graphic/GraphicFormatDetector.hxx | 208 | ||||
-rw-r--r-- | vcl/inc/graphic/GraphicID.hxx | 46 | ||||
-rw-r--r-- | vcl/inc/graphic/GraphicReader.hxx | 37 | ||||
-rw-r--r-- | vcl/inc/graphic/Manager.hxx | 81 | ||||
-rw-r--r-- | vcl/inc/graphic/UnoBinaryDataContainer.hxx | 39 | ||||
-rw-r--r-- | vcl/inc/graphic/UnoGraphic.hxx | 89 | ||||
-rw-r--r-- | vcl/inc/graphic/UnoGraphicDescriptor.hxx | 119 | ||||
-rw-r--r-- | vcl/inc/graphic/VectorGraphicLoader.hxx | 23 |
9 files changed, 707 insertions, 0 deletions
diff --git a/vcl/inc/graphic/DetectorTools.hxx b/vcl/inc/graphic/DetectorTools.hxx new file mode 100644 index 0000000000..3a3bae012e --- /dev/null +++ b/vcl/inc/graphic/DetectorTools.hxx @@ -0,0 +1,65 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include <rtl/string.hxx> + +#include <vector> + +namespace vcl +{ +const char* matchArray(const char* pSource, sal_Int32 nSourceSize, const char* pSearch, + sal_Int32 nSearchSize) +{ + for (sal_Int32 increment = 0; increment <= (nSourceSize - nSearchSize); ++increment) + { + bool bMatch = true; + // search both arrays if they match + for (sal_Int32 index = 0; index < nSearchSize && bMatch; ++index) + { + if (pSource[index] != pSearch[index]) + bMatch = false; + } + // match has been found + if (bMatch) + return pSource; + pSource++; + } + return nullptr; +} + +const char* matchArrayWithString(const char* pSource, sal_Int32 nSourceSize, OString const& rString) +{ + return matchArray(pSource, nSourceSize, rString.getStr(), rString.getLength()); +} + +bool checkArrayForMatchingStrings(const char* pSource, sal_Int32 nSourceSize, + std::vector<OString> const& rStrings) +{ + if (rStrings.empty()) + return false; + if (rStrings.size() < 2) + return matchArrayWithString(pSource, nSourceSize, rStrings[0]) != nullptr; + + const char* pBegin = pSource; + const char* pCurrent = pSource; + for (OString const& rString : rStrings) + { + sal_Int32 nCurrentSize = nSourceSize - sal_Int32(pCurrent - pBegin); + pCurrent = matchArray(pCurrent, nCurrentSize, rString.getStr(), rString.getLength()); + if (pCurrent == nullptr) + return false; + } + return true; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx b/vcl/inc/graphic/GraphicFormatDetector.hxx new file mode 100644 index 0000000000..d6791e377f --- /dev/null +++ b/vcl/inc/graphic/GraphicFormatDetector.hxx @@ -0,0 +1,208 @@ +/* -*- 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_VCL_INC_GRAPHICFORMATDETECTOR_HXX +#define INCLUDED_VCL_INC_GRAPHICFORMATDETECTOR_HXX + +#include <tools/stream.hxx> +#include <vector> +#include <vcl/graphic/GraphicMetadata.hxx> + +namespace vcl +{ +static inline OUString getImportFormatShortName(GraphicFileFormat nFormat) +{ + const char* pKeyName = nullptr; + + switch (nFormat) + { + case GraphicFileFormat::BMP: + pKeyName = "BMP"; + break; + case GraphicFileFormat::GIF: + pKeyName = "GIF"; + break; + case GraphicFileFormat::JPG: + pKeyName = "JPG"; + break; + case GraphicFileFormat::PCD: + pKeyName = "PCD"; + break; + case GraphicFileFormat::PCX: + pKeyName = "PCX"; + break; + case GraphicFileFormat::PNG: + pKeyName = "PNG"; + break; + case GraphicFileFormat::APNG: + pKeyName = "APNG"; + break; + case GraphicFileFormat::XBM: + pKeyName = "XBM"; + break; + case GraphicFileFormat::XPM: + pKeyName = "XPM"; + break; + case GraphicFileFormat::PBM: + pKeyName = "PBM"; + break; + case GraphicFileFormat::PGM: + pKeyName = "PGM"; + break; + case GraphicFileFormat::PPM: + pKeyName = "PPM"; + break; + case GraphicFileFormat::RAS: + pKeyName = "RAS"; + break; + case GraphicFileFormat::TGA: + pKeyName = "TGA"; + break; + case GraphicFileFormat::PSD: + pKeyName = "PSD"; + break; + case GraphicFileFormat::EPS: + pKeyName = "EPS"; + break; + case GraphicFileFormat::TIF: + pKeyName = "TIF"; + break; + case GraphicFileFormat::DXF: + pKeyName = "DXF"; + break; + case GraphicFileFormat::MET: + pKeyName = "MET"; + break; + case GraphicFileFormat::PCT: + pKeyName = "PCT"; + break; + case GraphicFileFormat::SVM: + pKeyName = "SVM"; + break; + case GraphicFileFormat::WMF: + pKeyName = "WMF"; + break; + case GraphicFileFormat::EMF: + pKeyName = "EMF"; + break; + case GraphicFileFormat::SVG: + pKeyName = "SVG"; + break; + case GraphicFileFormat::WMZ: + pKeyName = "WMZ"; + break; + case GraphicFileFormat::EMZ: + pKeyName = "EMZ"; + break; + case GraphicFileFormat::SVGZ: + pKeyName = "SVGZ"; + break; + case GraphicFileFormat::WEBP: + pKeyName = "WEBP"; + break; + case GraphicFileFormat::MOV: + pKeyName = "MOV"; + break; + case GraphicFileFormat::PDF: + pKeyName = "PDF"; + break; + default: + assert(false); + } + + return OUString::createFromAscii(pKeyName); +} +/*** + * This function is has two modes: + * - determine the file format when bTest = false + * returns true, success + * out rFormatExtension - on success: file format string + * - verify file format when bTest = true + * returns false, if file type can't be verified + * true, if the format is verified or the format is not known + */ +VCL_DLLPUBLIC bool peekGraphicFormat(SvStream& rStream, OUString& rFormatExtension, bool bTest); + +class VCL_DLLPUBLIC GraphicFormatDetector +{ +public: + SvStream& mrStream; + OUString maExtension; + + std::vector<sal_uInt8> maFirstBytes; + sal_uInt32 mnFirstLong; + sal_uInt32 mnSecondLong; + + sal_uInt64 mnStreamPosition; + sal_uInt64 mnStreamLength; + + GraphicFormatDetector(SvStream& rStream, OUString aFormatExtension, bool bExtendedInfo = false); + + bool detect(); + + bool checkMET(); + bool checkBMP(); + bool checkWMF(); + bool checkEMF(); + bool checkPCX(); + bool checkTIF(); + bool checkGIF(); + bool checkPNG(); + bool checkAPNG(); + bool checkJPG(); + bool checkSVM(); + bool checkPCD(); + bool checkPSD(); + bool checkEPS(); + bool checkDXF(); + bool checkPCT(); + bool checkPBM(); + bool checkPGM(); + bool checkPPM(); + bool checkRAS(); + bool checkXPM(); + bool checkXBM(); + bool checkSVG(); + bool checkTGA(); + bool checkMOV(); + bool checkPDF(); + bool checkWEBP(); + const GraphicMetadata& getMetadata(); + +private: + /** + * @brief Checks whether mrStream needs to be uncompressed and returns a pointer to the + * to aUncompressedBuffer or a pointer to maFirstBytes if it doesn't need to be uncompressed + * + * @param aUncompressedBuffer the buffer to hold the uncompressed data + * @param nSize the amount of bytes to uncompress + * @param nRetSize the amount of bytes actually uncompressed + * @return sal_uInt8* a pointer to maFirstBytes or aUncompressed buffer + */ + sal_uInt8* checkAndUncompressBuffer(sal_uInt8* aUncompressedBuffer, sal_uInt32 nSize, + sal_uInt64& nDecompressedSize); + bool mbExtendedInfo; + bool mbWasCompressed; + GraphicMetadata maMetadata; +}; +} + +#endif // INCLUDED_VCL_INC_GRAPHICFORMATDETECTOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/GraphicID.hxx b/vcl/inc/graphic/GraphicID.hxx new file mode 100644 index 0000000000..f2f156affe --- /dev/null +++ b/vcl/inc/graphic/GraphicID.hxx @@ -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 . + */ + +#pragma once + +#include <rtl/string.hxx> +#include <vcl/checksum.hxx> + +class ImpGraphic; + +class GraphicID +{ +private: + sal_uInt32 mnID1; + sal_uInt32 mnID2; + sal_uInt32 mnID3; + BitmapChecksum mnID4; + +public: + GraphicID(ImpGraphic const& rGraphic); + + bool operator==(const GraphicID& rID) const + { + return rID.mnID1 == mnID1 && rID.mnID2 == mnID2 && rID.mnID3 == mnID3 && rID.mnID4 == mnID4; + } + + OString getIDString() const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/GraphicReader.hxx b/vcl/inc/graphic/GraphicReader.hxx new file mode 100644 index 0000000000..0faf5a7fe9 --- /dev/null +++ b/vcl/inc/graphic/GraphicReader.hxx @@ -0,0 +1,37 @@ +/* -*- 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/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx new file mode 100644 index 0000000000..65e9214649 --- /dev/null +++ b/vcl/inc/graphic/Manager.hxx @@ -0,0 +1,81 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX +#define INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX + +#include <sal/types.h> +#include <rtl/strbuf.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/animate/Animation.hxx> +#include <vcl/vectorgraphicdata.hxx> +#include <vcl/timer.hxx> +#include <vcl/GraphicExternalLink.hxx> +#include <vcl/gfxlink.hxx> + +#include <memory> +#include <mutex> +#include <chrono> +#include <o3tl/sorted_vector.hxx> + +class ImpGraphic; + +namespace vcl::graphic +{ +class Manager final +{ +private: + std::mutex maMutex; // instead of SolarMutex because graphics can live past vcl main + o3tl::sorted_vector<ImpGraphic*> m_pImpGraphicList; + std::chrono::seconds mnAllowedIdleTime; + bool mbSwapEnabled; + bool mbReducingGraphicMemory; + sal_Int64 mnMemoryLimit; + sal_Int64 mnUsedSize; + Timer maSwapOutTimer; + + Manager(); + + void registerGraphic(const std::shared_ptr<ImpGraphic>& rImpGraphic); + void loopGraphicsAndSwapOut(std::unique_lock<std::mutex>& rGuard, bool bDropAll); + + DECL_LINK(SwapOutTimerHandler, Timer*, void); + + static sal_Int64 getGraphicSizeBytes(const ImpGraphic* pImpGraphic); + void reduceGraphicMemory(std::unique_lock<std::mutex>& rGuard, bool bDropAll = false); + +public: + static Manager& get(); + + void dropCache(); + void dumpState(rtl::OStringBuffer& rState); + + void swappedIn(const ImpGraphic* pImpGraphic, sal_Int64 nSizeBytes); + void swappedOut(const ImpGraphic* pImpGraphic, sal_Int64 nSizeBytes); + + void changeExisting(const ImpGraphic* pImpGraphic, sal_Int64 nOldSize); + void unregisterGraphic(ImpGraphic* pImpGraphic); + + std::shared_ptr<ImpGraphic> copy(std::shared_ptr<ImpGraphic> const& pImpGraphic); + std::shared_ptr<ImpGraphic> newInstance(); + std::shared_ptr<ImpGraphic> newInstance(const BitmapEx& rBitmapEx); + std::shared_ptr<ImpGraphic> newInstance(std::shared_ptr<GfxLink> const& rLink, + sal_Int32 nPageIndex = 0); + std::shared_ptr<ImpGraphic> + newInstance(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr); + std::shared_ptr<ImpGraphic> newInstance(const Animation& rAnimation); + std::shared_ptr<ImpGraphic> newInstance(const GDIMetaFile& rMtf); + std::shared_ptr<ImpGraphic> newInstance(const GraphicExternalLink& rGraphicLink); +}; + +} // end namespace vcl::graphic + +#endif // INCLUDED_VCL_INC_GRAPHIC_MANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/UnoBinaryDataContainer.hxx b/vcl/inc/graphic/UnoBinaryDataContainer.hxx new file mode 100644 index 0000000000..f4a63ce60d --- /dev/null +++ b/vcl/inc/graphic/UnoBinaryDataContainer.hxx @@ -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: + * + */ + +#pragma once + +#include <cppuhelper/implbase.hxx> + +#include <com/sun/star/util/XBinaryDataContainer.hpp> + +#include <utility> +#include <vcl/BinaryDataContainer.hxx> + +class UnoBinaryDataContainer final : public cppu::WeakImplHelper<css::util::XBinaryDataContainer> +{ +private: + BinaryDataContainer maBinaryDataContainer; + +public: + UnoBinaryDataContainer(BinaryDataContainer aBinaryDataContainer) + : maBinaryDataContainer(std::move(aBinaryDataContainer)) + { + } + + BinaryDataContainer const& getBinaryDataContainer() const { return maBinaryDataContainer; } + + // XBinaryDataContainer + css::uno::Sequence<sal_Int8> SAL_CALL getCopyAsByteSequence() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/UnoGraphic.hxx b/vcl/inc/graphic/UnoGraphic.hxx new file mode 100644 index 0000000000..ce060c98f4 --- /dev/null +++ b/vcl/inc/graphic/UnoGraphic.hxx @@ -0,0 +1,89 @@ +/* -*- 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_VCL_SOURCE_GRAPHIC_GRAPHIC_HXX +#define INCLUDED_VCL_SOURCE_GRAPHIC_GRAPHIC_HXX + +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/graphic/XGraphicTransformer.hpp> + +#include <graphic/UnoGraphicDescriptor.hxx> + +#include <vcl/graph.hxx> + +namespace unographic { + +class Graphic final : public css::graphic::XGraphic, + public css::awt::XBitmap, + public css::graphic::XGraphicTransformer, + public ::unographic::GraphicDescriptor +{ +public: + Graphic(); + virtual ~Graphic() noexcept override; + + using ::unographic::GraphicDescriptor::init; + void init(const ::Graphic& rGraphic); + + const ::Graphic& GetGraphic() const { return maGraphic; } + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; +private: + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; + + // XGraphic + virtual ::sal_Int8 SAL_CALL getType( ) override; + + // XBitmap + virtual css::awt::Size SAL_CALL getSize( ) override; + virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL getDIB( ) override; + virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL getMaskDIB( ) override; + + // XGraphicTransformer + virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL colorChange( + const css::uno::Reference< css::graphic::XGraphic >& rGraphic, + sal_Int32 nColorFrom, sal_Int8 nTolerance, sal_Int32 nColorTo, sal_Int8 nAlphaTo ) override; + + virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL applyDuotone( + const css::uno::Reference< css::graphic::XGraphic >& rGraphic, + sal_Int32 nColorOne, sal_Int32 nColorTwo ) override; + + virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL applyBrightnessContrast( + const css::uno::Reference< css::graphic::XGraphic >& rxGraphic, + sal_Int32 nBrightness, sal_Int32 nContrast, sal_Bool mso ) override; + + ::Graphic maGraphic; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/UnoGraphicDescriptor.hxx b/vcl/inc/graphic/UnoGraphicDescriptor.hxx new file mode 100644 index 0000000000..2adc19dac0 --- /dev/null +++ b/vcl/inc/graphic/UnoGraphicDescriptor.hxx @@ -0,0 +1,119 @@ +/* -*- 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_VCL_SOURCE_GRAPHIC_DESCRIPTOR_HXX +#define INCLUDED_VCL_SOURCE_GRAPHIC_DESCRIPTOR_HXX + +#include <comphelper/propertysethelper.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <comphelper/propertysetinfo.hxx> +#include <vcl/graph.hxx> + +inline constexpr OUString MIMETYPE_BMP = u"image/x-MS-bmp"_ustr; +inline constexpr OUString MIMETYPE_GIF = u"image/gif"_ustr; +inline constexpr OUString MIMETYPE_JPG = u"image/jpeg"_ustr; +inline constexpr OUString MIMETYPE_PCD = u"image/x-photo-cd"_ustr; +inline constexpr OUString MIMETYPE_PCX = u"image/x-pcx"_ustr; +inline constexpr OUString MIMETYPE_PNG = u"image/png"_ustr; +inline constexpr OUString MIMETYPE_TIF = u"image/tiff"_ustr; +inline constexpr OUString MIMETYPE_XBM = u"image/x-xbitmap"_ustr; +inline constexpr OUString MIMETYPE_XPM = u"image/x-xpixmap"_ustr; +inline constexpr OUString MIMETYPE_PBM = u"image/x-portable-bitmap"_ustr; +inline constexpr OUString MIMETYPE_PGM = u"image/x-portable-graymap"_ustr; +inline constexpr OUString MIMETYPE_PPM = u"image/x-portable-pixmap"_ustr; +inline constexpr OUString MIMETYPE_RAS = u"image/x-cmu-raster"_ustr; +inline constexpr OUString MIMETYPE_TGA = u"image/x-targa"_ustr; +inline constexpr OUString MIMETYPE_PSD = u"image/vnd.adobe.photoshop"_ustr; +inline constexpr OUString MIMETYPE_EPS = u"image/x-eps"_ustr; +inline constexpr OUString MIMETYPE_DXF = u"image/vnd.dxf"_ustr; +inline constexpr OUString MIMETYPE_MET = u"image/x-met"_ustr; +inline constexpr OUString MIMETYPE_PCT = u"image/x-pict"_ustr; +inline constexpr OUString MIMETYPE_SVM = u"image/x-svm"_ustr; +inline constexpr OUString MIMETYPE_WMF = u"image/x-wmf"_ustr; +inline constexpr OUString MIMETYPE_EMF = u"image/x-emf"_ustr; +inline constexpr OUString MIMETYPE_SVG = u"image/svg+xml"_ustr; +inline constexpr OUString MIMETYPE_PDF = u"application/pdf"_ustr; +inline constexpr OUString MIMETYPE_WEBP = u"image/webp"_ustr; +inline constexpr OUString MIMETYPE_VCLGRAPHIC = u"image/x-vclgraphic"_ustr; + +namespace comphelper { class PropertySetInfo; } +namespace com::sun::star::io { class XInputStream; } + +class Graphic; + +namespace unographic { + +class GraphicDescriptor : public ::cppu::OWeakObject, + public css::lang::XServiceInfo, + public css::lang::XTypeProvider, + public ::comphelper::PropertySetHelper +{ +public: + + GraphicDescriptor(); + virtual ~GraphicDescriptor() noexcept override; + + void init( const ::Graphic& rGraphic ); + void init( const OUString& rURL ); + void init( const css::uno::Reference< css::io::XInputStream >& rxIStm, const OUString& rURL ); + + static rtl::Reference<::comphelper::PropertySetInfo> createPropertySetInfo(); + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + +protected: + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; + + // PropertySetHelper + virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const css::uno::Any* pValues ) override; + virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, css::uno::Any* pValue ) override; + +private: + + const ::Graphic* mpGraphic; + GraphicType meType; + OUString maMimeType; + Size maSizePixel; + Size maSize100thMM; + sal_uInt16 mnBitsPerPixel; + bool mbTransparent; + + GraphicDescriptor( const GraphicDescriptor& rDescriptor ) = delete; + + GraphicDescriptor& operator=( const GraphicDescriptor& ) = delete; + + void implCreate( SvStream& rIStm, const OUString* pPath ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/graphic/VectorGraphicLoader.hxx b/vcl/inc/graphic/VectorGraphicLoader.hxx new file mode 100644 index 0000000000..55714fd2be --- /dev/null +++ b/vcl/inc/graphic/VectorGraphicLoader.hxx @@ -0,0 +1,23 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include <vcl/vectorgraphicdata.hxx> +#include <vcl/BinaryDataContainer.hxx> +#include <memory> + +namespace vcl +{ +std::shared_ptr<VectorGraphicData> loadVectorGraphic(BinaryDataContainer const& rDataContainer, + VectorGraphicDataType eType); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |