xref: /aoo41x/main/svx/source/items/e3ditem.cxx (revision f6e50924)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <com/sun/star/drawing/Direction3D.hpp>
27cdf0e10cSrcweir #include <tools/stream.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <svx/e3ditem.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir using namespace ::rtl;
32cdf0e10cSrcweir using namespace ::com::sun::star;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
35cdf0e10cSrcweir 
36cdf0e10cSrcweir DBG_NAMEEX(SvxB3DVectorItem)
37cdf0e10cSrcweir DBG_NAME(SvxB3DVectorItem)
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // -----------------------------------------------------------------------
40cdf0e10cSrcweir 
41cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxB3DVectorItem, SfxPoolItem, new SvxB3DVectorItem);
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // -----------------------------------------------------------------------
44cdf0e10cSrcweir 
SvxB3DVectorItem()45cdf0e10cSrcweir SvxB3DVectorItem::SvxB3DVectorItem()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	DBG_CTOR(SvxB3DVectorItem, 0);
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
~SvxB3DVectorItem()50cdf0e10cSrcweir SvxB3DVectorItem::~SvxB3DVectorItem()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	DBG_DTOR(SvxB3DVectorItem, 0);
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // -----------------------------------------------------------------------
56cdf0e10cSrcweir 
SvxB3DVectorItem(sal_uInt16 _nWhich,const basegfx::B3DVector & rVal)57cdf0e10cSrcweir SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, const basegfx::B3DVector& rVal ) :
58cdf0e10cSrcweir 	SfxPoolItem( _nWhich ),
59cdf0e10cSrcweir 	aVal( rVal )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	DBG_CTOR(SvxB3DVectorItem, 0);
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // -----------------------------------------------------------------------
65cdf0e10cSrcweir 
SvxB3DVectorItem(sal_uInt16 _nWhich,SvStream & rStream)66cdf0e10cSrcweir SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, SvStream& rStream ) :
67cdf0e10cSrcweir 	SfxPoolItem( _nWhich )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	DBG_CTOR(SvxB3DVectorItem, 0);
70cdf0e10cSrcweir 	double fValue;
71cdf0e10cSrcweir 	rStream >> fValue; aVal.setX(fValue);
72cdf0e10cSrcweir 	rStream >> fValue; aVal.setY(fValue);
73cdf0e10cSrcweir 	rStream >> fValue; aVal.setZ(fValue);
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir // -----------------------------------------------------------------------
77cdf0e10cSrcweir 
SvxB3DVectorItem(const SvxB3DVectorItem & rItem)78cdf0e10cSrcweir SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) :
79cdf0e10cSrcweir 	SfxPoolItem( rItem ),
80cdf0e10cSrcweir 	aVal( rItem.aVal )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	DBG_CTOR(SvxB3DVectorItem, 0);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir // -----------------------------------------------------------------------
86cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rItem) const87cdf0e10cSrcweir int SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	DBG_CHKTHIS(SvxB3DVectorItem, 0);
90cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
91cdf0e10cSrcweir 	return ((SvxB3DVectorItem&)rItem).aVal == aVal;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // -----------------------------------------------------------------------
95cdf0e10cSrcweir 
Clone(SfxItemPool *) const96cdf0e10cSrcweir SfxPoolItem* SvxB3DVectorItem::Clone( SfxItemPool* /*pPool*/ ) const
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	DBG_CHKTHIS(SvxB3DVectorItem, 0);
99cdf0e10cSrcweir 	return new SvxB3DVectorItem( *this );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // -----------------------------------------------------------------------
103cdf0e10cSrcweir 
Create(SvStream & rStream,sal_uInt16) const104cdf0e10cSrcweir SfxPoolItem* SvxB3DVectorItem::Create(SvStream &rStream, sal_uInt16 /*nVersion*/) const
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	DBG_CHKTHIS(SvxB3DVectorItem, 0);
107cdf0e10cSrcweir 	basegfx::B3DVector aStr;
108cdf0e10cSrcweir 	double fValue;
109cdf0e10cSrcweir 	rStream >> fValue; aStr.setX(fValue);
110cdf0e10cSrcweir 	rStream >> fValue; aStr.setY(fValue);
111cdf0e10cSrcweir 	rStream >> fValue; aStr.setZ(fValue);
112cdf0e10cSrcweir 	return new SvxB3DVectorItem(Which(), aStr);
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir // -----------------------------------------------------------------------
116cdf0e10cSrcweir 
Store(SvStream & rStream,sal_uInt16) const117cdf0e10cSrcweir SvStream& SvxB3DVectorItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/) const
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	DBG_CHKTHIS(SvxB3DVectorItem, 0);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	// ## if (nItemVersion)
122cdf0e10cSrcweir 	double fValue;
123cdf0e10cSrcweir 	fValue = aVal.getX(); rStream << fValue;
124cdf0e10cSrcweir 	fValue = aVal.getY(); rStream << fValue;
125cdf0e10cSrcweir 	fValue = aVal.getZ(); rStream << fValue;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	return rStream;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // -----------------------------------------------------------------------
131cdf0e10cSrcweir 
QueryValue(uno::Any & rVal,sal_uInt8) const132cdf0e10cSrcweir sal_Bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	drawing::Direction3D aDirection;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	// Werte eintragen
137cdf0e10cSrcweir 	aDirection.DirectionX = aVal.getX();
138cdf0e10cSrcweir 	aDirection.DirectionY = aVal.getY();
139cdf0e10cSrcweir 	aDirection.DirectionZ = aVal.getZ();
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	rVal <<= aDirection;
142cdf0e10cSrcweir 	return( sal_True );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir // -----------------------------------------------------------------------
146cdf0e10cSrcweir 
PutValue(const uno::Any & rVal,sal_uInt8)147cdf0e10cSrcweir sal_Bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	drawing::Direction3D aDirection;
150cdf0e10cSrcweir 	if(!(rVal >>= aDirection))
151cdf0e10cSrcweir 		return sal_False;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	aVal.setX(aDirection.DirectionX);
154cdf0e10cSrcweir 	aVal.setY(aDirection.DirectionY);
155cdf0e10cSrcweir 	aVal.setZ(aDirection.DirectionZ);
156cdf0e10cSrcweir 	return sal_True;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // -----------------------------------------------------------------------
160cdf0e10cSrcweir 
GetVersion(sal_uInt16 nFileFormatVersion) const161cdf0e10cSrcweir sal_uInt16 SvxB3DVectorItem::GetVersion (sal_uInt16 nFileFormatVersion) const
162cdf0e10cSrcweir {
163cdf0e10cSrcweir 	return (nFileFormatVersion == SOFFICE_FILEFORMAT_31) ? USHRT_MAX : 0;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir // eof
167