LibreOffice Module svx (master)  1
chrtitem.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 <comphelper/fileformat.h>
21 #include <tools/stream.hxx>
22 #include <basic/sbxvar.hxx>
23 #include <rtl/math.hxx>
24 #include <unotools/intlwrapper.hxx>
26 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
27 
28 #include <float.h>
29 #include <climits>
30 
31 #include <svx/chrtitem.hxx>
32 
33 using namespace ::com::sun::star;
34 
35 
37 
39  sal_uInt16 nId) :
40  SfxEnumItem(nId, eOrder)
41 {
42 }
43 
44 
46 {
47  return new SvxChartTextOrderItem(*this);
48 }
49 
50 
51 bool SvxChartTextOrderItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
52 {
53  // the order of the two enums is not equal, so a mapping is required
54  css::chart::ChartAxisArrangeOrderType eAO;
55  SvxChartTextOrder eOrder( GetValue());
56 
57  switch( eOrder )
58  {
60  eAO = css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE; break;
62  eAO = css::chart::ChartAxisArrangeOrderType_STAGGER_ODD; break;
64  eAO = css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN; break;
66  eAO = css::chart::ChartAxisArrangeOrderType_AUTO; break;
67  }
68 
69  rVal <<= eAO;
70 
71  return true;
72 }
73 
74 
75 bool SvxChartTextOrderItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
76 {
77  // the order of the two enums is not equal, so a mapping is required
78  css::chart::ChartAxisArrangeOrderType eAO;
79  SvxChartTextOrder eOrder;
80 
81  if(!(rVal >>= eAO))
82  {
83  // also try an int (for Basic)
84  sal_Int32 nAO = 0;
85  if(!(rVal >>= nAO))
86  return false;
87  eAO = static_cast< css::chart::ChartAxisArrangeOrderType >( nAO );
88  }
89 
90  switch( eAO )
91  {
92  case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE:
93  eOrder = SvxChartTextOrder::SideBySide; break;
94  case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD:
95  eOrder = SvxChartTextOrder::UpDown; break;
96  case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN:
97  eOrder = SvxChartTextOrder::DownUp; break;
98  case css::chart::ChartAxisArrangeOrderType_AUTO:
99  eOrder = SvxChartTextOrder::Auto; break;
100  default:
101  return false;
102  }
103 
104  SetValue( eOrder );
105 
106  return true;
107 }
108 
109 SvxDoubleItem::SvxDoubleItem(double fValue, sal_uInt16 nId) :
110  SfxPoolItem(nId),
111  fVal(fValue)
112 {
113 }
114 
116  SfxPoolItem(rItem),
117  fVal(rItem.fVal)
118 {
119 }
120 
122  ( SfxItemPresentation /*ePresentation*/, MapUnit /*eCoreMetric*/,
123  MapUnit /*ePresentationMetric*/, OUString& rText,
124  const IntlWrapper& rIntlWrapper) const
125 {
126  rText = ::rtl::math::doubleToUString( fVal, rtl_math_StringFormat_E, 4,
127  rIntlWrapper.getLocaleData()->getNumDecimalSep()[0], true );
128  return true;
129 }
130 
131 bool SvxDoubleItem::operator == (const SfxPoolItem& rItem) const
132 {
133  return static_cast<const SvxDoubleItem&>(rItem).fVal == fVal;
134 }
135 
137 {
138  return new SvxDoubleItem(*this);
139 }
140 
141 bool SvxDoubleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
142 {
143  rVal <<= fVal;
144  return true;
145 }
146 
147 bool SvxDoubleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
148 {
149  return rVal >>= fVal;
150 }
151 
153  sal_uInt16 nId) :
154  SfxEnumItem(nId, eOrient)
155 {
156 }
157 
158 
160 {
161  return new SvxChartKindErrorItem(*this);
162 }
163 
164 
166  sal_uInt16 nId) :
167  SfxEnumItem(nId, eOrient)
168 {
169 }
170 
171 
173 {
174  return new SvxChartIndicateItem(*this);
175 }
176 
177 
179  sal_uInt16 nId) :
180  SfxEnumItem(nId, eOrient)
181 {
182 }
183 
184 
186 {
187  return new SvxChartRegressItem(*this);
188 }
189 
190 
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxChartRegress
Definition: chrtitem.hxx:65
SvxChartRegressItem(SvxChartRegress eRegress, sal_uInt16 nId)
Definition: chrtitem.cxx:178
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:185
SvxDoubleItem(double fValue, sal_uInt16 nId)
Definition: chrtitem.cxx:109
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: chrtitem.cxx:147
SvxChartIndicateItem(SvxChartIndicate eOrient, sal_uInt16 nId)
Definition: chrtitem.cxx:165
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:45
SvxChartTextOrder
Definition: chrtitem.hxx:31
const LocaleDataWrapper * getLocaleData() const
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &) const override
Definition: chrtitem.cxx:122
static SfxPoolItem * CreateDefault()
Definition: chrtitem.cxx:36
const OUString & getNumDecimalSep() const
SfxItemPresentation
void SetValue(EnumT nTheValue)
SvxChartTextOrderItem(SvxChartTextOrder eOrder, sal_uInt16 nId)
Definition: chrtitem.cxx:38
virtual bool operator==(const SfxPoolItem &) const override
Definition: chrtitem.cxx:131
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:159
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: chrtitem.cxx:51
SvxChartIndicate
Definition: chrtitem.hxx:55
SvxChartKindError
Definition: chrtitem.hxx:41
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Definition: chrtitem.cxx:141
SvxChartKindErrorItem(SvxChartKindError, sal_uInt16 nId)
Definition: chrtitem.cxx:152
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: chrtitem.cxx:75
unsigned char sal_uInt8
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:172
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:136
MapUnit