Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / items / e3ditem.cxx
blob135c7efaf370fc2cf55c1a1ff01b0c0f1417bc15
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
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 ),
35 aVal( rVal )
40 SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) :
41 SfxPoolItem( rItem ),
42 aVal( rItem.aVal )
47 bool SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
49 assert(SfxPoolItem::operator==(rItem));
50 return static_cast<const SvxB3DVectorItem&>(rItem).aVal == aVal;
53 SvxB3DVectorItem* SvxB3DVectorItem::Clone( SfxItemPool* /*pPool*/ ) const
55 return new SvxB3DVectorItem( *this );
58 bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
60 assert(!std::isnan(aVal.getX()) && !std::isnan(aVal.getY()) && !std::isnan(aVal.getZ()));
62 drawing::Direction3D aDirection;
64 // enter values
65 aDirection.DirectionX = aVal.getX();
66 aDirection.DirectionY = aVal.getY();
67 aDirection.DirectionZ = aVal.getZ();
69 rVal <<= aDirection;
70 return true;
74 bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
76 drawing::Direction3D aDirection;
77 if(!(rVal >>= aDirection))
78 return false;
80 aVal.setX(aDirection.DirectionX);
81 aVal.setY(aDirection.DirectionY);
82 aVal.setZ(aDirection.DirectionZ);
84 assert(!std::isnan(aVal.getX()) && !std::isnan(aVal.getY()) && !std::isnan(aVal.getZ()));
86 return true;
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(aVal.getX()).getStr()));
95 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("y"), BAD_CAST(OString::number(aVal.getY()).getStr()));
96 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("z"), BAD_CAST(OString::number(aVal.getZ()).getStr()));
97 (void)xmlTextWriterEndElement(pWriter);
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */