Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / svtools / imageresourceaccess.hxx
blobca76c0909f17564de6e3b67fe9f2f136d715766d
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 #pragma once
22 #include <sal/config.h>
24 #include <memory>
25 #include <string_view>
27 #include <config_options.h>
28 #include <svtools/svtdllapi.h>
30 #include <com/sun/star/uno/Reference.hxx>
32 namespace com :: sun :: star :: io { class XInputStream; }
33 namespace com :: sun :: star :: uno { class XComponentContext; }
35 class SvStream;
37 namespace svt::GraphicAccess
40 /** Helpers for obtaining streams (which also can be used with the ImageProducer)
41 from a resource.
44 /** determines whether the given URL denotes an image within a resource */
45 UNLESS_MERGELIBS(SVT_DLLPUBLIC) bool isSupportedURL(std::u16string_view rURL);
47 /** for a given URL of an image within a resource, this method retrieves an
48 SvStream for this image.
50 This method works for arbitrary URLs denoting an image, since the
51 css::graphics::GraphicsProvider service is used
52 to resolve the URL. However, obtaining the stream is expensive (since
53 the image must be copied), so you are strongly encouraged to only use it
54 when you know that the image is small enough.
56 UNLESS_MERGELIBS(SVT_DLLPUBLIC) std::unique_ptr<SvStream> getImageStream(
57 css::uno::Reference<css::uno::XComponentContext> const & rxContext,
58 OUString const & rImageResourceURL);
60 /** for a given URL of an image within a resource, this method retrieves
61 a css::io::XInputStream for this image.
63 UNLESS_MERGELIBS(SVT_DLLPUBLIC) css::uno::Reference<css::io::XInputStream> getImageXStream(
64 css::uno::Reference<css::uno::XComponentContext> const & rxContext,
65 OUString const & rImageResourceURL);
67 } // namespace svt::GraphicAccess
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */