LibreOffice Module framework (master) 1
ImageList.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <vcl/image.hxx>
23
24#include <string_view>
25#include <unordered_map>
26#include <vector>
27
28// Images identified by either name, or by id
30{
31 OUString maName;
32 sal_uInt16 mnId;
34};
35
36
38{
39public:
40 explicit ImageList();
41 ImageList( const std::vector<OUString>& rNameVector,
42 const OUString& rPrefix);
43
44 void InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
45 const std::vector< OUString > &rNameVector );
47 sal_uInt16 GetImageCount() const;
48
49 void AddImage( const OUString& rImageName, const Image& rImage );
50
51 void ReplaceImage( const OUString& rImageName, const Image& rImage );
52
53 void RemoveImage( sal_uInt16 nId );
54
55 Image GetImage( const OUString& rImageName ) const;
56
57 sal_uInt16 GetImagePos( std::u16string_view rImageName ) const;
58
59 sal_uInt16 GetImageId( sal_uInt16 nPos ) const;
60
61 const OUString & GetImageName( sal_uInt16 nPos ) const;
62 void GetImageNames( ::std::vector< OUString >& rNames ) const;
63
64private:
65
66 std::vector< std::unique_ptr<ImageAryData> > maImages;
67 std::unordered_map< OUString, ImageAryData * > maNameHash;
68 OUString maPrefix;
69
70 sal_uInt16 ImplGetImageId( const OUString& rImageName ) const;
71 void ImplAddImage( std::u16string_view aPrefix, const OUString &aName, sal_uInt16 nId, const Image &aImage );
72 void ImplRemoveImage( sal_uInt16 nPos );
73};
74
75/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddImage(const OUString &rImageName, const Image &rImage)
Definition: ImageList.cxx:97
void ReplaceImage(const OUString &rImageName, const Image &rImage)
Definition: ImageList.cxx:104
sal_uInt16 ImplGetImageId(const OUString &rImageName) const
Definition: ImageList.cxx:89
sal_uInt16 GetImagePos(std::u16string_view rImageName) const
Definition: ImageList.cxx:142
Image GetImage(const OUString &rImageName) const
Definition: ImageList.cxx:129
sal_uInt16 GetImageId(sal_uInt16 nPos) const
Definition: ImageList.cxx:156
const OUString & GetImageName(sal_uInt16 nPos) const
Definition: ImageList.cxx:161
std::unordered_map< OUString, ImageAryData * > maNameHash
Definition: ImageList.hxx:67
BitmapEx GetAsHorizontalStrip() const
Definition: ImageList.cxx:42
void ImplAddImage(std::u16string_view aPrefix, const OUString &aName, sal_uInt16 nId, const Image &aImage)
Definition: ImageList.cxx:180
void GetImageNames(::std::vector< OUString > &rNames) const
Definition: ImageList.cxx:166
void RemoveImage(sal_uInt16 nId)
Definition: ImageList.cxx:117
void ImplRemoveImage(sal_uInt16 nPos)
Definition: ImageList.cxx:193
std::vector< std::unique_ptr< ImageAryData > > maImages
Definition: ImageList.hxx:66
void InsertFromHorizontalStrip(const BitmapEx &rBitmapEx, const std::vector< OUString > &rNameVector)
Definition: ImageList.cxx:65
OUString maPrefix
Definition: ImageList.hxx:68
sal_uInt16 GetImageCount() const
Definition: ImageList.cxx:137
sal_uInt16 nPos
sal_Int16 nId
sal_uInt16 mnId
Definition: ImageList.hxx:32
OUString maName
Definition: ImageList.hxx:31
Image maImage
Definition: ImageList.hxx:33