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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <com/sun/star/drawing/Direction3D.hpp>
27 #include <tools/stream.hxx>
28
29 #include <svx/e3ditem.hxx>
30
31 using namespace ::rtl;
32 using namespace ::com::sun::star;
33
34 // STATIC DATA -----------------------------------------------------------
35
36 DBG_NAMEEX(SvxB3DVectorItem)
37 DBG_NAME(SvxB3DVectorItem)
38
39 // -----------------------------------------------------------------------
40
41 TYPEINIT1_FACTORY(SvxB3DVectorItem, SfxPoolItem, new SvxB3DVectorItem);
42
43 // -----------------------------------------------------------------------
44
SvxB3DVectorItem()45 SvxB3DVectorItem::SvxB3DVectorItem()
46 {
47 DBG_CTOR(SvxB3DVectorItem, 0);
48 }
49
~SvxB3DVectorItem()50 SvxB3DVectorItem::~SvxB3DVectorItem()
51 {
52 DBG_DTOR(SvxB3DVectorItem, 0);
53 }
54
55 // -----------------------------------------------------------------------
56
SvxB3DVectorItem(sal_uInt16 _nWhich,const basegfx::B3DVector & rVal)57 SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, const basegfx::B3DVector& rVal ) :
58 SfxPoolItem( _nWhich ),
59 aVal( rVal )
60 {
61 DBG_CTOR(SvxB3DVectorItem, 0);
62 }
63
64 // -----------------------------------------------------------------------
65
SvxB3DVectorItem(sal_uInt16 _nWhich,SvStream & rStream)66 SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, SvStream& rStream ) :
67 SfxPoolItem( _nWhich )
68 {
69 DBG_CTOR(SvxB3DVectorItem, 0);
70 double fValue;
71 rStream >> fValue; aVal.setX(fValue);
72 rStream >> fValue; aVal.setY(fValue);
73 rStream >> fValue; aVal.setZ(fValue);
74 }
75
76 // -----------------------------------------------------------------------
77
SvxB3DVectorItem(const SvxB3DVectorItem & rItem)78 SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) :
79 SfxPoolItem( rItem ),
80 aVal( rItem.aVal )
81 {
82 DBG_CTOR(SvxB3DVectorItem, 0);
83 }
84
85 // -----------------------------------------------------------------------
86
operator ==(const SfxPoolItem & rItem) const87 int SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
88 {
89 DBG_CHKTHIS(SvxB3DVectorItem, 0);
90 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
91 return ((SvxB3DVectorItem&)rItem).aVal == aVal;
92 }
93
94 // -----------------------------------------------------------------------
95
Clone(SfxItemPool *) const96 SfxPoolItem* SvxB3DVectorItem::Clone( SfxItemPool* /*pPool*/ ) const
97 {
98 DBG_CHKTHIS(SvxB3DVectorItem, 0);
99 return new SvxB3DVectorItem( *this );
100 }
101
102 // -----------------------------------------------------------------------
103
Create(SvStream & rStream,sal_uInt16) const104 SfxPoolItem* SvxB3DVectorItem::Create(SvStream &rStream, sal_uInt16 /*nVersion*/) const
105 {
106 DBG_CHKTHIS(SvxB3DVectorItem, 0);
107 basegfx::B3DVector aStr;
108 double fValue;
109 rStream >> fValue; aStr.setX(fValue);
110 rStream >> fValue; aStr.setY(fValue);
111 rStream >> fValue; aStr.setZ(fValue);
112 return new SvxB3DVectorItem(Which(), aStr);
113 }
114
115 // -----------------------------------------------------------------------
116
Store(SvStream & rStream,sal_uInt16) const117 SvStream& SvxB3DVectorItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/) const
118 {
119 DBG_CHKTHIS(SvxB3DVectorItem, 0);
120
121 // ## if (nItemVersion)
122 double fValue;
123 fValue = aVal.getX(); rStream << fValue;
124 fValue = aVal.getY(); rStream << fValue;
125 fValue = aVal.getZ(); rStream << fValue;
126
127 return rStream;
128 }
129
130 // -----------------------------------------------------------------------
131
QueryValue(uno::Any & rVal,sal_uInt8) const132 sal_Bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
133 {
134 drawing::Direction3D aDirection;
135
136 // Werte eintragen
137 aDirection.DirectionX = aVal.getX();
138 aDirection.DirectionY = aVal.getY();
139 aDirection.DirectionZ = aVal.getZ();
140
141 rVal <<= aDirection;
142 return( sal_True );
143 }
144
145 // -----------------------------------------------------------------------
146
PutValue(const uno::Any & rVal,sal_uInt8)147 sal_Bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
148 {
149 drawing::Direction3D aDirection;
150 if(!(rVal >>= aDirection))
151 return sal_False;
152
153 aVal.setX(aDirection.DirectionX);
154 aVal.setY(aDirection.DirectionY);
155 aVal.setZ(aDirection.DirectionZ);
156 return sal_True;
157 }
158
159 // -----------------------------------------------------------------------
160
GetVersion(sal_uInt16 nFileFormatVersion) const161 sal_uInt16 SvxB3DVectorItem::GetVersion (sal_uInt16 nFileFormatVersion) const
162 {
163 return (nFileFormatVersion == SOFFICE_FILEFORMAT_31) ? USHRT_MAX : 0;
164 }
165
166 // eof
167