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 #ifndef INCLUDED_SVX_SDASITM_HXX
21 #define INCLUDED_SVX_SDASITM_HXX
22 
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>
30 
31 namespace com::sun::star::uno { class Any; }
32 
33 class SVX_DLLPUBLIC SdrCustomShapeGeometryItem : public SfxPoolItem
34 {
35 public:
36     typedef std::pair < const OUString, const OUString > PropertyPair;
37 
38 private:
39     struct SVX_DLLPUBLIC PropertyPairHash
40     {
41         size_t operator()( const SdrCustomShapeGeometryItem::PropertyPair& ) const;
42     };
43     typedef std::unordered_map <PropertyPair, sal_Int32, PropertyPairHash> PropertyPairHashMap;
44     typedef std::unordered_map<OUString, sal_Int32> PropertyHashMap;
45 
46     PropertyHashMap     aPropHashMap;
47     PropertyPairHashMap aPropPairHashMap;
48 
49     css::uno::Sequence< css::beans::PropertyValue > aPropSeq;
50 
51     public:
52 
53             SdrCustomShapeGeometryItem();
54             SdrCustomShapeGeometryItem( const css::uno::Sequence< css::beans::PropertyValue >& );
55             virtual ~SdrCustomShapeGeometryItem() override;
56 
57             SdrCustomShapeGeometryItem(SdrCustomShapeGeometryItem const &) = default;
58             SdrCustomShapeGeometryItem(SdrCustomShapeGeometryItem &&) = default;
59             SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem const &) = delete; // due to SfxPoolItem
60             SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem &&) = delete; // due to SfxPoolItem
61 
62             virtual bool                operator==( const SfxPoolItem& ) const override;
63             virtual bool GetPresentation(SfxItemPresentation ePresentation,
64                                          MapUnit eCoreMetric, MapUnit ePresentationMetric,
65                                          OUString &rText, const IntlWrapper&) const override;
66 
67             virtual SfxPoolItem*        Clone( SfxItemPool* pPool = nullptr ) const override;
68 
69             virtual bool                QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
70             virtual bool                PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
71 
72             css::uno::Any* GetPropertyValueByName( const OUString& rPropName );
73             const css::uno::Any* GetPropertyValueByName( const OUString& rPropName ) const;
74             css::uno::Any* GetPropertyValueByName( const OUString& rPropName, const OUString& rPropName2 );
75             const css::uno::Any* GetPropertyValueByName( const OUString& rPropName, const OUString& rPropName2 ) const;
76 
77             void SetPropertyValue( const css::beans::PropertyValue& rPropVal );
78             void SetPropertyValue( const OUString& rSequenceName, const css::beans::PropertyValue& rPropVal );
79 
80             void ClearPropertyValue( const OUString& rPropertyName );
81 };
82 
makeSdrTextWordWrapItem(bool bAuto)83 inline SdrOnOffItem makeSdrTextWordWrapItem( bool bAuto ) {
84     return SdrOnOffItem( SDRATTR_TEXT_WORDWRAP, bAuto );
85 }
86 
87 // some useful inline methods
88 
operator ()(const SdrCustomShapeGeometryItem::PropertyPair & r1) const89 inline size_t SdrCustomShapeGeometryItem::PropertyPairHash::operator()( const SdrCustomShapeGeometryItem::PropertyPair &r1 ) const
90 {
91     size_t hash = 17;
92     hash = hash * 37 + r1.first.hashCode();
93     hash = hash * 37 + r1.second.hashCode();
94     return hash;
95 };
96 
97 #endif
98 
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
100