LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/items - chrtitem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 136 17.6 %
Date: 2013-07-09 Functions: 24 84 28.6 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <tools/stream.hxx>
      21             : #include <basic/sbxvar.hxx>
      22             : #if defined UNX && !defined LINUX
      23             : #include <wchar.h>
      24             : #endif
      25             : #include <rtl/math.hxx>
      26             : #include <unotools/intlwrapper.hxx>
      27             : #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
      28             : 
      29             : #include <stdio.h>
      30             : #include <float.h>
      31             : 
      32             : #include "svx/chrtitem.hxx"
      33             : 
      34             : using namespace ::rtl;
      35             : using namespace ::com::sun::star;
      36             : // -----------------------------------------------------------------------
      37             : 
      38         267 : TYPEINIT1_FACTORY(SvxChartStyleItem, SfxEnumItem, new SvxChartStyleItem(CHSTYLE_2D_LINE, 0));
      39           0 : TYPEINIT1(SvxChartDataDescrItem, SfxEnumItem);
      40         267 : TYPEINIT1(SvxChartTextOrderItem, SfxEnumItem);
      41           0 : TYPEINIT1(SvxChartTextOrientItem, SfxEnumItem);
      42         267 : TYPEINIT1(SvxChartIndicateItem, SfxEnumItem);
      43         267 : TYPEINIT1(SvxChartKindErrorItem, SfxEnumItem);
      44         267 : TYPEINIT1(SvxChartRegressItem, SfxEnumItem);
      45        3279 : TYPEINIT1_FACTORY(SvxDoubleItem, SfxPoolItem, new SvxDoubleItem(0.0, 0));
      46             : 
      47             : /*************************************************************************
      48             : |*
      49             : |*  SvxChartStyleItem
      50             : |*
      51             : *************************************************************************/
      52             : 
      53          89 : SvxChartStyleItem::SvxChartStyleItem(SvxChartStyle eStyle, sal_uInt16 nId) :
      54          89 :     SfxEnumItem(nId, (sal_uInt16)eStyle)
      55             : {
      56          89 : }
      57             : 
      58             : // -----------------------------------------------------------------------
      59             : 
      60           0 : SvxChartStyleItem::SvxChartStyleItem(SvStream& rIn, sal_uInt16 nId) :
      61           0 :     SfxEnumItem(nId, rIn)
      62             : {
      63           0 : }
      64             : 
      65             : // -----------------------------------------------------------------------
      66             : 
      67           0 : SfxPoolItem* SvxChartStyleItem::Clone(SfxItemPool* /*pPool*/) const
      68             : {
      69           0 :     return new SvxChartStyleItem(*this);
      70             : }
      71             : 
      72             : // -----------------------------------------------------------------------
      73             : 
      74           0 : SfxPoolItem* SvxChartStyleItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const
      75             : {
      76           0 :     return new SvxChartStyleItem(rIn, Which());
      77             : }
      78             : 
      79             : /*************************************************************************
      80             : |*
      81             : |*  SvxChartDataDescrItem
      82             : |*
      83             : *************************************************************************/
      84             : 
      85           0 : SvxChartDataDescrItem::SvxChartDataDescrItem(SvStream& rIn, sal_uInt16 nId) :
      86           0 :     SfxEnumItem(nId, rIn)
      87             : {
      88           0 : }
      89             : 
      90             : // -----------------------------------------------------------------------
      91             : 
      92           0 : SfxPoolItem* SvxChartDataDescrItem::Clone(SfxItemPool* /*pPool*/) const
      93             : {
      94           0 :     return new SvxChartDataDescrItem(*this);
      95             : }
      96             : 
      97             : // -----------------------------------------------------------------------
      98             : 
      99           0 : SfxPoolItem* SvxChartDataDescrItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const
     100             : {
     101           0 :     return new SvxChartDataDescrItem(rIn, Which());
     102             : }
     103             : 
     104             : /*************************************************************************
     105             : |*
     106             : |*  SvxChartTextOrderItem
     107             : |*
     108             : *************************************************************************/
     109             : 
     110          89 : SvxChartTextOrderItem::SvxChartTextOrderItem(SvxChartTextOrder eOrder,
     111             :                                              sal_uInt16 nId) :
     112          89 :     SfxEnumItem(nId, (sal_uInt16)eOrder)
     113             : {
     114          89 : }
     115             : 
     116             : // -----------------------------------------------------------------------
     117             : 
     118           0 : SvxChartTextOrderItem::SvxChartTextOrderItem(SvStream& rIn, sal_uInt16 nId) :
     119           0 :     SfxEnumItem(nId, rIn)
     120             : {
     121           0 : }
     122             : 
     123             : // -----------------------------------------------------------------------
     124             : 
     125           0 : SfxPoolItem* SvxChartTextOrderItem::Clone(SfxItemPool* /*pPool*/) const
     126             : {
     127           0 :     return new SvxChartTextOrderItem(*this);
     128             : }
     129             : 
     130             : // -----------------------------------------------------------------------
     131             : 
     132           0 : SfxPoolItem* SvxChartTextOrderItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const
     133             : {
     134           0 :     return new SvxChartTextOrderItem(rIn, Which());
     135             : }
     136             : 
     137             : // -----------------------------------------------------------------------
     138             : 
     139           0 : bool SvxChartTextOrderItem::QueryValue( ::com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     140             : {
     141             :     // the order of the two enums is not equal, so a mapping is required
     142             :     ::com::sun::star::chart::ChartAxisArrangeOrderType eAO;
     143           0 :     SvxChartTextOrder eOrder( GetValue());
     144             : 
     145           0 :     switch( eOrder )
     146             :     {
     147             :         case CHTXTORDER_SIDEBYSIDE:
     148           0 :             eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE; break;
     149             :         case CHTXTORDER_UPDOWN:
     150           0 :             eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD; break;
     151             :         case CHTXTORDER_DOWNUP:
     152           0 :             eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN; break;
     153             :         case CHTXTORDER_AUTO:
     154           0 :             eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO; break;
     155             :     }
     156             : 
     157           0 :     rVal <<= eAO;
     158             : 
     159           0 :     return true;
     160             : }
     161             : 
     162             : // -----------------------------------------------------------------------
     163             : 
     164           0 : bool SvxChartTextOrderItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     165             : {
     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;
     169             : 
     170           0 :     if(!(rVal >>= eAO))
     171             :     {
     172             :         // also try an int (for Basic)
     173           0 :         sal_Int32 nAO = 0;
     174           0 :         if(!(rVal >>= nAO))
     175           0 :             return false;
     176           0 :         eAO = static_cast< ::com::sun::star::chart::ChartAxisArrangeOrderType >( nAO );
     177             :     }
     178             : 
     179           0 :     switch( eAO )
     180             :     {
     181             :         case ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE:
     182           0 :             eOrder = CHTXTORDER_SIDEBYSIDE; break;
     183             :         case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD:
     184           0 :             eOrder = CHTXTORDER_UPDOWN; break;
     185             :         case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN:
     186           0 :             eOrder = CHTXTORDER_DOWNUP; break;
     187             :         case ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO:
     188           0 :             eOrder = CHTXTORDER_AUTO; break;
     189             :         default:
     190           0 :             return false;
     191             :     }
     192             : 
     193           0 :     SetValue( (sal_uInt16)eOrder );
     194             : 
     195           0 :     return true;
     196             : }
     197             : 
     198             : /*************************************************************************
     199             : |*
     200             : |*  SvxChartTextOrientItem
     201             : |*
     202             : *************************************************************************/
     203             : 
     204           0 : SvxChartTextOrientItem::SvxChartTextOrientItem(SvStream& rIn, sal_uInt16 nId) :
     205           0 :     SfxEnumItem(nId, rIn)
     206             : {
     207           0 : }
     208             : 
     209             : // -----------------------------------------------------------------------
     210             : 
     211           0 : SfxPoolItem* SvxChartTextOrientItem::Clone(SfxItemPool* /*pPool*/) const
     212             : {
     213           0 :     return new SvxChartTextOrientItem(*this);
     214             : }
     215             : 
     216             : // -----------------------------------------------------------------------
     217             : 
     218           0 : SfxPoolItem* SvxChartTextOrientItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const
     219             : {
     220           0 :     return new SvxChartTextOrientItem(rIn, Which());
     221             : }
     222             : 
     223             : /*************************************************************************
     224             : |*
     225             : |*  SvxDoubleItem
     226             : |*
     227             : *************************************************************************/
     228             : 
     229        1068 : SvxDoubleItem::SvxDoubleItem(double fValue, sal_uInt16 nId) :
     230             :     SfxPoolItem(nId),
     231        1068 :     fVal(fValue)
     232             : {
     233        1068 : }
     234             : 
     235             : // -----------------------------------------------------------------------
     236             : 
     237           0 : SvxDoubleItem::SvxDoubleItem(const SvxDoubleItem& rItem) :
     238             :     SfxPoolItem(rItem),
     239           0 :     fVal(rItem.fVal)
     240             : {
     241           0 : }
     242             : 
     243             : // -----------------------------------------------------------------------
     244             : 
     245           0 : OUString SvxDoubleItem::GetValueText() const
     246             : {
     247           0 :     return rtl::math::doubleToUString( fVal, rtl_math_StringFormat_E, 4, '.', false );
     248             : }
     249             : 
     250             : // -----------------------------------------------------------------------
     251             : 
     252           0 : SfxItemPresentation SvxDoubleItem::GetPresentation
     253             :             ( SfxItemPresentation /*ePresentation*/, SfxMapUnit /*eCoreMetric*/,
     254             :               SfxMapUnit /*ePresentationMetric*/, OUString& rText,
     255             :               const IntlWrapper * pIntlWrapper) const
     256             : {
     257             :     DBG_ASSERT( pIntlWrapper, "SvxDoubleItem::GetPresentation: no IntlWrapper" );
     258           0 :     if ( pIntlWrapper )
     259             :     {
     260           0 :         rText = ::rtl::math::doubleToUString( fVal, rtl_math_StringFormat_E, 4,
     261           0 :             pIntlWrapper->getLocaleData()->getNumDecimalSep()[0], true );
     262             :     }
     263             :     else
     264           0 :         rText = GetValueText();
     265           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
     266             : }
     267             : 
     268             : // -----------------------------------------------------------------------
     269             : 
     270           0 : int SvxDoubleItem::operator == (const SfxPoolItem& rItem) const
     271             : {
     272           0 :     return (((SvxDoubleItem&)rItem).fVal == fVal);
     273             : }
     274             : 
     275             : // -----------------------------------------------------------------------
     276             : 
     277           0 : SfxPoolItem* SvxDoubleItem::Clone(SfxItemPool* /*pPool*/) const
     278             : {
     279           0 :     return new SvxDoubleItem(*this);
     280             : }
     281             : 
     282             : // -----------------------------------------------------------------------
     283             : 
     284           0 : SfxPoolItem* SvxDoubleItem::Create(SvStream& rIn, sal_uInt16 /*nVersion*/) const
     285             : {
     286             :     double _fVal;
     287           0 :     rIn >> _fVal;
     288           0 :     return new SvxDoubleItem(_fVal, Which());
     289             : }
     290             : 
     291             : // -----------------------------------------------------------------------
     292             : 
     293           0 : SvStream& SvxDoubleItem::Store(SvStream& rOut, sal_uInt16 /*nItemVersion*/) const
     294             : {
     295           0 :     rOut << fVal;
     296           0 :     return rOut;
     297             : }
     298             : 
     299             : // -----------------------------------------------------------------------
     300             : 
     301           0 : double SvxDoubleItem::GetMin() const
     302             : {
     303           0 :     return DBL_MIN;
     304             : }
     305             : 
     306             : // -----------------------------------------------------------------------
     307             : 
     308           0 : double SvxDoubleItem::GetMax() const
     309             : {
     310           0 :     return DBL_MAX;
     311             : }
     312             : 
     313             : // -----------------------------------------------------------------------
     314             : 
     315           0 : SfxFieldUnit SvxDoubleItem::GetUnit() const
     316             : {
     317           0 :     return SFX_FUNIT_NONE;
     318             : }
     319             : 
     320             : 
     321             : 
     322             : 
     323             : // -----------------------------------------------------------------------
     324           0 : bool SvxDoubleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     325             : {
     326           0 :     rVal <<= fVal;
     327           0 :     return true;
     328             : }
     329             : 
     330             : // -----------------------------------------------------------------------
     331           0 : bool SvxDoubleItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     332             : {
     333           0 :     return rVal >>= fVal;
     334             : }
     335             : 
     336             : 
     337             : 
     338             : /*************************************************************************
     339             : |*
     340             : |*  SvxChartKindErrorItem
     341             : |*
     342             : *************************************************************************/
     343             : 
     344          89 : SvxChartKindErrorItem::SvxChartKindErrorItem(SvxChartKindError eOrient,
     345             :                                                sal_uInt16 nId) :
     346          89 :     SfxEnumItem(nId, (sal_uInt16)eOrient)
     347             : {
     348          89 : }
     349             : 
     350             : // -----------------------------------------------------------------------
     351             : 
     352           0 : SvxChartKindErrorItem::SvxChartKindErrorItem(SvStream& rIn, sal_uInt16 nId) :
     353           0 :     SfxEnumItem(nId, rIn)
     354             : {
     355           0 : }
     356             : 
     357             : // -----------------------------------------------------------------------
     358             : 
     359           0 : SfxPoolItem* SvxChartKindErrorItem::Clone(SfxItemPool* /*pPool*/) const
     360             : {
     361           0 :     return new SvxChartKindErrorItem(*this);
     362             : }
     363             : 
     364             : // -----------------------------------------------------------------------
     365             : 
     366           0 : SfxPoolItem* SvxChartKindErrorItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const
     367             : {
     368           0 :     return new SvxChartKindErrorItem(rIn, Which());
     369             : }
     370             : 
     371             : // -----------------------------------------------------------------------
     372             : 
     373           0 : sal_uInt16 SvxChartKindErrorItem::GetVersion (sal_uInt16 nFileFormatVersion) const
     374             : {
     375             :     return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
     376             :                ? USHRT_MAX
     377           0 :                : 0;
     378             : }
     379             : 
     380             : /*************************************************************************
     381             : |*
     382             : |*  SvxChartIndicateItem
     383             : |*
     384             : *************************************************************************/
     385             : 
     386          89 : SvxChartIndicateItem::SvxChartIndicateItem(SvxChartIndicate eOrient,
     387             :                                                sal_uInt16 nId) :
     388          89 :     SfxEnumItem(nId, (sal_uInt16)eOrient)
     389             : {
     390          89 : }
     391             : 
     392             : // -----------------------------------------------------------------------
     393             : 
     394           0 : SvxChartIndicateItem::SvxChartIndicateItem(SvStream& rIn, sal_uInt16 nId) :
     395           0 :     SfxEnumItem(nId, rIn)
     396             : {
     397           0 : }
     398             : 
     399             : // -----------------------------------------------------------------------
     400             : 
     401           0 : SfxPoolItem* SvxChartIndicateItem::Clone(SfxItemPool* /*pPool*/) const
     402             : {
     403           0 :     return new SvxChartIndicateItem(*this);
     404             : }
     405             : 
     406             : // -----------------------------------------------------------------------
     407             : 
     408           0 : SfxPoolItem* SvxChartIndicateItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const
     409             : {
     410           0 :     return new SvxChartIndicateItem(rIn, Which());
     411             : }
     412             : 
     413             : // -----------------------------------------------------------------------
     414             : 
     415           0 : sal_uInt16 SvxChartIndicateItem::GetVersion (sal_uInt16 nFileFormatVersion) const
     416             : {
     417             :     return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
     418             :                ? USHRT_MAX
     419           0 :                : 0;
     420             : }
     421             : 
     422             : /*************************************************************************
     423             : |*
     424             : |*  SvxChartRegressItem
     425             : |*
     426             : *************************************************************************/
     427             : 
     428          89 : SvxChartRegressItem::SvxChartRegressItem(SvxChartRegress eOrient,
     429             :                                                sal_uInt16 nId) :
     430          89 :     SfxEnumItem(nId, (sal_uInt16)eOrient)
     431             : {
     432          89 : }
     433             : 
     434             : // -----------------------------------------------------------------------
     435             : 
     436           0 : SvxChartRegressItem::SvxChartRegressItem(SvStream& rIn, sal_uInt16 nId) :
     437           0 :     SfxEnumItem(nId, rIn)
     438             : {
     439           0 : }
     440             : 
     441             : // -----------------------------------------------------------------------
     442             : 
     443           0 : SfxPoolItem* SvxChartRegressItem::Clone(SfxItemPool* /*pPool*/) const
     444             : {
     445           0 :     return new SvxChartRegressItem(*this);
     446             : }
     447             : 
     448             : // -----------------------------------------------------------------------
     449             : 
     450           0 : SfxPoolItem* SvxChartRegressItem::Create(SvStream& rIn, sal_uInt16 /*nVer*/) const
     451             : {
     452           0 :     return new SvxChartRegressItem(rIn, Which());
     453             : }
     454             : 
     455             : // -----------------------------------------------------------------------
     456             : 
     457           0 : sal_uInt16 SvxChartRegressItem::GetVersion (sal_uInt16 nFileFormatVersion) const
     458             : {
     459             :     return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
     460             :                ? USHRT_MAX
     461           0 :                : 0;
     462             : }
     463             : 
     464             : 
     465             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10