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  assert(SfxPoolItem::operator==(rItem));
126  return static_cast<const SvxDoubleItem&>(rItem).fVal == fVal;
127 }
128 
130 {
131  return new SvxDoubleItem(*this);
132 }
133 
134 bool SvxDoubleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
135 {
136  rVal <<= fVal;
137  return true;
138 }
139 
140 bool SvxDoubleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
141 {
142  return rVal >>= fVal;
143 }
144 
146  sal_uInt16 nId) :
147  SfxEnumItem(nId, eOrient)
148 {
149 }
150 
152 {
153  return new SvxChartKindErrorItem(*this);
154 }
155 
157  sal_uInt16 nId) :
158  SfxEnumItem(nId, eOrient)
159 {
160 }
161 
163 {
164  return new SvxChartIndicateItem(*this);
165 }
166 
168  sal_uInt16 nId) :
169  SfxEnumItem(nId, eOrient)
170 {
171 }
172 
174 {
175  return new SvxChartRegressItem(*this);
176 }
177 
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxChartRegress
Definition: chrtitem.hxx:65
SvxChartRegressItem(SvxChartRegress eRegress, sal_uInt16 nId)
Definition: chrtitem.cxx:167
virtual SvxDoubleItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:129
virtual SvxChartIndicateItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:162
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:140
SvxChartIndicateItem(SvxChartIndicate eOrient, sal_uInt16 nId)
Definition: chrtitem.cxx:156
SvxChartTextOrder
Definition: chrtitem.hxx:31
const LocaleDataWrapper * getLocaleData() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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:151
const OUString & getNumDecimalSep() const
virtual SvxChartRegressItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: chrtitem.cxx:173
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:134
SvxChartKindErrorItem(SvxChartKindError, sal_uInt16 nId)
Definition: chrtitem.cxx:145
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
Definition: chrtitem.cxx:67
unsigned char sal_uInt8
MapUnit