tdf#164627 docx export: consolidate getWordCompatibilityMode()
[LibreOffice.git] / svx / source / items / chrtitem.cxx
blob11a299cfab01888deb708d14956d3d64e9bebfd8
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 <rtl/math.hxx>
21 #include <unotools/intlwrapper.hxx>
22 #include <unotools/localedatawrapper.hxx>
23 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
24 #include <o3tl/hash_combine.hxx>
25 #include <svx/chrtitem.hxx>
27 using namespace ::com::sun::star;
30 SfxPoolItem* SvxDoubleItem::CreateDefault() { return new SvxDoubleItem(0.0, TypedWhichId<SvxDoubleItem>(0));}
32 SvxChartTextOrderItem::SvxChartTextOrderItem(SvxChartTextOrder eOrder,
33 TypedWhichId<SvxChartTextOrderItem> nId) :
34 SfxEnumItem(nId, SfxItemType::SvxChartTextOrderItemType, eOrder)
38 SvxChartTextOrderItem* SvxChartTextOrderItem::Clone(SfxItemPool* /*pPool*/) const
40 return new SvxChartTextOrderItem(*this);
43 bool SvxChartTextOrderItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
45 // the order of the two enums is not equal, so a mapping is required
46 css::chart::ChartAxisArrangeOrderType eAO;
47 SvxChartTextOrder eOrder( GetValue());
49 switch( eOrder )
51 case SvxChartTextOrder::SideBySide:
52 eAO = css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE; break;
53 case SvxChartTextOrder::UpDown:
54 eAO = css::chart::ChartAxisArrangeOrderType_STAGGER_ODD; break;
55 case SvxChartTextOrder::DownUp:
56 eAO = css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN; break;
57 case SvxChartTextOrder::Auto:
58 eAO = css::chart::ChartAxisArrangeOrderType_AUTO; break;
61 rVal <<= eAO;
63 return true;
67 bool SvxChartTextOrderItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
69 // the order of the two enums is not equal, so a mapping is required
70 css::chart::ChartAxisArrangeOrderType eAO;
71 SvxChartTextOrder eOrder;
73 if(!(rVal >>= eAO))
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 );
82 switch( eAO )
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;
96 SetValue( eOrder );
98 return true;
101 SvxDoubleItem::SvxDoubleItem(double fValue, TypedWhichId<SvxDoubleItem> nId) :
102 SfxPoolItem(nId, SfxItemType::SvxDoubleItemType),
103 fVal(fValue)
107 SvxDoubleItem::SvxDoubleItem(const SvxDoubleItem& rItem) :
108 SfxPoolItem(rItem),
109 fVal(rItem.fVal)
113 bool SvxDoubleItem::GetPresentation
114 ( SfxItemPresentation /*ePresentation*/, MapUnit /*eCoreMetric*/,
115 MapUnit /*ePresentationMetric*/, OUString& rText,
116 const IntlWrapper& rIntlWrapper) const
118 rText = ::rtl::math::doubleToUString( fVal, rtl_math_StringFormat_E, 4,
119 rIntlWrapper.getLocaleData()->getNumDecimalSep()[0], true );
120 return true;
123 bool SvxDoubleItem::operator == (const SfxPoolItem& rItem) const
125 assert(SfxPoolItem::operator==(rItem));
126 return static_cast<const SvxDoubleItem&>(rItem).fVal == fVal;
129 SvxDoubleItem* SvxDoubleItem::Clone(SfxItemPool* /*pPool*/) const
131 return new SvxDoubleItem(*this);
134 bool SvxDoubleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
136 rVal <<= fVal;
137 return true;
140 bool SvxDoubleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
142 ASSERT_CHANGE_REFCOUNTED_ITEM;
143 return rVal >>= fVal;
146 SvxChartKindErrorItem::SvxChartKindErrorItem(SvxChartKindError eOrient,
147 TypedWhichId<SvxChartKindErrorItem> nId) :
148 SfxEnumItem(nId, SfxItemType::SvxChartKindErrorItemType, eOrient)
152 SvxChartKindErrorItem* SvxChartKindErrorItem::Clone(SfxItemPool* /*pPool*/) const
154 return new SvxChartKindErrorItem(*this);
157 SvxChartIndicateItem::SvxChartIndicateItem(SvxChartIndicate eOrient,
158 TypedWhichId<SvxChartIndicateItem> nId) :
159 SfxEnumItem(nId, SfxItemType::SvxChartIndicateItemType, eOrient)
163 SvxChartIndicateItem* SvxChartIndicateItem::Clone(SfxItemPool* /*pPool*/) const
165 return new SvxChartIndicateItem(*this);
168 SvxChartRegressItem::SvxChartRegressItem(SvxChartRegress eOrient,
169 TypedWhichId<SvxChartRegressItem> nId) :
170 SfxEnumItem(nId, SfxItemType::SvxChartRegressItemType, eOrient)
174 SvxChartRegressItem* SvxChartRegressItem::Clone(SfxItemPool* /*pPool*/) const
176 return new SvxChartRegressItem(*this);
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */