LibreOffice Module svx (master) 1
sdasitm.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#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
31namespace com::sun::star::uno { class Any; }
32
34{
35public:
36 typedef std::pair < const OUString, const OUString > PropertyPair;
37
38private:
40 {
41 inline 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
48
49 css::uno::Sequence< css::beans::PropertyValue > m_aPropSeq;
50
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;
56
57 void SetPropSeq( const css::uno::Sequence< css::beans::PropertyValue >& rPropSeq );
58 inline void UpdateHash() const;
59 inline void InvalidateHash();
60
61 public:
62
64 SdrCustomShapeGeometryItem( const css::uno::Sequence< css::beans::PropertyValue >& );
65 virtual ~SdrCustomShapeGeometryItem() override;
66
69 SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem const &) = delete; // due to SfxPoolItem
71
72 virtual bool operator==( const SfxPoolItem& ) const override;
73 virtual bool operator<( const SfxPoolItem& ) const override;
74 virtual bool IsSortable() const override { return true; }
75
76 virtual bool GetPresentation(SfxItemPresentation ePresentation,
77 MapUnit eCoreMetric, MapUnit ePresentationMetric,
78 OUString &rText, const IntlWrapper&) const override;
79
80 virtual SdrCustomShapeGeometryItem* Clone( SfxItemPool* pPool = nullptr ) const override;
81
82 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
83 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
84
85 css::uno::Any* GetPropertyValueByName( const OUString& rPropName );
86 const css::uno::Any* GetPropertyValueByName( const OUString& rPropName ) const;
87 css::uno::Any* GetPropertyValueByName( const OUString& rPropName, const OUString& rPropName2 );
88 const css::uno::Any* GetPropertyValueByName( const OUString& rPropName, const OUString& rPropName2 ) const;
89
90 void SetPropertyValue( const css::beans::PropertyValue& rPropVal );
91 void SetPropertyValue( const OUString& rSequenceName, const css::beans::PropertyValue& rPropVal );
92
93 void ClearPropertyValue( const OUString& rPropertyName );
94};
95
97 return SdrOnOffItem( SDRATTR_TEXT_WORDWRAP, bAuto );
98}
99
100// some useful inline methods
101
103{
104 size_t hash = 17;
105 hash = hash * 37 + r1.first.hashCode();
106 hash = hash * 37 + r1.second.hashCode();
107 return hash;
108};
109
110#endif
111
112/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::beans::PropertyValue > m_aPropSeq
Definition: sdasitm.hxx:49
virtual bool IsSortable() const override
Definition: sdasitm.hxx:74
std::pair< const OUString, const OUString > PropertyPair
Definition: sdasitm.hxx:36
std::unordered_map< PropertyPair, sal_Int32, PropertyPairHash > PropertyPairHashMap
Definition: sdasitm.hxx:43
PropertyPairHashMap m_aPropPairHashMap
Definition: sdasitm.hxx:47
SdrCustomShapeGeometryItem(SdrCustomShapeGeometryItem &&)=default
std::unordered_map< OUString, sal_Int32 > PropertyHashMap
Definition: sdasitm.hxx:44
PropertyHashMap m_aPropHashMap
Definition: sdasitm.hxx:46
SdrCustomShapeGeometryItem(const css::uno::Sequence< css::beans::PropertyValue > &)
SdrCustomShapeGeometryItem(SdrCustomShapeGeometryItem const &)=default
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
virtual bool GetPresentation(SfxItemPresentation ePresentation, MapUnit eCoreMetric, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
virtual bool operator==(const SfxPoolItem &) const=0
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
virtual bool operator<(const SfxPoolItem &) const
SfxPoolItem & operator=(const SfxPoolItem &)=delete
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
MapUnit
void SetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName, const css::uno::Any &rValue, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
Unknown
SfxItemPresentation
SdrOnOffItem makeSdrTextWordWrapItem(bool bAuto)
Definition: sdasitm.hxx:96
size_t operator()(const SdrCustomShapeGeometryItem::PropertyPair &) const
Definition: sdasitm.hxx:102
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_WORDWRAP(SDRATTR_MISC_FIRST+24)
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
unsigned char sal_uInt8