1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/drawing/Direction3D.hpp>
21 #include <libxml/xmlwriter.h>
22 #include <o3tl/hash_combine.hxx>
23 #include <svx/e3ditem.hxx>
25 using namespace ::com::sun::star
;
28 SvxB3DVectorItem::~SvxB3DVectorItem()
33 SvxB3DVectorItem::SvxB3DVectorItem( TypedWhichId
<SvxB3DVectorItem
> _nWhich
, const basegfx::B3DVector
& rVal
) :
34 SfxPoolItem( _nWhich
, SfxItemType::SvxB3DVectorItemType
),
40 SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem
& rItem
) :
42 m_aVal( rItem
.m_aVal
)
46 bool SvxB3DVectorItem::operator==( const SfxPoolItem
&rItem
) const
48 assert(SfxPoolItem::operator==(rItem
));
49 return static_cast<const SvxB3DVectorItem
&>(rItem
).m_aVal
== m_aVal
;
52 SvxB3DVectorItem
* SvxB3DVectorItem::Clone( SfxItemPool
* /*pPool*/ ) const
54 return new SvxB3DVectorItem( *this );
57 bool SvxB3DVectorItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
59 assert(!std::isnan(m_aVal
.getX()) && !std::isnan(m_aVal
.getY()) && !std::isnan(m_aVal
.getZ()));
61 drawing::Direction3D aDirection
;
64 aDirection
.DirectionX
= m_aVal
.getX();
65 aDirection
.DirectionY
= m_aVal
.getY();
66 aDirection
.DirectionZ
= m_aVal
.getZ();
73 bool SvxB3DVectorItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
75 ASSERT_CHANGE_REFCOUNTED_ITEM
;
76 drawing::Direction3D aDirection
;
77 if(!(rVal
>>= aDirection
))
80 m_aVal
.setX(aDirection
.DirectionX
);
81 m_aVal
.setY(aDirection
.DirectionY
);
82 m_aVal
.setZ(aDirection
.DirectionZ
);
84 assert(!std::isnan(m_aVal
.getX()) && !std::isnan(m_aVal
.getY()) && !std::isnan(m_aVal
.getZ()));
90 void SvxB3DVectorItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
92 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SvxB3DVectorItem"));
93 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
94 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("x"), BAD_CAST(OString::number(m_aVal
.getX()).getStr()));
95 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("y"), BAD_CAST(OString::number(m_aVal
.getY()).getStr()));
96 (void)xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("z"), BAD_CAST(OString::number(m_aVal
.getZ()).getStr()));
97 (void)xmlTextWriterEndElement(pWriter
);
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */