LibreOffice Module svx (master)  1
e3ditem.cxx
Go to the documentation of this file.
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 <libxml/xmlwriter.h>
22 
23 #include <svx/e3ditem.hxx>
24 
25 using namespace ::com::sun::star;
26 
27 
29 {
30 }
31 
32 
33 SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, const basegfx::B3DVector& rVal ) :
34  SfxPoolItem( _nWhich ),
35  aVal( rVal )
36 {
37 }
38 
39 
41  SfxPoolItem( rItem ),
42  aVal( rItem.aVal )
43 {
44 }
45 
46 
47 bool SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
48 {
49  assert(SfxPoolItem::operator==(rItem));
50  return static_cast<const SvxB3DVectorItem&>(rItem).aVal == aVal;
51 }
52 
54 {
55  return new SvxB3DVectorItem( *this );
56 }
57 
58 bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
59 {
60  assert(!std::isnan(aVal.getX()) && !std::isnan(aVal.getY()) && !std::isnan(aVal.getZ()));
61 
62  drawing::Direction3D aDirection;
63 
64  // enter values
65  aDirection.DirectionX = aVal.getX();
66  aDirection.DirectionY = aVal.getY();
67  aDirection.DirectionZ = aVal.getZ();
68 
69  rVal <<= aDirection;
70  return true;
71 }
72 
73 
74 bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
75 {
76  drawing::Direction3D aDirection;
77  if(!(rVal >>= aDirection))
78  return false;
79 
80  aVal.setX(aDirection.DirectionX);
81  aVal.setY(aDirection.DirectionY);
82  aVal.setZ(aDirection.DirectionZ);
83 
84  assert(!std::isnan(aVal.getX()) && !std::isnan(aVal.getY()) && !std::isnan(aVal.getZ()));
85 
86  return true;
87 }
88 
89 
91 {
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);
98 }
99 
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
virtual SvxB3DVectorItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: e3ditem.cxx:53
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: e3ditem.cxx:58
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: e3ditem.cxx:90
basegfx::B3DVector aVal
Definition: e3ditem.hxx:29
void setZ(double fZ)
double getY() const
double getZ() const
void setY(double fY)
double getX() const
css::drawing::Direction3D aDirection
virtual ~SvxB3DVectorItem() override
Definition: e3ditem.cxx:28
unsigned char sal_uInt8
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: e3ditem.cxx:74
void setX(double fX)
virtual bool operator==(const SfxPoolItem &) const override
Definition: e3ditem.cxx:47
sal_uInt16 Which() const
SvxB3DVectorItem(sal_uInt16 nWhich, const basegfx::B3DVector &rVal)
Definition: e3ditem.cxx:33
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo