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