Avoid potential negative array index access to cached text.
[LibreOffice.git] / vcl / inc / graphic / UnoGraphicDescriptor.hxx
blob2adc19dac059b16d7b8dc94573e3b15509591173
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_SOURCE_GRAPHIC_DESCRIPTOR_HXX
21 #define INCLUDED_VCL_SOURCE_GRAPHIC_DESCRIPTOR_HXX
23 #include <comphelper/propertysethelper.hxx>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <comphelper/propertysetinfo.hxx>
27 #include <vcl/graph.hxx>
29 inline constexpr OUString MIMETYPE_BMP = u"image/x-MS-bmp"_ustr;
30 inline constexpr OUString MIMETYPE_GIF = u"image/gif"_ustr;
31 inline constexpr OUString MIMETYPE_JPG = u"image/jpeg"_ustr;
32 inline constexpr OUString MIMETYPE_PCD = u"image/x-photo-cd"_ustr;
33 inline constexpr OUString MIMETYPE_PCX = u"image/x-pcx"_ustr;
34 inline constexpr OUString MIMETYPE_PNG = u"image/png"_ustr;
35 inline constexpr OUString MIMETYPE_TIF = u"image/tiff"_ustr;
36 inline constexpr OUString MIMETYPE_XBM = u"image/x-xbitmap"_ustr;
37 inline constexpr OUString MIMETYPE_XPM = u"image/x-xpixmap"_ustr;
38 inline constexpr OUString MIMETYPE_PBM = u"image/x-portable-bitmap"_ustr;
39 inline constexpr OUString MIMETYPE_PGM = u"image/x-portable-graymap"_ustr;
40 inline constexpr OUString MIMETYPE_PPM = u"image/x-portable-pixmap"_ustr;
41 inline constexpr OUString MIMETYPE_RAS = u"image/x-cmu-raster"_ustr;
42 inline constexpr OUString MIMETYPE_TGA = u"image/x-targa"_ustr;
43 inline constexpr OUString MIMETYPE_PSD = u"image/vnd.adobe.photoshop"_ustr;
44 inline constexpr OUString MIMETYPE_EPS = u"image/x-eps"_ustr;
45 inline constexpr OUString MIMETYPE_DXF = u"image/vnd.dxf"_ustr;
46 inline constexpr OUString MIMETYPE_MET = u"image/x-met"_ustr;
47 inline constexpr OUString MIMETYPE_PCT = u"image/x-pict"_ustr;
48 inline constexpr OUString MIMETYPE_SVM = u"image/x-svm"_ustr;
49 inline constexpr OUString MIMETYPE_WMF = u"image/x-wmf"_ustr;
50 inline constexpr OUString MIMETYPE_EMF = u"image/x-emf"_ustr;
51 inline constexpr OUString MIMETYPE_SVG = u"image/svg+xml"_ustr;
52 inline constexpr OUString MIMETYPE_PDF = u"application/pdf"_ustr;
53 inline constexpr OUString MIMETYPE_WEBP = u"image/webp"_ustr;
54 inline constexpr OUString MIMETYPE_VCLGRAPHIC = u"image/x-vclgraphic"_ustr;
56 namespace comphelper { class PropertySetInfo; }
57 namespace com::sun::star::io { class XInputStream; }
59 class Graphic;
61 namespace unographic {
63 class GraphicDescriptor : public ::cppu::OWeakObject,
64 public css::lang::XServiceInfo,
65 public css::lang::XTypeProvider,
66 public ::comphelper::PropertySetHelper
68 public:
70 GraphicDescriptor();
71 virtual ~GraphicDescriptor() noexcept override;
73 void init( const ::Graphic& rGraphic );
74 void init( const OUString& rURL );
75 void init( const css::uno::Reference< css::io::XInputStream >& rxIStm, const OUString& rURL );
77 static rtl::Reference<::comphelper::PropertySetInfo> createPropertySetInfo();
79 // XInterface
80 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
81 virtual void SAL_CALL acquire() noexcept override;
82 virtual void SAL_CALL release() noexcept override;
84 protected:
85 // XServiceInfo
86 virtual OUString SAL_CALL getImplementationName() override;
87 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
88 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
90 // XTypeProvider
91 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
92 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
94 // PropertySetHelper
95 virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const css::uno::Any* pValues ) override;
96 virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, css::uno::Any* pValue ) override;
98 private:
100 const ::Graphic* mpGraphic;
101 GraphicType meType;
102 OUString maMimeType;
103 Size maSizePixel;
104 Size maSize100thMM;
105 sal_uInt16 mnBitsPerPixel;
106 bool mbTransparent;
108 GraphicDescriptor( const GraphicDescriptor& rDescriptor ) = delete;
110 GraphicDescriptor& operator=( const GraphicDescriptor& ) = delete;
112 void implCreate( SvStream& rIStm, const OUString* pPath );
117 #endif
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */