1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <tools/stream.hxx>
21 #include <basic/sbxvar.hxx>
22 #if defined UNX && !defined LINUX
25 #include <rtl/math.hxx>
26 #include <unotools/intlwrapper.hxx>
27 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
32 #include "svx/chrtitem.hxx"
34 using namespace ::rtl
;
35 using namespace ::com::sun::star
;
36 // -----------------------------------------------------------------------
38 TYPEINIT1_FACTORY(SvxChartStyleItem
, SfxEnumItem
, new SvxChartStyleItem(CHSTYLE_2D_LINE
, 0));
39 TYPEINIT1(SvxChartDataDescrItem
, SfxEnumItem
);
40 TYPEINIT1(SvxChartTextOrderItem
, SfxEnumItem
);
41 TYPEINIT1(SvxChartTextOrientItem
, SfxEnumItem
);
42 TYPEINIT1(SvxChartIndicateItem
, SfxEnumItem
);
43 TYPEINIT1(SvxChartKindErrorItem
, SfxEnumItem
);
44 TYPEINIT1(SvxChartRegressItem
, SfxEnumItem
);
45 TYPEINIT1_FACTORY(SvxDoubleItem
, SfxPoolItem
, new SvxDoubleItem(0.0, 0));
47 /*************************************************************************
51 *************************************************************************/
53 SvxChartStyleItem::SvxChartStyleItem(SvxChartStyle eStyle
, sal_uInt16 nId
) :
54 SfxEnumItem(nId
, (sal_uInt16
)eStyle
)
58 // -----------------------------------------------------------------------
60 SvxChartStyleItem::SvxChartStyleItem(SvStream
& rIn
, sal_uInt16 nId
) :
65 // -----------------------------------------------------------------------
67 SfxPoolItem
* SvxChartStyleItem::Clone(SfxItemPool
* /*pPool*/) const
69 return new SvxChartStyleItem(*this);
72 // -----------------------------------------------------------------------
74 SfxPoolItem
* SvxChartStyleItem::Create(SvStream
& rIn
, sal_uInt16
/*nVer*/) const
76 return new SvxChartStyleItem(rIn
, Which());
79 /*************************************************************************
81 |* SvxChartDataDescrItem
83 *************************************************************************/
85 SvxChartDataDescrItem::SvxChartDataDescrItem(SvStream
& rIn
, sal_uInt16 nId
) :
90 // -----------------------------------------------------------------------
92 SfxPoolItem
* SvxChartDataDescrItem::Clone(SfxItemPool
* /*pPool*/) const
94 return new SvxChartDataDescrItem(*this);
97 // -----------------------------------------------------------------------
99 SfxPoolItem
* SvxChartDataDescrItem::Create(SvStream
& rIn
, sal_uInt16
/*nVer*/) const
101 return new SvxChartDataDescrItem(rIn
, Which());
104 /*************************************************************************
106 |* SvxChartTextOrderItem
108 *************************************************************************/
110 SvxChartTextOrderItem::SvxChartTextOrderItem(SvxChartTextOrder eOrder
,
112 SfxEnumItem(nId
, (sal_uInt16
)eOrder
)
116 // -----------------------------------------------------------------------
118 SvxChartTextOrderItem::SvxChartTextOrderItem(SvStream
& rIn
, sal_uInt16 nId
) :
119 SfxEnumItem(nId
, rIn
)
123 // -----------------------------------------------------------------------
125 SfxPoolItem
* SvxChartTextOrderItem::Clone(SfxItemPool
* /*pPool*/) const
127 return new SvxChartTextOrderItem(*this);
130 // -----------------------------------------------------------------------
132 SfxPoolItem
* SvxChartTextOrderItem::Create(SvStream
& rIn
, sal_uInt16
/*nVer*/) const
134 return new SvxChartTextOrderItem(rIn
, Which());
137 // -----------------------------------------------------------------------
139 bool SvxChartTextOrderItem::QueryValue( ::com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
141 // the order of the two enums is not equal, so a mapping is required
142 ::com::sun::star::chart::ChartAxisArrangeOrderType eAO
;
143 SvxChartTextOrder
eOrder( GetValue());
147 case CHTXTORDER_SIDEBYSIDE
:
148 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE
; break;
149 case CHTXTORDER_UPDOWN
:
150 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD
; break;
151 case CHTXTORDER_DOWNUP
:
152 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN
; break;
153 case CHTXTORDER_AUTO
:
154 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO
; break;
162 // -----------------------------------------------------------------------
164 bool SvxChartTextOrderItem::PutValue( const ::com::sun::star::uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
166 // the order of the two enums is not equal, so a mapping is required
167 ::com::sun::star::chart::ChartAxisArrangeOrderType eAO
;
168 SvxChartTextOrder eOrder
;
172 // also try an int (for Basic)
176 eAO
= static_cast< ::com::sun::star::chart::ChartAxisArrangeOrderType
>( nAO
);
181 case ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE
:
182 eOrder
= CHTXTORDER_SIDEBYSIDE
; break;
183 case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD
:
184 eOrder
= CHTXTORDER_UPDOWN
; break;
185 case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN
:
186 eOrder
= CHTXTORDER_DOWNUP
; break;
187 case ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO
:
188 eOrder
= CHTXTORDER_AUTO
; break;
193 SetValue( (sal_uInt16
)eOrder
);
198 /*************************************************************************
200 |* SvxChartTextOrientItem
202 *************************************************************************/
204 SvxChartTextOrientItem::SvxChartTextOrientItem(SvStream
& rIn
, sal_uInt16 nId
) :
205 SfxEnumItem(nId
, rIn
)
209 // -----------------------------------------------------------------------
211 SfxPoolItem
* SvxChartTextOrientItem::Clone(SfxItemPool
* /*pPool*/) const
213 return new SvxChartTextOrientItem(*this);
216 // -----------------------------------------------------------------------
218 SfxPoolItem
* SvxChartTextOrientItem::Create(SvStream
& rIn
, sal_uInt16
/*nVer*/) const
220 return new SvxChartTextOrientItem(rIn
, Which());
223 /*************************************************************************
227 *************************************************************************/
229 SvxDoubleItem::SvxDoubleItem(double fValue
, sal_uInt16 nId
) :
235 // -----------------------------------------------------------------------
237 SvxDoubleItem::SvxDoubleItem(const SvxDoubleItem
& rItem
) :
243 // -----------------------------------------------------------------------
245 XubString
SvxDoubleItem::GetValueText() const
247 OString
aOStr( rtl::math::doubleToString( fVal
, rtl_math_StringFormat_E
, 4, '.', false ) );
248 return String( aOStr
.getStr(), (sal_uInt16
)aOStr
.getLength() );
251 // -----------------------------------------------------------------------
253 SfxItemPresentation
SvxDoubleItem::GetPresentation
254 ( SfxItemPresentation
/*ePresentation*/, SfxMapUnit
/*eCoreMetric*/,
255 SfxMapUnit
/*ePresentationMetric*/, OUString
& rText
,
256 const IntlWrapper
* pIntlWrapper
) const
258 DBG_ASSERT( pIntlWrapper
, "SvxDoubleItem::GetPresentation: no IntlWrapper" );
261 rText
= ::rtl::math::doubleToUString( fVal
, rtl_math_StringFormat_E
, 4,
262 pIntlWrapper
->getLocaleData()->getNumDecimalSep()[0], true );
265 rText
= GetValueText();
266 return SFX_ITEM_PRESENTATION_NAMELESS
;
269 // -----------------------------------------------------------------------
271 int SvxDoubleItem::operator == (const SfxPoolItem
& rItem
) const
273 return (((SvxDoubleItem
&)rItem
).fVal
== fVal
);
276 // -----------------------------------------------------------------------
278 SfxPoolItem
* SvxDoubleItem::Clone(SfxItemPool
* /*pPool*/) const
280 return new SvxDoubleItem(*this);
283 // -----------------------------------------------------------------------
285 SfxPoolItem
* SvxDoubleItem::Create(SvStream
& rIn
, sal_uInt16
/*nVersion*/) const
289 return new SvxDoubleItem(_fVal
, Which());
292 // -----------------------------------------------------------------------
294 SvStream
& SvxDoubleItem::Store(SvStream
& rOut
, sal_uInt16
/*nItemVersion*/) const
300 // -----------------------------------------------------------------------
302 double SvxDoubleItem::GetMin() const
307 // -----------------------------------------------------------------------
309 double SvxDoubleItem::GetMax() const
314 // -----------------------------------------------------------------------
316 SfxFieldUnit
SvxDoubleItem::GetUnit() const
318 return SFX_FUNIT_NONE
;
324 // -----------------------------------------------------------------------
325 bool SvxDoubleItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
331 // -----------------------------------------------------------------------
332 bool SvxDoubleItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
334 return rVal
>>= fVal
;
339 /*************************************************************************
341 |* SvxChartKindErrorItem
343 *************************************************************************/
345 SvxChartKindErrorItem::SvxChartKindErrorItem(SvxChartKindError eOrient
,
347 SfxEnumItem(nId
, (sal_uInt16
)eOrient
)
351 // -----------------------------------------------------------------------
353 SvxChartKindErrorItem::SvxChartKindErrorItem(SvStream
& rIn
, sal_uInt16 nId
) :
354 SfxEnumItem(nId
, rIn
)
358 // -----------------------------------------------------------------------
360 SfxPoolItem
* SvxChartKindErrorItem::Clone(SfxItemPool
* /*pPool*/) const
362 return new SvxChartKindErrorItem(*this);
365 // -----------------------------------------------------------------------
367 SfxPoolItem
* SvxChartKindErrorItem::Create(SvStream
& rIn
, sal_uInt16
/*nVer*/) const
369 return new SvxChartKindErrorItem(rIn
, Which());
372 // -----------------------------------------------------------------------
374 sal_uInt16
SvxChartKindErrorItem::GetVersion (sal_uInt16 nFileFormatVersion
) const
376 return (nFileFormatVersion
== SOFFICE_FILEFORMAT_31
)
381 /*************************************************************************
383 |* SvxChartIndicateItem
385 *************************************************************************/
387 SvxChartIndicateItem::SvxChartIndicateItem(SvxChartIndicate eOrient
,
389 SfxEnumItem(nId
, (sal_uInt16
)eOrient
)
393 // -----------------------------------------------------------------------
395 SvxChartIndicateItem::SvxChartIndicateItem(SvStream
& rIn
, sal_uInt16 nId
) :
396 SfxEnumItem(nId
, rIn
)
400 // -----------------------------------------------------------------------
402 SfxPoolItem
* SvxChartIndicateItem::Clone(SfxItemPool
* /*pPool*/) const
404 return new SvxChartIndicateItem(*this);
407 // -----------------------------------------------------------------------
409 SfxPoolItem
* SvxChartIndicateItem::Create(SvStream
& rIn
, sal_uInt16
/*nVer*/) const
411 return new SvxChartIndicateItem(rIn
, Which());
414 // -----------------------------------------------------------------------
416 sal_uInt16
SvxChartIndicateItem::GetVersion (sal_uInt16 nFileFormatVersion
) const
418 return (nFileFormatVersion
== SOFFICE_FILEFORMAT_31
)
423 /*************************************************************************
425 |* SvxChartRegressItem
427 *************************************************************************/
429 SvxChartRegressItem::SvxChartRegressItem(SvxChartRegress eOrient
,
431 SfxEnumItem(nId
, (sal_uInt16
)eOrient
)
435 // -----------------------------------------------------------------------
437 SvxChartRegressItem::SvxChartRegressItem(SvStream
& rIn
, sal_uInt16 nId
) :
438 SfxEnumItem(nId
, rIn
)
442 // -----------------------------------------------------------------------
444 SfxPoolItem
* SvxChartRegressItem::Clone(SfxItemPool
* /*pPool*/) const
446 return new SvxChartRegressItem(*this);
449 // -----------------------------------------------------------------------
451 SfxPoolItem
* SvxChartRegressItem::Create(SvStream
& rIn
, sal_uInt16
/*nVer*/) const
453 return new SvxChartRegressItem(rIn
, Which());
456 // -----------------------------------------------------------------------
458 sal_uInt16
SvxChartRegressItem::GetVersion (sal_uInt16 nFileFormatVersion
) const
460 return (nFileFormatVersion
== SOFFICE_FILEFORMAT_31
)
466 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */