1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 #include <com/sun/star/drawing/Direction3D.hpp> 31 #include <tools/stream.hxx> 32 33 #include <svx/e3ditem.hxx> 34 35 using namespace ::rtl; 36 using namespace ::com::sun::star; 37 38 // STATIC DATA ----------------------------------------------------------- 39 40 DBG_NAMEEX(SvxB3DVectorItem) 41 DBG_NAME(SvxB3DVectorItem) 42 43 // ----------------------------------------------------------------------- 44 45 TYPEINIT1_FACTORY(SvxB3DVectorItem, SfxPoolItem, new SvxB3DVectorItem); 46 47 // ----------------------------------------------------------------------- 48 49 SvxB3DVectorItem::SvxB3DVectorItem() 50 { 51 DBG_CTOR(SvxB3DVectorItem, 0); 52 } 53 54 SvxB3DVectorItem::~SvxB3DVectorItem() 55 { 56 DBG_DTOR(SvxB3DVectorItem, 0); 57 } 58 59 // ----------------------------------------------------------------------- 60 61 SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, const basegfx::B3DVector& rVal ) : 62 SfxPoolItem( _nWhich ), 63 aVal( rVal ) 64 { 65 DBG_CTOR(SvxB3DVectorItem, 0); 66 } 67 68 // ----------------------------------------------------------------------- 69 70 SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, SvStream& rStream ) : 71 SfxPoolItem( _nWhich ) 72 { 73 DBG_CTOR(SvxB3DVectorItem, 0); 74 double fValue; 75 rStream >> fValue; aVal.setX(fValue); 76 rStream >> fValue; aVal.setY(fValue); 77 rStream >> fValue; aVal.setZ(fValue); 78 } 79 80 // ----------------------------------------------------------------------- 81 82 SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) : 83 SfxPoolItem( rItem ), 84 aVal( rItem.aVal ) 85 { 86 DBG_CTOR(SvxB3DVectorItem, 0); 87 } 88 89 // ----------------------------------------------------------------------- 90 91 int SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const 92 { 93 DBG_CHKTHIS(SvxB3DVectorItem, 0); 94 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" ); 95 return ((SvxB3DVectorItem&)rItem).aVal == aVal; 96 } 97 98 // ----------------------------------------------------------------------- 99 100 SfxPoolItem* SvxB3DVectorItem::Clone( SfxItemPool* /*pPool*/ ) const 101 { 102 DBG_CHKTHIS(SvxB3DVectorItem, 0); 103 return new SvxB3DVectorItem( *this ); 104 } 105 106 // ----------------------------------------------------------------------- 107 108 SfxPoolItem* SvxB3DVectorItem::Create(SvStream &rStream, sal_uInt16 /*nVersion*/) const 109 { 110 DBG_CHKTHIS(SvxB3DVectorItem, 0); 111 basegfx::B3DVector aStr; 112 double fValue; 113 rStream >> fValue; aStr.setX(fValue); 114 rStream >> fValue; aStr.setY(fValue); 115 rStream >> fValue; aStr.setZ(fValue); 116 return new SvxB3DVectorItem(Which(), aStr); 117 } 118 119 // ----------------------------------------------------------------------- 120 121 SvStream& SvxB3DVectorItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/) const 122 { 123 DBG_CHKTHIS(SvxB3DVectorItem, 0); 124 125 // ## if (nItemVersion) 126 double fValue; 127 fValue = aVal.getX(); rStream << fValue; 128 fValue = aVal.getY(); rStream << fValue; 129 fValue = aVal.getZ(); rStream << fValue; 130 131 return rStream; 132 } 133 134 // ----------------------------------------------------------------------- 135 136 sal_Bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const 137 { 138 drawing::Direction3D aDirection; 139 140 // Werte eintragen 141 aDirection.DirectionX = aVal.getX(); 142 aDirection.DirectionY = aVal.getY(); 143 aDirection.DirectionZ = aVal.getZ(); 144 145 rVal <<= aDirection; 146 return( sal_True ); 147 } 148 149 // ----------------------------------------------------------------------- 150 151 sal_Bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) 152 { 153 drawing::Direction3D aDirection; 154 if(!(rVal >>= aDirection)) 155 return sal_False; 156 157 aVal.setX(aDirection.DirectionX); 158 aVal.setY(aDirection.DirectionY); 159 aVal.setZ(aDirection.DirectionZ); 160 return sal_True; 161 } 162 163 // ----------------------------------------------------------------------- 164 165 sal_uInt16 SvxB3DVectorItem::GetVersion (sal_uInt16 nFileFormatVersion) const 166 { 167 return (nFileFormatVersion == SOFFICE_FILEFORMAT_31) ? USHRT_MAX : 0; 168 } 169 170 // eof 171