Line data Source code
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 : #include <com/sun/star/drawing/Direction3D.hpp>
21 : #include <tools/stream.hxx>
22 :
23 : #include <svx/e3ditem.hxx>
24 :
25 : using namespace ::rtl;
26 : using namespace ::com::sun::star;
27 :
28 : // STATIC DATA -----------------------------------------------------------
29 :
30 :
31 :
32 :
33 0 : TYPEINIT1_FACTORY(SvxB3DVectorItem, SfxPoolItem, new SvxB3DVectorItem);
34 :
35 :
36 :
37 0 : SvxB3DVectorItem::SvxB3DVectorItem()
38 : {
39 0 : }
40 :
41 0 : SvxB3DVectorItem::~SvxB3DVectorItem()
42 : {
43 0 : }
44 :
45 :
46 :
47 0 : SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, const basegfx::B3DVector& rVal ) :
48 : SfxPoolItem( _nWhich ),
49 0 : aVal( rVal )
50 : {
51 0 : }
52 :
53 :
54 :
55 0 : SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) :
56 : SfxPoolItem( rItem ),
57 0 : aVal( rItem.aVal )
58 : {
59 0 : }
60 :
61 :
62 :
63 0 : bool SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
64 : {
65 : DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
66 0 : return ((SvxB3DVectorItem&)rItem).aVal == aVal;
67 : }
68 :
69 :
70 :
71 0 : SfxPoolItem* SvxB3DVectorItem::Clone( SfxItemPool* /*pPool*/ ) const
72 : {
73 0 : return new SvxB3DVectorItem( *this );
74 : }
75 :
76 :
77 :
78 0 : SfxPoolItem* SvxB3DVectorItem::Create(SvStream &rStream, sal_uInt16 /*nVersion*/) const
79 : {
80 0 : basegfx::B3DVector aStr;
81 : double fValue;
82 0 : rStream.ReadDouble( fValue ); aStr.setX(fValue);
83 0 : rStream.ReadDouble( fValue ); aStr.setY(fValue);
84 0 : rStream.ReadDouble( fValue ); aStr.setZ(fValue);
85 0 : return new SvxB3DVectorItem(Which(), aStr);
86 : }
87 :
88 :
89 :
90 0 : SvStream& SvxB3DVectorItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/) const
91 : {
92 :
93 : // ## if (nItemVersion)
94 : double fValue;
95 0 : fValue = aVal.getX(); rStream.WriteDouble( fValue );
96 0 : fValue = aVal.getY(); rStream.WriteDouble( fValue );
97 0 : fValue = aVal.getZ(); rStream.WriteDouble( fValue );
98 :
99 0 : return rStream;
100 : }
101 :
102 :
103 :
104 0 : bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
105 : {
106 0 : drawing::Direction3D aDirection;
107 :
108 : // Werte eintragen
109 0 : aDirection.DirectionX = aVal.getX();
110 0 : aDirection.DirectionY = aVal.getY();
111 0 : aDirection.DirectionZ = aVal.getZ();
112 :
113 0 : rVal <<= aDirection;
114 0 : return true;
115 : }
116 :
117 :
118 :
119 0 : bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
120 : {
121 0 : drawing::Direction3D aDirection;
122 0 : if(!(rVal >>= aDirection))
123 0 : return false;
124 :
125 0 : aVal.setX(aDirection.DirectionX);
126 0 : aVal.setY(aDirection.DirectionY);
127 0 : aVal.setZ(aDirection.DirectionZ);
128 0 : return true;
129 : }
130 :
131 :
132 :
133 0 : sal_uInt16 SvxB3DVectorItem::GetVersion (sal_uInt16 nFileFormatVersion) const
134 : {
135 0 : return (nFileFormatVersion == SOFFICE_FILEFORMAT_31) ? USHRT_MAX : 0;
136 : }
137 :
138 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|