1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chrtitem.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/stream.hxx>
36 #ifndef __SBX_SBXVARIABLE_HXX
37 #include <basic/sbxvar.hxx>
39 #if defined UNX && !defined LINUX
42 #include <rtl/math.hxx>
43 #include <unotools/intlwrapper.hxx>
44 #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
48 #include <rtl/math.hxx>
50 #include "chrtitem.hxx"
52 using namespace ::rtl
;
53 using namespace ::com::sun::star
;
54 // -----------------------------------------------------------------------
56 TYPEINIT1_FACTORY(SvxChartStyleItem
, SfxEnumItem
, new SvxChartStyleItem(CHSTYLE_2D_LINE
, 0));
57 TYPEINIT1(SvxChartDataDescrItem
, SfxEnumItem
);
58 TYPEINIT1(SvxChartLegendPosItem
, SfxEnumItem
);
59 TYPEINIT1(SvxChartTextOrderItem
, SfxEnumItem
);
60 TYPEINIT1(SvxChartTextOrientItem
, SfxEnumItem
);
61 TYPEINIT1(SvxChartIndicateItem
, SfxEnumItem
);
62 TYPEINIT1(SvxChartKindErrorItem
, SfxEnumItem
);
63 TYPEINIT1(SvxChartRegressItem
, SfxEnumItem
);
64 TYPEINIT1_FACTORY(SvxDoubleItem
, SfxPoolItem
, new SvxDoubleItem(0.0, 0));
66 /*************************************************************************
70 *************************************************************************/
72 SvxChartStyleItem::SvxChartStyleItem(SvxChartStyle eStyle
, USHORT nId
) :
73 SfxEnumItem(nId
, (USHORT
)eStyle
)
77 // -----------------------------------------------------------------------
79 SvxChartStyleItem::SvxChartStyleItem(SvStream
& rIn
, USHORT nId
) :
84 // -----------------------------------------------------------------------
86 SfxPoolItem
* SvxChartStyleItem::Clone(SfxItemPool
* /*pPool*/) const
88 return new SvxChartStyleItem(*this);
91 // -----------------------------------------------------------------------
93 SfxPoolItem
* SvxChartStyleItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
95 return new SvxChartStyleItem(rIn
, Which());
98 /*************************************************************************
100 |* SvxChartDataDescrItem
102 *************************************************************************/
104 SvxChartDataDescrItem::SvxChartDataDescrItem(SvxChartDataDescr eDataDescr
,
106 SfxEnumItem(nId
, (USHORT
)eDataDescr
)
110 // -----------------------------------------------------------------------
112 SvxChartDataDescrItem::SvxChartDataDescrItem(SvStream
& rIn
, USHORT nId
) :
113 SfxEnumItem(nId
, rIn
)
117 // -----------------------------------------------------------------------
119 SfxPoolItem
* SvxChartDataDescrItem::Clone(SfxItemPool
* /*pPool*/) const
121 return new SvxChartDataDescrItem(*this);
124 // -----------------------------------------------------------------------
126 SfxPoolItem
* SvxChartDataDescrItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
128 return new SvxChartDataDescrItem(rIn
, Which());
131 /*************************************************************************
133 |* SvxChartLegendPosItem
135 *************************************************************************/
137 SvxChartLegendPosItem::SvxChartLegendPosItem(SvxChartLegendPos eLegendPos
,
139 SfxEnumItem(nId
, (USHORT
)eLegendPos
)
143 // -----------------------------------------------------------------------
145 SvxChartLegendPosItem::SvxChartLegendPosItem(SvStream
& rIn
, USHORT nId
) :
146 SfxEnumItem(nId
, rIn
)
150 // -----------------------------------------------------------------------
152 SfxPoolItem
* SvxChartLegendPosItem::Clone(SfxItemPool
* /*pPool*/) const
154 return new SvxChartLegendPosItem(*this);
157 // -----------------------------------------------------------------------
159 SfxPoolItem
* SvxChartLegendPosItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
161 return new SvxChartLegendPosItem(rIn
, Which());
164 /*************************************************************************
166 |* SvxChartTextOrderItem
168 *************************************************************************/
170 SvxChartTextOrderItem::SvxChartTextOrderItem(SvxChartTextOrder eOrder
,
172 SfxEnumItem(nId
, (USHORT
)eOrder
)
176 // -----------------------------------------------------------------------
178 SvxChartTextOrderItem::SvxChartTextOrderItem(SvStream
& rIn
, USHORT nId
) :
179 SfxEnumItem(nId
, rIn
)
183 // -----------------------------------------------------------------------
185 SfxPoolItem
* SvxChartTextOrderItem::Clone(SfxItemPool
* /*pPool*/) const
187 return new SvxChartTextOrderItem(*this);
190 // -----------------------------------------------------------------------
192 SfxPoolItem
* SvxChartTextOrderItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
194 return new SvxChartTextOrderItem(rIn
, Which());
197 // -----------------------------------------------------------------------
199 sal_Bool
SvxChartTextOrderItem::QueryValue( ::com::sun::star::uno::Any
& rVal
, BYTE
/*nMemberId*/ ) const
201 // the order of the two enums is not equal, so a mapping is required
202 ::com::sun::star::chart::ChartAxisArrangeOrderType eAO
;
203 SvxChartTextOrder
eOrder( GetValue());
207 case CHTXTORDER_SIDEBYSIDE
:
208 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE
; break;
209 case CHTXTORDER_UPDOWN
:
210 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD
; break;
211 case CHTXTORDER_DOWNUP
:
212 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN
; break;
213 case CHTXTORDER_AUTO
:
214 eAO
= ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO
; break;
222 // -----------------------------------------------------------------------
224 sal_Bool
SvxChartTextOrderItem::PutValue( const ::com::sun::star::uno::Any
& rVal
, BYTE
/*nMemberId*/ )
226 // the order of the two enums is not equal, so a mapping is required
227 ::com::sun::star::chart::ChartAxisArrangeOrderType eAO
;
228 SvxChartTextOrder eOrder
;
232 // also try an int (for Basic)
236 eAO
= static_cast< ::com::sun::star::chart::ChartAxisArrangeOrderType
>( nAO
);
241 case ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE
:
242 eOrder
= CHTXTORDER_SIDEBYSIDE
; break;
243 case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD
:
244 eOrder
= CHTXTORDER_UPDOWN
; break;
245 case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN
:
246 eOrder
= CHTXTORDER_DOWNUP
; break;
247 case ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO
:
248 eOrder
= CHTXTORDER_AUTO
; break;
253 SetValue( (USHORT
)eOrder
);
258 /*************************************************************************
260 |* SvxChartTextOrientItem
262 *************************************************************************/
264 SvxChartTextOrientItem::SvxChartTextOrientItem(SvxChartTextOrient eOrient
,
266 SfxEnumItem(nId
, (USHORT
)eOrient
)
270 // -----------------------------------------------------------------------
272 SvxChartTextOrientItem::SvxChartTextOrientItem(SvStream
& rIn
, USHORT nId
) :
273 SfxEnumItem(nId
, rIn
)
277 // -----------------------------------------------------------------------
279 SfxPoolItem
* SvxChartTextOrientItem::Clone(SfxItemPool
* /*pPool*/) const
281 return new SvxChartTextOrientItem(*this);
284 // -----------------------------------------------------------------------
286 SfxPoolItem
* SvxChartTextOrientItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
288 return new SvxChartTextOrientItem(rIn
, Which());
291 /*************************************************************************
295 *************************************************************************/
297 SvxDoubleItem::SvxDoubleItem(double fValue
, USHORT nId
) :
303 // -----------------------------------------------------------------------
305 SvxDoubleItem::SvxDoubleItem(SvStream
& rIn
, USHORT nId
) :
311 // -----------------------------------------------------------------------
313 SvxDoubleItem::SvxDoubleItem(const SvxDoubleItem
& rItem
) :
319 // -----------------------------------------------------------------------
321 XubString
SvxDoubleItem::GetValueText() const
323 rtl::OString
aOStr( rtl::math::doubleToString( fVal
, rtl_math_StringFormat_E
, 4, '.', false ) );
324 return String( aOStr
.getStr(), (sal_uInt16
)aOStr
.getLength() );
327 // -----------------------------------------------------------------------
329 SfxItemPresentation
SvxDoubleItem::GetPresentation
330 ( SfxItemPresentation
/*ePresentation*/, SfxMapUnit
/*eCoreMetric*/,
331 SfxMapUnit
/*ePresentationMetric*/, XubString
& rText
,
332 const IntlWrapper
* pIntlWrapper
) const
334 DBG_ASSERT( pIntlWrapper
, "SvxDoubleItem::GetPresentation: no IntlWrapper" );
337 rText
= ::rtl::math::doubleToUString( fVal
, rtl_math_StringFormat_E
, 4,
338 pIntlWrapper
->getLocaleData()->getNumDecimalSep().GetChar(0), true );
341 rText
= GetValueText();
342 return SFX_ITEM_PRESENTATION_NAMELESS
;
345 // -----------------------------------------------------------------------
347 int SvxDoubleItem::operator == (const SfxPoolItem
& rItem
) const
349 return (((SvxDoubleItem
&)rItem
).fVal
== fVal
);
352 // -----------------------------------------------------------------------
354 SfxPoolItem
* SvxDoubleItem::Clone(SfxItemPool
* /*pPool*/) const
356 return new SvxDoubleItem(*this);
359 // -----------------------------------------------------------------------
361 SfxPoolItem
* SvxDoubleItem::Create(SvStream
& rIn
, USHORT
/*nVersion*/) const
365 return new SvxDoubleItem(_fVal
, Which());
368 // -----------------------------------------------------------------------
370 SvStream
& SvxDoubleItem::Store(SvStream
& rOut
, USHORT
/*nItemVersion*/) const
376 // -----------------------------------------------------------------------
378 double SvxDoubleItem::GetMin() const
383 // -----------------------------------------------------------------------
385 double SvxDoubleItem::GetMax() const
390 // -----------------------------------------------------------------------
392 SfxFieldUnit
SvxDoubleItem::GetUnit() const
394 return SFX_FUNIT_NONE
;
400 // -----------------------------------------------------------------------
401 sal_Bool
SvxDoubleItem::QueryValue( uno::Any
& rVal
, BYTE
/*nMemberId*/ ) const
407 // -----------------------------------------------------------------------
408 sal_Bool
SvxDoubleItem::PutValue( const uno::Any
& rVal
, BYTE
/*nMemberId*/ )
410 return rVal
>>= fVal
;
415 /*************************************************************************
417 |* SvxChartKindErrorItem
419 *************************************************************************/
421 SvxChartKindErrorItem::SvxChartKindErrorItem(SvxChartKindError eOrient
,
423 SfxEnumItem(nId
, (USHORT
)eOrient
)
427 // -----------------------------------------------------------------------
429 SvxChartKindErrorItem::SvxChartKindErrorItem(SvStream
& rIn
, USHORT nId
) :
430 SfxEnumItem(nId
, rIn
)
434 // -----------------------------------------------------------------------
436 SfxPoolItem
* SvxChartKindErrorItem::Clone(SfxItemPool
* /*pPool*/) const
438 return new SvxChartKindErrorItem(*this);
441 // -----------------------------------------------------------------------
443 SfxPoolItem
* SvxChartKindErrorItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
445 return new SvxChartKindErrorItem(rIn
, Which());
448 // -----------------------------------------------------------------------
450 USHORT
SvxChartKindErrorItem::GetVersion (USHORT nFileFormatVersion
) const
452 return (nFileFormatVersion
== SOFFICE_FILEFORMAT_31
)
457 /*************************************************************************
459 |* SvxChartIndicateItem
461 *************************************************************************/
463 SvxChartIndicateItem::SvxChartIndicateItem(SvxChartIndicate eOrient
,
465 SfxEnumItem(nId
, (USHORT
)eOrient
)
469 // -----------------------------------------------------------------------
471 SvxChartIndicateItem::SvxChartIndicateItem(SvStream
& rIn
, USHORT nId
) :
472 SfxEnumItem(nId
, rIn
)
476 // -----------------------------------------------------------------------
478 SfxPoolItem
* SvxChartIndicateItem::Clone(SfxItemPool
* /*pPool*/) const
480 return new SvxChartIndicateItem(*this);
483 // -----------------------------------------------------------------------
485 SfxPoolItem
* SvxChartIndicateItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
487 return new SvxChartIndicateItem(rIn
, Which());
490 // -----------------------------------------------------------------------
492 USHORT
SvxChartIndicateItem::GetVersion (USHORT nFileFormatVersion
) const
494 return (nFileFormatVersion
== SOFFICE_FILEFORMAT_31
)
499 /*************************************************************************
501 |* SvxChartRegressItem
503 *************************************************************************/
505 SvxChartRegressItem::SvxChartRegressItem(SvxChartRegress eOrient
,
507 SfxEnumItem(nId
, (USHORT
)eOrient
)
511 // -----------------------------------------------------------------------
513 SvxChartRegressItem::SvxChartRegressItem(SvStream
& rIn
, USHORT nId
) :
514 SfxEnumItem(nId
, rIn
)
518 // -----------------------------------------------------------------------
520 SfxPoolItem
* SvxChartRegressItem::Clone(SfxItemPool
* /*pPool*/) const
522 return new SvxChartRegressItem(*this);
525 // -----------------------------------------------------------------------
527 SfxPoolItem
* SvxChartRegressItem::Create(SvStream
& rIn
, USHORT
/*nVer*/) const
529 return new SvxChartRegressItem(rIn
, Which());
532 // -----------------------------------------------------------------------
534 USHORT
SvxChartRegressItem::GetVersion (USHORT nFileFormatVersion
) const
536 return (nFileFormatVersion
== SOFFICE_FILEFORMAT_31
)