Fix typo in code
[LibreOffice.git] / include / svx / sdasitm.hxx
blob7821bbd2e0a8c7bb2a6080a8de56b9eadc975429
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_SVX_SDASITM_HXX
21 #define INCLUDED_SVX_SDASITM_HXX
23 #include <svx/svddef.hxx>
24 #include <svx/sdooitm.hxx>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <rtl/ustring.hxx>
28 #include <svx/svxdllapi.h>
29 #include <unordered_map>
31 namespace com::sun::star::uno { class Any; }
33 class SVXCORE_DLLPUBLIC SdrCustomShapeGeometryItem final : public SfxPoolItem
35 public:
36 typedef std::pair < const OUString, const OUString > PropertyPair;
38 private:
39 struct PropertyPairHash
41 inline size_t operator()( const SdrCustomShapeGeometryItem::PropertyPair& ) const;
43 typedef std::unordered_map <PropertyPair, sal_Int32, PropertyPairHash> PropertyPairHashMap;
44 typedef std::unordered_map<OUString, sal_Int32> PropertyHashMap;
46 PropertyHashMap m_aPropHashMap;
47 PropertyPairHashMap m_aPropPairHashMap;
49 css::uno::Sequence< css::beans::PropertyValue > m_aPropSeq;
51 // For fast comparisons keep a hash of the content, computed on demand
52 // (unusable state is if anyToHash() returns no hash).
53 enum HashState { Unknown, Valid, Unusable };
54 mutable HashState m_aHashState = HashState::Unknown;
55 mutable size_t m_aHash = 0xdeadbeef;
57 SAL_DLLPRIVATE void SetPropSeq( const css::uno::Sequence< css::beans::PropertyValue >& rPropSeq );
58 inline void UpdateHash() const;
59 inline void InvalidateHash();
61 public:
63 SAL_DLLPRIVATE SdrCustomShapeGeometryItem();
64 SdrCustomShapeGeometryItem( const css::uno::Sequence< css::beans::PropertyValue >& );
65 virtual ~SdrCustomShapeGeometryItem() override;
67 SdrCustomShapeGeometryItem(SdrCustomShapeGeometryItem const &) = default;
68 SdrCustomShapeGeometryItem(SdrCustomShapeGeometryItem &&) = default;
69 SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem const &) = delete; // due to SfxPoolItem
70 SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem &&) = delete; // due to SfxPoolItem
72 SAL_DLLPRIVATE virtual bool operator==( const SfxPoolItem& ) const override;
74 SAL_DLLPRIVATE virtual bool GetPresentation(SfxItemPresentation ePresentation,
75 MapUnit eCoreMetric, MapUnit ePresentationMetric,
76 OUString &rText, const IntlWrapper&) const override;
78 SAL_DLLPRIVATE virtual SdrCustomShapeGeometryItem* Clone( SfxItemPool* pPool = nullptr ) const override;
80 SAL_DLLPRIVATE virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
81 SAL_DLLPRIVATE virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
83 css::uno::Any* GetPropertyValueByName( const OUString& rPropName );
84 const css::uno::Any* GetPropertyValueByName( const OUString& rPropName ) const;
85 css::uno::Any* GetPropertyValueByName( const OUString& rPropName, const OUString& rPropName2 );
86 const css::uno::Any* GetPropertyValueByName( const OUString& rPropName, const OUString& rPropName2 ) const;
88 void SetPropertyValue( const css::beans::PropertyValue& rPropVal );
89 void SetPropertyValue( const OUString& rSequenceName, const css::beans::PropertyValue& rPropVal );
91 void ClearPropertyValue( const OUString& rPropertyName );
94 inline SdrOnOffItem makeSdrTextWordWrapItem( bool bAuto ) {
95 return SdrOnOffItem( SDRATTR_TEXT_WORDWRAP, bAuto );
98 // some useful inline methods
100 size_t SdrCustomShapeGeometryItem::PropertyPairHash::operator()( const SdrCustomShapeGeometryItem::PropertyPair &r1 ) const
102 size_t hash = 17;
103 hash = hash * 37 + r1.first.hashCode();
104 hash = hash * 37 + r1.second.hashCode();
105 return hash;
108 #endif
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */