/src/libreoffice/xmloff/inc/StyleMap.hxx
Line | Count | Source |
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 <cppuhelper/implbase.hxx> |
23 | | #include <o3tl/hash_combine.hxx> |
24 | | #include <unordered_map> |
25 | | #include <utility> |
26 | | |
27 | | enum class XmlStyleFamily; |
28 | | |
29 | | struct StyleNameKey_Impl |
30 | | { |
31 | | XmlStyleFamily m_nFamily; |
32 | | OUString m_aName; |
33 | | |
34 | | StyleNameKey_Impl( XmlStyleFamily nFamily, |
35 | | OUString sName ) : |
36 | 284k | m_nFamily( nFamily ), |
37 | 284k | m_aName(std::move( sName )) |
38 | 284k | { |
39 | 284k | } |
40 | | }; |
41 | | |
42 | | struct StyleNameHash_Impl |
43 | | { |
44 | | inline size_t operator()( const StyleNameKey_Impl& r ) const; |
45 | | inline bool operator()( const StyleNameKey_Impl& r1, |
46 | | const StyleNameKey_Impl& r2 ) const; |
47 | | }; |
48 | | |
49 | | inline size_t StyleNameHash_Impl::operator()( const StyleNameKey_Impl& r ) const |
50 | 284k | { |
51 | 284k | std::size_t seed = 0; |
52 | 284k | o3tl::hash_combine(seed, r.m_nFamily); |
53 | 284k | o3tl::hash_combine(seed, r.m_aName.hashCode()); |
54 | 284k | return seed; |
55 | 284k | } |
56 | | |
57 | | inline bool StyleNameHash_Impl::operator()( |
58 | | const StyleNameKey_Impl& r1, |
59 | | const StyleNameKey_Impl& r2 ) const |
60 | 25.8k | { |
61 | 25.8k | return r1.m_nFamily == r2.m_nFamily && r1.m_aName == r2.m_aName; |
62 | 25.8k | } |
63 | | |
64 | | class StyleMap final : |
65 | | public ::cppu::WeakImplHelper<>, |
66 | | public std::unordered_map< StyleNameKey_Impl, OUString, |
67 | | StyleNameHash_Impl, StyleNameHash_Impl > |
68 | | { |
69 | | |
70 | | public: |
71 | | |
72 | | StyleMap(); |
73 | | virtual ~StyleMap() override; |
74 | | }; |
75 | | |
76 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |