LCOV - code coverage report
Current view: top level - sc/source/core/tool - chartarr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 173 254 68.1 %
Date: 2012-08-25 Functions: 8 19 42.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 167 372 44.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "scitems.hxx"
      30                 :            : #include <svl/intitem.hxx>
      31                 :            : #include <svl/zforlist.hxx>
      32                 :            : #include <float.h>              // DBL_MIN
      33                 :            : 
      34                 :            : #include "chartarr.hxx"
      35                 :            : #include "document.hxx"
      36                 :            : #include "rechead.hxx"
      37                 :            : #include "globstr.hrc"
      38                 :            : #include "cell.hxx"
      39                 :            : #include "docoptio.hxx"
      40                 :            : 
      41                 :            : #include <vector>
      42                 :            : 
      43                 :            : using ::std::vector;
      44                 :            : using ::rtl::OUString;
      45                 :            : using ::rtl::OUStringBuffer;
      46                 :            : 
      47                 :            : // -----------------------------------------------------------------------
      48                 :            : 
      49                 :         26 : ScMemChart::ScMemChart(short nCols, short nRows)
      50                 :            : {
      51                 :         26 :     nRowCnt = nRows;
      52                 :         26 :     nColCnt = nCols;
      53                 :         26 :     pData   = new double[nColCnt * nRowCnt];
      54                 :            : 
      55         [ +  - ]:         26 :     if (pData)
      56                 :            :     {
      57                 :         26 :         double *pFill = pData;
      58                 :            : 
      59         [ +  + ]:         94 :         for (short i = 0; i < nColCnt; i++)
      60         [ +  + ]:        428 :             for (short j = 0; j < nRowCnt; j++)
      61                 :        360 :                 *(pFill ++) = 0.0;
      62                 :            :     }
      63                 :            : 
      64         [ +  + ]:         94 :     pColText = new OUString[nColCnt];
      65         [ +  + ]:        202 :     pRowText = new OUString[nRowCnt];
      66                 :         26 : }
      67                 :            : 
      68                 :         26 : ScMemChart::~ScMemChart()
      69                 :            : {
      70 [ +  - ][ +  + ]:        202 :     delete[] pRowText;
      71 [ +  - ][ +  + ]:         94 :     delete[] pColText;
      72         [ +  - ]:         26 :     delete[] pData;
      73                 :         26 : }
      74                 :            : 
      75                 :            : // -----------------------------------------------------------------------
      76                 :            : 
      77                 :          0 : ScChartArray::ScChartArray( ScDocument* pDoc, SCTAB nTab,
      78                 :            :                     SCCOL nStartColP, SCROW nStartRowP, SCCOL nEndColP, SCROW nEndRowP,
      79                 :            :                     const OUString& rChartName ) :
      80                 :            :         aName( rChartName ),
      81                 :            :         pDocument( pDoc ),
      82                 :            :         aPositioner(pDoc, nTab, nStartColP, nStartRowP, nEndColP, nEndRowP),
      83         [ #  # ]:          0 :         bValid( true )
      84                 :            : {
      85                 :          0 : }
      86                 :            : 
      87                 :         37 : ScChartArray::ScChartArray(
      88                 :            :     ScDocument* pDoc, const ScRangeListRef& rRangeList, const OUString& rChartName ) :
      89                 :            :     aName( rChartName ),
      90                 :            :     pDocument( pDoc ),
      91                 :            :     aPositioner(pDoc, rRangeList),
      92         [ +  - ]:         37 :     bValid( true ) {}
      93                 :            : 
      94                 :          0 : ScChartArray::ScChartArray( const ScChartArray& rArr ) :
      95                 :            :     aName(rArr.aName),
      96                 :            :     pDocument(rArr.pDocument),
      97                 :            :     aPositioner(rArr.aPositioner),
      98         [ #  # ]:          0 :     bValid(rArr.bValid) {}
      99                 :            : 
     100         [ +  - ]:         37 : ScChartArray::~ScChartArray() {}
     101                 :            : 
     102                 :          0 : bool ScChartArray::operator==(const ScChartArray& rCmp) const
     103                 :            : {
     104                 :          0 :     return aPositioner == rCmp.aPositioner
     105 [ #  # ][ #  # ]:          0 :         && aName == rCmp.aName;
     106                 :            : }
     107                 :            : 
     108                 :            : #ifdef _MSC_VER
     109                 :            : #pragma optimize("",off)
     110                 :            : #endif
     111                 :            : 
     112                 :         26 : ScMemChart* ScChartArray::CreateMemChart()
     113                 :            : {
     114                 :         26 :     ScRangeListRef aRangeListRef(GetRangeList());
     115         [ +  - ]:         26 :     size_t nCount = aRangeListRef->size();
     116         [ +  + ]:         26 :     if ( nCount > 1 )
     117         [ +  - ]:         10 :         return CreateMemChartMulti();
     118         [ +  - ]:         16 :     else if ( nCount == 1 )
     119                 :            :     {
     120         [ +  - ]:         16 :         ScRange* pR = aRangeListRef->front();
     121         [ -  + ]:         16 :         if ( pR->aStart.Tab() != pR->aEnd.Tab() )
     122         [ #  # ]:          0 :             return CreateMemChartMulti();
     123                 :            :         else
     124         [ +  - ]:         16 :             return CreateMemChartSingle();
     125                 :            :     }
     126                 :            :     else
     127 [ #  # ][ +  - ]:         26 :         return CreateMemChartMulti();   // kann 0 Range besser ab als Single
     128                 :            : }
     129                 :            : 
     130                 :         16 : ScMemChart* ScChartArray::CreateMemChartSingle()
     131                 :            : {
     132                 :            :     SCSIZE nCol;
     133                 :            :     SCSIZE nRow;
     134                 :            : 
     135                 :            :         //
     136                 :            :         //  wirkliche Groesse (ohne versteckte Zeilen/Spalten)
     137                 :            :         //
     138                 :            : 
     139         [ +  + ]:         16 :     SCCOL nColAdd = HasRowHeaders() ? 1 : 0;
     140         [ +  + ]:         16 :     SCROW nRowAdd = HasColHeaders() ? 1 : 0;
     141                 :            : 
     142                 :            :     SCCOL nCol1;
     143                 :            :     SCROW nRow1;
     144                 :            :     SCTAB nTab1;
     145                 :            :     SCCOL nCol2;
     146                 :            :     SCROW nRow2;
     147                 :            :     SCTAB nTab2;
     148                 :         16 :     ScRangeListRef aRangeListRef(GetRangeList());
     149         [ +  - ]:         16 :     aRangeListRef->front()->GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
     150                 :            : 
     151                 :         16 :     SCCOL nStrCol = nCol1;      // fuer Beschriftung merken
     152                 :         16 :     SCROW nStrRow = nRow1;
     153                 :            :     // Skip hidden columns.
     154                 :            :     // TODO: make use of last column value once implemented.
     155                 :         16 :     SCCOL nLastCol = -1;
     156 [ +  - ][ -  + ]:         16 :     while (pDocument->ColHidden(nCol1, nTab1, NULL, &nLastCol))
     157                 :          0 :         ++nCol1;
     158                 :            : 
     159                 :            :     // Skip hidden rows.
     160                 :         16 :     SCROW nLastRow = -1;
     161 [ +  - ][ -  + ]:         16 :     if (pDocument->RowHidden(nRow1, nTab1, NULL, &nLastRow))
     162                 :          0 :         nRow1 = nLastRow + 1;
     163                 :            : 
     164                 :            :     // falls alles hidden ist, bleibt die Beschriftung am Anfang
     165         [ +  - ]:         16 :     if ( nCol1 <= nCol2 )
     166                 :            :     {
     167                 :         16 :         nStrCol = nCol1;
     168                 :         16 :         nCol1 = sal::static_int_cast<SCCOL>( nCol1 + nColAdd );
     169                 :            :     }
     170         [ +  - ]:         16 :     if ( nRow1 <= nRow2 )
     171                 :            :     {
     172                 :         16 :         nStrRow = nRow1;
     173                 :         16 :         nRow1 = sal::static_int_cast<SCROW>( nRow1 + nRowAdd );
     174                 :            :     }
     175                 :            : 
     176         [ +  - ]:         16 :     SCSIZE nTotalCols = ( nCol1 <= nCol2 ? nCol2 - nCol1 + 1 : 0 );
     177         [ +  - ]:         16 :     vector<SCCOL> aCols;
     178         [ +  - ]:         16 :     aCols.reserve(nTotalCols);
     179         [ +  + ]:         72 :     for (SCSIZE i=0; i<nTotalCols; i++)
     180                 :            :     {
     181                 :         56 :         SCCOL nThisCol = sal::static_int_cast<SCCOL>(nCol1+i);
     182 [ +  - ][ +  - ]:         56 :         if (!pDocument->ColHidden(nThisCol, nTab1, NULL, &nLastCol))
     183         [ +  - ]:         56 :             aCols.push_back(nThisCol);
     184                 :            :     }
     185                 :         16 :     SCSIZE nColCount = aCols.size();
     186                 :            : 
     187         [ +  - ]:         16 :     SCSIZE nTotalRows = ( nRow1 <= nRow2 ? nRow2 - nRow1 + 1 : 0 );
     188         [ +  - ]:         16 :     vector<SCROW> aRows;
     189         [ +  - ]:         16 :     aRows.reserve(nTotalRows);
     190         [ +  - ]:         16 :     if (nRow1 <= nRow2)
     191                 :            :     {
     192                 :            :         // Get all visible rows between nRow1 and nRow2.
     193                 :         16 :         SCROW nThisRow = nRow1;
     194         [ +  + ]:         80 :         while (nThisRow <= nRow2)
     195                 :            :         {
     196 [ +  - ][ -  + ]:         64 :             if (pDocument->RowHidden(nThisRow, nTab1, NULL, &nLastRow))
     197                 :          0 :                 nThisRow = nLastRow;
     198                 :            :             else
     199         [ +  - ]:         64 :                 aRows.push_back(nThisRow);
     200                 :         64 :             ++nThisRow;
     201                 :            :         }
     202                 :            :     }
     203                 :         16 :     SCSIZE nRowCount = aRows.size();
     204                 :            : 
     205                 :            :     // May happen at least with more than 32k rows.
     206 [ -  + ][ +  - ]:         16 :     if (nColCount > SHRT_MAX || nRowCount > SHRT_MAX)
     207                 :            :     {
     208                 :          0 :         nColCount = 0;
     209                 :          0 :         nRowCount = 0;
     210                 :            :     }
     211                 :            : 
     212                 :         16 :     bool bValidData = true;
     213         [ -  + ]:         16 :     if ( !nColCount )
     214                 :            :     {
     215                 :          0 :         bValidData = false;
     216                 :          0 :         nColCount = 1;
     217         [ #  # ]:          0 :         aCols.push_back(nStrCol);
     218                 :            :     }
     219         [ -  + ]:         16 :     if ( !nRowCount )
     220                 :            :     {
     221                 :          0 :         bValidData = false;
     222                 :          0 :         nRowCount = 1;
     223         [ #  # ]:          0 :         aRows.push_back(nStrRow);
     224                 :            :     }
     225                 :            : 
     226                 :            :         //
     227                 :            :         //  Daten
     228                 :            :         //
     229                 :            : 
     230                 :            :     ScMemChart* pMemChart = new ScMemChart(
     231 [ +  - ][ +  - ]:         16 :             static_cast<short>(nColCount), static_cast<short>(nRowCount) );
     232         [ +  - ]:         16 :     if (pMemChart)
     233                 :            :     {
     234         [ +  - ]:         16 :         if ( bValidData )
     235                 :            :         {
     236         [ +  - ]:         16 :             bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
     237                 :            :             ScBaseCell* pCell;
     238         [ +  + ]:         72 :             for (nCol=0; nCol<nColCount; nCol++)
     239                 :            :             {
     240         [ +  + ]:        280 :                 for (nRow=0; nRow<nRowCount; nRow++)
     241                 :            :                 {
     242                 :        224 :                     double nVal = DBL_MIN;      // Hack fuer Chart, um leere Zellen zu erkennen
     243                 :            : 
     244 [ +  - ][ +  - ]:        224 :                     pDocument->GetCell( aCols[nCol], aRows[nRow], nTab1, pCell );
                 [ +  - ]
     245         [ +  + ]:        224 :                     if (pCell)
     246                 :            :                     {
     247                 :        113 :                         CellType eType = pCell->GetCellType();
     248         [ +  + ]:        113 :                         if (eType == CELLTYPE_VALUE)
     249                 :            :                         {
     250                 :        111 :                             nVal = ((ScValueCell*)pCell)->GetValue();
     251 [ #  # ][ -  + ]:        111 :                             if ( bCalcAsShown && nVal != 0.0 )
     252                 :            :                             {
     253                 :            :                                 sal_uInt32 nFormat;
     254         [ #  # ]:          0 :                                 pDocument->GetNumberFormat( aCols[nCol],
     255 [ #  # ][ #  # ]:          0 :                                     aRows[nRow], nTab1, nFormat );
     256         [ #  # ]:          0 :                                 nVal = pDocument->RoundValueAsShown( nVal, nFormat );
     257                 :            :                             }
     258                 :            :                         }
     259         [ -  + ]:          2 :                         else if (eType == CELLTYPE_FORMULA)
     260                 :            :                         {
     261         [ #  # ]:          0 :                             ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
     262 [ #  # ][ #  # ]:          0 :                             if ( (pFCell->GetErrCode() == 0) && pFCell->IsValue() )
         [ #  # ][ #  # ]
                 [ #  # ]
     263         [ #  # ]:          0 :                                 nVal = pFCell->GetValue();
     264                 :            :                         }
     265                 :            :                     }
     266                 :        224 :                     pMemChart->SetData(static_cast<short>(nCol), static_cast<short>(nRow), nVal);
     267                 :            :                 }
     268                 :            :             }
     269                 :            :         }
     270                 :            :         else
     271                 :            :         {
     272                 :            :             //! Flag, dass Daten ungueltig ??
     273                 :            : 
     274         [ #  # ]:          0 :             for (nCol=0; nCol<nColCount; nCol++)
     275         [ #  # ]:          0 :                 for (nRow=0; nRow<nRowCount; nRow++)
     276                 :          0 :                     pMemChart->SetData( static_cast<short>(nCol), static_cast<short>(nRow), DBL_MIN );
     277                 :            :         }
     278                 :            : 
     279                 :            :         //
     280                 :            :         //  Spalten-Header
     281                 :            :         //
     282                 :            : 
     283         [ +  + ]:         72 :         for (nCol=0; nCol<nColCount; nCol++)
     284                 :            :         {
     285                 :         56 :             OUString aString, aColStr;
     286         [ +  + ]:         56 :             if (HasColHeaders())
     287 [ +  - ][ +  - ]:         24 :                 pDocument->GetString( aCols[nCol], nStrRow, nTab1, aString );
     288         [ +  + ]:         56 :             if (aString.isEmpty())
     289                 :            :             {
     290                 :         53 :                 OUStringBuffer aBuf;
     291 [ +  - ][ +  - ]:         53 :                 aBuf.append(ScGlobal::GetRscString(STR_COLUMN));
                 [ +  - ]
     292         [ +  - ]:         53 :                 aBuf.append(sal_Unicode(' '));
     293                 :            : 
     294         [ +  - ]:         53 :                 ScAddress aPos( aCols[ nCol ], 0, 0 );
     295         [ +  - ]:         53 :                 aPos.Format( aColStr, SCA_VALID_COL, NULL );
     296         [ +  - ]:         53 :                 aBuf.append(aColStr);
     297                 :            : 
     298         [ +  - ]:         53 :                 aString = aBuf.makeStringAndClear();
     299                 :            :             }
     300                 :         56 :             pMemChart->SetColText( static_cast<short>(nCol), aString);
     301                 :         56 :         }
     302                 :            : 
     303                 :            :         //
     304                 :            :         //  Zeilen-Header
     305                 :            :         //
     306                 :            : 
     307         [ +  + ]:         80 :         for (nRow=0; nRow<nRowCount; nRow++)
     308                 :            :         {
     309                 :         64 :             OUString aString;
     310         [ +  + ]:         64 :             if (HasRowHeaders())
     311                 :            :             {
     312         [ +  - ]:         32 :                 ScAddress aAddr( nStrCol, aRows[nRow], nTab1 );
     313 [ +  - ][ +  - ]:         32 :                 pDocument->GetString( nStrCol, aRows[nRow], nTab1, aString );
     314                 :            :             }
     315         [ +  + ]:         64 :             if (aString.isEmpty())
     316                 :            :             {
     317                 :         52 :                 OUStringBuffer aBuf;
     318 [ +  - ][ +  - ]:         52 :                 aBuf.append(ScGlobal::GetRscString(STR_ROW));
                 [ +  - ]
     319         [ +  - ]:         52 :                 aBuf.append(sal_Unicode(' '));
     320 [ +  - ][ +  - ]:         52 :                 aBuf.append(static_cast<sal_Int32>(aRows[nRow]+1));
     321         [ +  - ]:         52 :                 aString = aBuf.makeStringAndClear();
     322                 :            :             }
     323                 :         64 :             pMemChart->SetRowText( static_cast<short>(nRow), aString);
     324                 :         64 :         }
     325                 :            :     }
     326                 :            : 
     327         [ +  - ]:         16 :     return pMemChart;
     328                 :            : }
     329                 :            : 
     330                 :         10 : ScMemChart* ScChartArray::CreateMemChartMulti()
     331                 :            : {
     332                 :         10 :     SCSIZE nColCount = GetPositionMap()->GetColCount();
     333                 :         10 :     SCSIZE nRowCount = GetPositionMap()->GetRowCount();
     334                 :            : 
     335                 :            :     // May happen at least with more than 32k rows.
     336 [ -  + ][ +  - ]:         10 :     if (nColCount > SHRT_MAX || nRowCount > SHRT_MAX)
     337                 :            :     {
     338                 :          0 :         nColCount = 0;
     339                 :          0 :         nRowCount = 0;
     340                 :            :     }
     341                 :            : 
     342                 :         10 :     bool bValidData = true;
     343         [ -  + ]:         10 :     if ( !nColCount )
     344                 :            :     {
     345                 :          0 :         bValidData = false;
     346                 :          0 :         nColCount = 1;
     347                 :            :     }
     348         [ -  + ]:         10 :     if ( !nRowCount )
     349                 :            :     {
     350                 :          0 :         bValidData = false;
     351                 :          0 :         nRowCount = 1;
     352                 :            :     }
     353                 :            : 
     354                 :            :     //
     355                 :            :     //  Daten
     356                 :            :     //
     357                 :            : 
     358                 :            :     ScMemChart* pMemChart = new ScMemChart(
     359         [ +  - ]:         10 :             static_cast<short>(nColCount), static_cast<short>(nRowCount) );
     360         [ +  - ]:         10 :     if (pMemChart)
     361                 :            :     {
     362                 :         10 :         SCSIZE nCol = 0;
     363                 :         10 :         SCSIZE nRow = 0;
     364                 :         10 :         bool bCalcAsShown = pDocument->GetDocOptions().IsCalcAsShown();
     365                 :         10 :         sal_uLong nIndex = 0;
     366         [ +  - ]:         10 :         if (bValidData)
     367                 :            :         {
     368         [ +  + ]:         22 :             for ( nCol = 0; nCol < nColCount; nCol++ )
     369                 :            :             {
     370         [ +  + ]:        148 :                 for ( nRow = 0; nRow < nRowCount; nRow++, nIndex++ )
     371                 :            :                 {
     372                 :        136 :                     double nVal = DBL_MIN;      // Hack fuer Chart, um leere Zellen zu erkennen
     373         [ +  - ]:        136 :                     const ScAddress* pPos = GetPositionMap()->GetPosition( nIndex );
     374         [ +  - ]:        136 :                     if ( pPos )
     375                 :            :                     {   // sonst: Luecke
     376         [ +  - ]:        136 :                         ScBaseCell* pCell = pDocument->GetCell( *pPos );
     377         [ +  + ]:        136 :                         if (pCell)
     378                 :            :                         {
     379                 :        117 :                             CellType eType = pCell->GetCellType();
     380         [ +  + ]:        117 :                             if (eType == CELLTYPE_VALUE)
     381                 :            :                             {
     382                 :         70 :                                 nVal = ((ScValueCell*)pCell)->GetValue();
     383 [ #  # ][ -  + ]:         70 :                                 if ( bCalcAsShown && nVal != 0.0 )
     384                 :            :                                 {
     385         [ #  # ]:          0 :                                     sal_uLong nFormat = pDocument->GetNumberFormat( *pPos );
     386         [ #  # ]:          0 :                                     nVal = pDocument->RoundValueAsShown( nVal, nFormat );
     387                 :            :                                 }
     388                 :            :                             }
     389         [ -  + ]:         47 :                             else if (eType == CELLTYPE_FORMULA)
     390                 :            :                             {
     391         [ #  # ]:          0 :                                 ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
     392 [ #  # ][ #  # ]:          0 :                                 if ( (pFCell->GetErrCode() == 0) && pFCell->IsValue() )
         [ #  # ][ #  # ]
                 [ #  # ]
     393         [ #  # ]:          0 :                                     nVal = pFCell->GetValue();
     394                 :            :                             }
     395                 :            :                         }
     396                 :            :                     }
     397                 :        136 :                     pMemChart->SetData(static_cast<short>(nCol), static_cast<short>(nRow), nVal);
     398                 :            :                 }
     399                 :            :             }
     400                 :            :         }
     401                 :            :         else
     402                 :            :         {
     403         [ #  # ]:          0 :             for ( nRow = 0; nRow < nRowCount; nRow++, nIndex++ )
     404                 :            :             {
     405                 :          0 :                 double nVal = DBL_MIN;      // Hack fuer Chart, um leere Zellen zu erkennen
     406         [ #  # ]:          0 :                 const ScAddress* pPos = GetPositionMap()->GetPosition( nIndex );
     407         [ #  # ]:          0 :                 if ( pPos )
     408                 :            :                 {   // sonst: Luecke
     409         [ #  # ]:          0 :                     ScBaseCell* pCell = pDocument->GetCell( *pPos );
     410         [ #  # ]:          0 :                     if (pCell)
     411                 :            :                     {
     412                 :          0 :                         CellType eType = pCell->GetCellType();
     413         [ #  # ]:          0 :                         if (eType == CELLTYPE_VALUE)
     414                 :            :                         {
     415                 :          0 :                             nVal = ((ScValueCell*)pCell)->GetValue();
     416 [ #  # ][ #  # ]:          0 :                             if ( bCalcAsShown && nVal != 0.0 )
     417                 :            :                             {
     418         [ #  # ]:          0 :                                 sal_uLong nFormat = pDocument->GetNumberFormat( *pPos );
     419         [ #  # ]:          0 :                                 nVal = pDocument->RoundValueAsShown( nVal, nFormat );
     420                 :            :                             }
     421                 :            :                         }
     422         [ #  # ]:          0 :                         else if (eType == CELLTYPE_FORMULA)
     423                 :            :                         {
     424         [ #  # ]:          0 :                             ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
     425 [ #  # ][ #  # ]:          0 :                             if ( (pFCell->GetErrCode() == 0) && pFCell->IsValue() )
         [ #  # ][ #  # ]
                 [ #  # ]
     426         [ #  # ]:          0 :                                 nVal = pFCell->GetValue();
     427                 :            :                         }
     428                 :            :                     }
     429                 :            :                 }
     430                 :          0 :                 pMemChart->SetData(static_cast<short>(nCol), static_cast<short>(nRow), nVal);
     431                 :            :             }
     432                 :            :         }
     433                 :            : 
     434                 :            : //2do: Beschriftung bei Luecken
     435                 :            : 
     436                 :            :         //
     437                 :            :         //  Spalten-Header
     438                 :            :         //
     439                 :            : 
     440                 :         10 :         SCCOL nPosCol = 0;
     441         [ +  + ]:         22 :         for ( nCol = 0; nCol < nColCount; nCol++ )
     442                 :            :         {
     443                 :         12 :             OUString aString, aColStr;
     444         [ +  - ]:         12 :             const ScAddress* pPos = GetPositionMap()->GetColHeaderPosition( static_cast<SCCOL>(nCol) );
     445 [ +  - ][ +  + ]:         12 :             if ( HasColHeaders() && pPos )
                 [ +  + ]
     446                 :            :                 pDocument->GetString(
     447         [ +  - ]:          8 :                     pPos->Col(), pPos->Row(), pPos->Tab(), aString );
     448                 :            : 
     449         [ +  + ]:         12 :             if (aString.isEmpty())
     450                 :            :             {
     451 [ +  - ][ +  - ]:          4 :                 OUStringBuffer aBuf(ScGlobal::GetRscString(STR_COLUMN));
                 [ +  - ]
     452         [ +  - ]:          4 :                 aBuf.append(sal_Unicode(' '));
     453         [ +  - ]:          4 :                 if ( pPos )
     454                 :          4 :                     nPosCol = pPos->Col() + 1;
     455                 :            :                 else
     456                 :          0 :                     nPosCol++;
     457                 :          4 :                 ScAddress aPos( nPosCol - 1, 0, 0 );
     458         [ +  - ]:          4 :                 aPos.Format( aColStr, SCA_VALID_COL, NULL );
     459         [ +  - ]:          4 :                 aBuf.append(aColStr);
     460         [ +  - ]:          4 :                 aString = aBuf.makeStringAndClear();
     461                 :            :             }
     462                 :         12 :             pMemChart->SetColText( static_cast<short>(nCol), aString);
     463                 :         12 :         }
     464                 :            : 
     465                 :            :         //
     466                 :            :         //  Zeilen-Header
     467                 :            :         //
     468                 :            : 
     469                 :         10 :         SCROW nPosRow = 0;
     470         [ +  + ]:        122 :         for ( nRow = 0; nRow < nRowCount; nRow++ )
     471                 :            :         {
     472                 :        112 :             OUString aString;
     473         [ +  - ]:        112 :             const ScAddress* pPos = GetPositionMap()->GetRowHeaderPosition( nRow );
     474 [ +  - ][ +  + ]:        112 :             if ( HasRowHeaders() && pPos )
                 [ +  + ]
     475                 :            :             {
     476                 :            :                 pDocument->GetString(
     477         [ +  - ]:         88 :                     pPos->Col(), pPos->Row(), pPos->Tab(), aString );
     478                 :            :             }
     479         [ +  + ]:        112 :             if (aString.isEmpty())
     480                 :            :             {
     481 [ +  - ][ +  - ]:         24 :                 OUStringBuffer aBuf(ScGlobal::GetRscString(STR_ROW));
                 [ +  - ]
     482         [ +  - ]:         24 :                 aBuf.append(sal_Unicode(' '));
     483         [ +  - ]:         24 :                 if ( pPos )
     484                 :         24 :                     nPosRow = pPos->Row() + 1;
     485                 :            :                 else
     486                 :          0 :                     nPosRow++;
     487         [ +  - ]:         24 :                 aBuf.append(static_cast<sal_Int32>(nPosRow));
     488         [ +  - ]:         24 :                 aString = aBuf.makeStringAndClear();
     489                 :            :             }
     490                 :        112 :             pMemChart->SetRowText( static_cast<short>(nRow), aString);
     491                 :        112 :         }
     492                 :            :     }
     493                 :            : 
     494                 :         10 :     return pMemChart;
     495                 :            : }
     496                 :            : 
     497                 :            : #ifdef _MSC_VER
     498                 :            : #pragma optimize("",on)
     499                 :            : #endif
     500                 :            : 
     501                 :       1781 : ScChartCollection::ScChartCollection() {}
     502                 :          0 : ScChartCollection::ScChartCollection(const ScChartCollection& r) :
     503                 :          0 :     maData(r.maData) {}
     504                 :            : 
     505                 :          0 : void ScChartCollection::push_back(ScChartArray* p)
     506                 :            : {
     507                 :          0 :     maData.push_back(p);
     508                 :          0 : }
     509                 :            : 
     510                 :          0 : void ScChartCollection::clear()
     511                 :            : {
     512                 :          0 :     maData.clear();
     513                 :          0 : }
     514                 :            : 
     515                 :          0 : size_t ScChartCollection::size() const
     516                 :            : {
     517                 :          0 :     return maData.size();
     518                 :            : }
     519                 :            : 
     520                 :          0 : bool ScChartCollection::empty() const
     521                 :            : {
     522                 :          0 :     return maData.empty();
     523                 :            : }
     524                 :            : 
     525                 :          0 : ScChartArray* ScChartCollection::operator[](size_t nIndex)
     526                 :            : {
     527         [ #  # ]:          0 :     if (maData.size() <= nIndex)
     528                 :          0 :         return NULL;
     529                 :          0 :     return &maData[nIndex];
     530                 :            : }
     531                 :            : 
     532                 :          0 : const ScChartArray* ScChartCollection::operator[](size_t nIndex) const
     533                 :            : {
     534         [ #  # ]:          0 :     if (maData.size() <= nIndex)
     535                 :          0 :         return NULL;
     536                 :          0 :     return &maData[nIndex];
     537                 :            : }
     538                 :            : 
     539                 :          0 : bool ScChartCollection::operator==(const ScChartCollection& rCmp) const
     540                 :            : {
     541                 :          0 :     return maData == rCmp.maData;
     542                 :            : }
     543                 :            : 
     544                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10