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 : DBG_NAMEEX(SvxB3DVectorItem)
31 : DBG_NAME(SvxB3DVectorItem)
32 :
33 : // -----------------------------------------------------------------------
34 :
35 4704 : TYPEINIT1_FACTORY(SvxB3DVectorItem, SfxPoolItem, new SvxB3DVectorItem);
36 :
37 : // -----------------------------------------------------------------------
38 :
39 0 : SvxB3DVectorItem::SvxB3DVectorItem()
40 : {
41 : DBG_CTOR(SvxB3DVectorItem, 0);
42 0 : }
43 :
44 1568 : SvxB3DVectorItem::~SvxB3DVectorItem()
45 : {
46 : DBG_DTOR(SvxB3DVectorItem, 0);
47 1568 : }
48 :
49 : // -----------------------------------------------------------------------
50 :
51 3152 : SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, const basegfx::B3DVector& rVal ) :
52 : SfxPoolItem( _nWhich ),
53 3152 : aVal( rVal )
54 : {
55 : DBG_CTOR(SvxB3DVectorItem, 0);
56 3152 : }
57 :
58 : // -----------------------------------------------------------------------
59 :
60 0 : SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) :
61 : SfxPoolItem( rItem ),
62 0 : aVal( rItem.aVal )
63 : {
64 : DBG_CTOR(SvxB3DVectorItem, 0);
65 0 : }
66 :
67 : // -----------------------------------------------------------------------
68 :
69 0 : int SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
70 : {
71 : DBG_CHKTHIS(SvxB3DVectorItem, 0);
72 : DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
73 0 : return ((SvxB3DVectorItem&)rItem).aVal == aVal;
74 : }
75 :
76 : // -----------------------------------------------------------------------
77 :
78 0 : SfxPoolItem* SvxB3DVectorItem::Clone( SfxItemPool* /*pPool*/ ) const
79 : {
80 : DBG_CHKTHIS(SvxB3DVectorItem, 0);
81 0 : return new SvxB3DVectorItem( *this );
82 : }
83 :
84 : // -----------------------------------------------------------------------
85 :
86 0 : SfxPoolItem* SvxB3DVectorItem::Create(SvStream &rStream, sal_uInt16 /*nVersion*/) const
87 : {
88 : DBG_CHKTHIS(SvxB3DVectorItem, 0);
89 0 : basegfx::B3DVector aStr;
90 : double fValue;
91 0 : rStream >> fValue; aStr.setX(fValue);
92 0 : rStream >> fValue; aStr.setY(fValue);
93 0 : rStream >> fValue; aStr.setZ(fValue);
94 0 : return new SvxB3DVectorItem(Which(), aStr);
95 : }
96 :
97 : // -----------------------------------------------------------------------
98 :
99 0 : SvStream& SvxB3DVectorItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/) const
100 : {
101 : DBG_CHKTHIS(SvxB3DVectorItem, 0);
102 :
103 : // ## if (nItemVersion)
104 : double fValue;
105 0 : fValue = aVal.getX(); rStream << fValue;
106 0 : fValue = aVal.getY(); rStream << fValue;
107 0 : fValue = aVal.getZ(); rStream << fValue;
108 :
109 0 : return rStream;
110 : }
111 :
112 : // -----------------------------------------------------------------------
113 :
114 0 : bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
115 : {
116 0 : drawing::Direction3D aDirection;
117 :
118 : // Werte eintragen
119 0 : aDirection.DirectionX = aVal.getX();
120 0 : aDirection.DirectionY = aVal.getY();
121 0 : aDirection.DirectionZ = aVal.getZ();
122 :
123 0 : rVal <<= aDirection;
124 0 : return true;
125 : }
126 :
127 : // -----------------------------------------------------------------------
128 :
129 0 : bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
130 : {
131 0 : drawing::Direction3D aDirection;
132 0 : if(!(rVal >>= aDirection))
133 0 : return false;
134 :
135 0 : aVal.setX(aDirection.DirectionX);
136 0 : aVal.setY(aDirection.DirectionY);
137 0 : aVal.setZ(aDirection.DirectionZ);
138 0 : return true;
139 : }
140 :
141 : // -----------------------------------------------------------------------
142 :
143 0 : sal_uInt16 SvxB3DVectorItem::GetVersion (sal_uInt16 nFileFormatVersion) const
144 : {
145 0 : return (nFileFormatVersion == SOFFICE_FILEFORMAT_31) ? USHRT_MAX : 0;
146 : }
147 :
148 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|