xref: /AOO41X/main/svx/inc/svx/sdasitm.hxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SDASITM_HXX
25 #define _SDASITM_HXX
26 
27 #include <svx/svddef.hxx>
28 #include <svx/sdooitm.hxx>
29 #include <svl/stritem.hxx>
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <com/sun/star/beans/PropertyValue.hpp>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <rtl/ustring.hxx>
34 #include <hash_map>
35 #include <map>
36 #include "svx/svxdllapi.h"
37 
38 class SdrCustomShapeEngineItem : public SfxStringItem
39 {
40     public :
41             SdrCustomShapeEngineItem();
42             SdrCustomShapeEngineItem( const String& rCustomShapeEngine );
43 };
44 
45 class SdrCustomShapeDataItem : public SfxStringItem
46 {
47     public :
48             SdrCustomShapeDataItem();
49             SdrCustomShapeDataItem( const String& rCustomShapeData );
50 };
51 
52 class SVX_DLLPUBLIC SdrCustomShapeGeometryItem : public SfxPoolItem
53 {
54 public:
55     typedef std::pair < const ::rtl::OUString, const ::rtl::OUString > PropertyPair;
56 
57 private:
58     struct SVX_DLLPRIVATE PropertyEq
59     {
60         bool operator()( const rtl::OUString&, const rtl::OUString& ) const;
61     };
62     struct SVX_DLLPRIVATE PropertyPairEq
63     {
64         bool operator()( const SdrCustomShapeGeometryItem::PropertyPair&, const SdrCustomShapeGeometryItem::PropertyPair& ) const;
65     };
66     struct SVX_DLLPRIVATE PropertyPairHash
67     {
68         size_t operator()( const SdrCustomShapeGeometryItem::PropertyPair &r1 ) const;
69     };
70     typedef std::hash_map < PropertyPair, sal_Int32, PropertyPairHash, PropertyPairEq > PropertyPairHashMap;
71     typedef std::hash_map< rtl::OUString, sal_Int32, rtl::OUStringHash, PropertyEq > PropertyHashMap;
72 
73     PropertyHashMap     aPropHashMap;
74     PropertyPairHashMap aPropPairHashMap;
75 
76     com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aPropSeq;
77 
78     public :
79 
80             TYPEINFO();
81 
82             SdrCustomShapeGeometryItem();
83             SdrCustomShapeGeometryItem( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& );
84             SdrCustomShapeGeometryItem( SvStream& rIn, sal_uInt16 nVersion );
85             ~SdrCustomShapeGeometryItem();
86 
87             virtual int                 operator==( const SfxPoolItem& ) const;
88             virtual SfxItemPresentation GetPresentation(SfxItemPresentation ePresentation,
89                                             SfxMapUnit eCoreMetric, SfxMapUnit ePresentationMetric,
90                                                 String &rText, const IntlWrapper * = 0) const;
91 
92             virtual SfxPoolItem*        Create( SvStream&, sal_uInt16 nItem ) const;
93             virtual SvStream&           Store( SvStream&, sal_uInt16 nVersion ) const;
94 
95             virtual SfxPoolItem*        Clone( SfxItemPool* pPool = NULL ) const;
96             virtual sal_uInt16          GetVersion( sal_uInt16 nFileFormatVersion ) const;
97 
98             virtual sal_Bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
99             virtual sal_Bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
100 
101             const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& GetGeometry() const;
102 
103 #ifdef SDR_ISPOOLABLE
104             virtual int IsPoolable() const;
105 #endif
106             com::sun::star::uno::Any* GetPropertyValueByName( const rtl::OUString& rPropName );
107             com::sun::star::uno::Any* GetPropertyValueByName( const rtl::OUString& rPropName, const rtl::OUString& rPropName2 );
108 
109             void SetPropertyValue( const com::sun::star::beans::PropertyValue& rPropVal );
110             void SetPropertyValue( const rtl::OUString& rSequenceName, const com::sun::star::beans::PropertyValue& rPropVal );
111 
112             void ClearPropertyValue( const rtl::OUString& rPropertyName );
113             void ClearPropertyValue( const rtl::OUString& rSequenceName, const rtl::OUString& rPropertyName );
114 };
115 
116 class SdrCustomShapeReplacementURLItem : public SfxStringItem
117 {
118     public :
119             SdrCustomShapeReplacementURLItem();
120             SdrCustomShapeReplacementURLItem( const String& rCustomShapeReplacementURL );
121 };
122 
123 //---------------------------
124 // class SdrTextWordWrapItem
125 //---------------------------
126 class SdrTextWordWrapItem : public SdrOnOffItem {
127 public:
SdrTextWordWrapItem(sal_Bool bAuto=sal_False)128     SdrTextWordWrapItem( sal_Bool bAuto = sal_False ):  SdrOnOffItem( SDRATTR_TEXT_WORDWRAP, bAuto ) {}
SdrTextWordWrapItem(SvStream & rIn)129     SdrTextWordWrapItem( SvStream& rIn )  :     SdrOnOffItem( SDRATTR_TEXT_WORDWRAP, rIn )   {}
130 };
131 
132 //-------------------------------
133 // class SdrTextAutoGrowSizeItem
134 //-------------------------------
135 class SdrTextAutoGrowSizeItem : public SdrOnOffItem {
136 public:
SdrTextAutoGrowSizeItem(sal_Bool bAuto=sal_False)137     SdrTextAutoGrowSizeItem( sal_Bool bAuto = sal_False ):      SdrOnOffItem( SDRATTR_TEXT_AUTOGROWSIZE, bAuto ) {}
SdrTextAutoGrowSizeItem(SvStream & rIn)138     SdrTextAutoGrowSizeItem( SvStream& rIn )   :        SdrOnOffItem( SDRATTR_TEXT_AUTOGROWSIZE, rIn )   {}
139 };
140 
141 // some useful inline methods
142 
operator ()(const rtl::OUString & r1,const rtl::OUString & r2) const143 inline bool SdrCustomShapeGeometryItem::PropertyEq::operator()( const rtl::OUString& r1, const rtl::OUString& r2 ) const
144 {
145     return r1.equals( r2 );
146 }
147 
operator ()(const SdrCustomShapeGeometryItem::PropertyPair & r1,const SdrCustomShapeGeometryItem::PropertyPair & r2) const148 inline bool SdrCustomShapeGeometryItem::PropertyPairEq::operator()( const SdrCustomShapeGeometryItem::PropertyPair& r1, const SdrCustomShapeGeometryItem::PropertyPair& r2 ) const
149 {
150     return ( r1.first.equals( r2.first ) ) && ( r1.second.equals( r2.second ) );
151 }
152 
operator ()(const SdrCustomShapeGeometryItem::PropertyPair & r1) const153 inline size_t SdrCustomShapeGeometryItem::PropertyPairHash::operator()( const SdrCustomShapeGeometryItem::PropertyPair &r1 ) const
154 {
155     return (size_t)r1.first.hashCode() + r1.second.hashCode();
156 };
157 
158 #endif
159 
160