summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriha/tbe <iha@openoffice.org>2012-07-27 17:26:37 +0200
committerMichael Stahl <mstahl@redhat.com>2012-07-27 17:26:37 +0200
commit0df48990763fd7bae00a586d0c34526fe13aadd1 (patch)
treeed890809be1e3fa0019f91f123db26ca8a70e01d
parentScRangeFindList is unused (diff)
downloadbinfilter-0df48990763fd7bae00a586d0c34526fe13aadd1.tar.gz
binfilter-0df48990763fd7bae00a586d0c34526fe13aadd1.zip
sds chart binfilter import
-rw-r--r--binfilter/bf_sch/source/core/sch_calculat.cxx12
-rw-r--r--binfilter/bf_sch/source/core/sch_chartdoc.cxx5
-rw-r--r--binfilter/bf_sch/source/core/sch_chaxis.cxx54
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmod2a.cxx81
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmod3d.cxx26
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmode1.cxx48
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmode2.cxx64
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmode3.cxx43
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmode4.cxx78
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmode7.cxx4
-rw-r--r--binfilter/bf_sch/source/core/sch_chtmode9.cxx131
-rw-r--r--binfilter/bf_sch/source/core/sch_globfunc.cxx244
-rw-r--r--binfilter/bf_sch/source/core/sch_memchrt.cxx403
-rw-r--r--binfilter/inc/bf_sch/arrayhelper.hxx91
-rw-r--r--binfilter/inc/bf_sch/calculat.hxx46
-rw-r--r--binfilter/inc/bf_sch/chtmodel.hxx5
-rw-r--r--binfilter/inc/bf_sch/globfunc.hxx38
-rw-r--r--binfilter/inc/bf_sch/memchrt.hxx178
18 files changed, 810 insertions, 741 deletions
diff --git a/binfilter/bf_sch/source/core/sch_calculat.cxx b/binfilter/bf_sch/source/core/sch_calculat.cxx
index 6e28ea74a..7dc4ccf7d 100644
--- a/binfilter/bf_sch/source/core/sch_calculat.cxx
+++ b/binfilter/bf_sch/source/core/sch_calculat.cxx
@@ -27,13 +27,6 @@
// for performance measurement
#include <rtl/logfile.hxx>
-// Note: Enable the following to skip points in the resulting spline
-// poly-polygon, if they have equal x-values rather than identical points.
-// Unitl now, I think there are situations where the output might differ, if you
-// do so, so it's not enabled by default.
-
-// #define SPLINE_OPTIMIZE_POINTS
-
#include "calculat.hxx"
#include <algorithm>
@@ -187,11 +180,6 @@ using namespace ::std;
// --------------------------------------------------------------------------------
-// Calculation of Splines
-
-
-// ----------------------------------------
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/binfilter/bf_sch/source/core/sch_chartdoc.cxx b/binfilter/bf_sch/source/core/sch_chartdoc.cxx
index fc9ae33c7..618014328 100644
--- a/binfilter/bf_sch/source/core/sch_chartdoc.cxx
+++ b/binfilter/bf_sch/source/core/sch_chartdoc.cxx
@@ -233,6 +233,11 @@ namespace binfilter {
/*N*/
/*N*/ rDoc.LoadAttributes(rIn);
/*N*/ }
+ if( rIn.GetError() != 0 ) //read error
+ {
+ return rIn;//handle error occured maybe in rDoc.LoadAttributes e.g. if memchart could not be read correctly
+ }
+
/*N*/ // <- Basisaufruf
/*N*/
/*N*/ rDoc.GetItemPool().LoadCompleted();
diff --git a/binfilter/bf_sch/source/core/sch_chaxis.cxx b/binfilter/bf_sch/source/core/sch_chaxis.cxx
index 31b043420..09af0009b 100644
--- a/binfilter/bf_sch/source/core/sch_chaxis.cxx
+++ b/binfilter/bf_sch/source/core/sch_chaxis.cxx
@@ -49,6 +49,7 @@
#include <bf_svx/fhgtitem.hxx>
#include <bf_svx/svxids.hrc>
+#include "arrayhelper.hxx"
#include "float.h"
#include "chaxis.hxx"
#include "pairs.hxx"
@@ -124,17 +125,12 @@ namespace binfilter {
/*N*/ };
/*N*/ ChartAxis::~ChartAxis()
/*N*/ {
-/*N*/ if(mpTotal)
-/*N*/ delete [] mpTotal;
-/*N*/
-/*N*/ if(mpColStack)
-/*N*/ delete [] mpColStack;
-/*N*/
+/*N*/ delete [] mpTotal;
+/*N*/ delete [] mpColStack;
/*N*/ delete mpAxisAttr;
/*N*/ mpAxisAttr=NULL;
/*N*/ mpModel=NULL;
-/*N*/ if(mpTextAttr)
-/*N*/ delete mpTextAttr;
+/*N*/ delete mpTextAttr;
/*N*/ }
/*N*/ ChartAxis::ChartAxis(ChartModel* pModel,long nId,long nUId)
@@ -270,14 +266,18 @@ namespace binfilter {
/*N*/ {
/*N*/ if(nSize!=mnTotalSize)
/*N*/ {
-/*N*/ if(mpTotal)
-/*N*/ delete [] mpTotal;
+/*N*/ delete [] mpTotal;
/*N*/ mnTotalSize = nSize;
-/*N*/ mpTotal = new double[mnTotalSize];
+/*N*/ mpTotal = ArrayHelper<double>::create_long_size(mnTotalSize);
+ if(!mpTotal)
+ mnTotalSize=0;
/*N*/ }
/*N*/
-/*N*/ while(nSize--)
-/*N*/ mpTotal[nSize]=0.0;
+ if(mpTotal)
+ {
+/*N*/ while(nSize--)
+/*N*/ mpTotal[nSize]=0.0;
+ }
/*N*/ }
/*N*/ mbTotalAlloc=TRUE;
/*N*/ };
@@ -292,7 +292,9 @@ namespace binfilter {
/*N*/ if(!mbTotalActual)
/*N*/ CreateTotal();
/*N*/
-/*N*/ return mpTotal[n];
+ if( mpTotal && n>=0 && n<mnTotalSize )
+/*N*/ return mpTotal[n];
+ return 10.0;
/*N*/ }
/*N*/ void ChartAxis::CreateTotal()
/*N*/ {
@@ -319,7 +321,7 @@ namespace binfilter {
/*N*/ for(long nRow=0;nRow<nRowCnt;nRow++)
/*N*/ {
/*N*/ nId=((const SfxInt32Item &)(mpModel->GetDataRowAttr(nRow).Get(SCHATTR_AXIS))).GetValue();
-/*N*/ if(nId==mnUId)
+/*N*/ if(nId==mnUId && mpTotal)
/*N*/ {
/*N*/ for(nCol=0;nCol<nColCnt;nCol++)
/*N*/ {
@@ -339,13 +341,13 @@ namespace binfilter {
// Stapeln der Werte je Col (für Liniencharts)
/*N*/ void ChartAxis::InitColStacking(long nColCnt)
/*N*/ {
-/*N*/
-/*N*/
-/*N*/ if(mpColStack)
-/*N*/ delete [] mpColStack;
-/*N*/ mpColStack=new double[nColCnt];
-/*N*/ while(nColCnt--)
-/*N*/ mpColStack[nColCnt]=0.0;//mfOrigin ????;
+/*N*/ delete [] mpColStack;
+/*N*/ mpColStack = ArrayHelper<double>::create_long_size(nColCnt);
+ if(mpColStack)
+ {
+/*N*/ while(nColCnt--)
+/*N*/ mpColStack[nColCnt]=0.0;//mfOrigin ????;
+ }
/*N*/ }
//Stapeln der Werte je Column (Stapeln bei LinienCharts)
/*N*/ double ChartAxis::StackColData(double fData,long nCol,long nColCnt)
@@ -354,8 +356,12 @@ namespace binfilter {
/*N*/ InitColStacking(nColCnt);//falls noch nicht geschehen
/*N*/ mbColStackOK=TRUE;//wird bei Initialise auf FALSE gesetzt
/*N*/
-/*N*/ mpColStack[nCol]+=fData;
-/*N*/ return mpColStack[nCol];
+ if(mpColStack)
+ {
+/*N*/ mpColStack[nCol]+=fData;
+/*N*/ return mpColStack[nCol];
+ }
+ return fData;
/*N*/ }
//Dies Funktion wird u.A. von Initialise gerufen (sehr früh im Buildvorgang)
//Attribute innerer Schleifen (CretaeMarks, etc.) können hier in Variablen
diff --git a/binfilter/bf_sch/source/core/sch_chtmod2a.cxx b/binfilter/bf_sch/source/core/sch_chtmod2a.cxx
index 65411e3bd..2efa41161 100644
--- a/binfilter/bf_sch/source/core/sch_chtmod2a.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmod2a.cxx
@@ -46,6 +46,7 @@
#include "pairs.hxx"
#include "globfunc.hxx"
+#include "arrayhelper.hxx"
#include <bf_svx/xlineit.hxx>
// header for Line
@@ -277,9 +278,9 @@ namespace binfilter {
/*N*/ long nColCnt = GetColCount() ;
/*N*/ long nRowCnt = GetRowCount() ;
/*N*/
-/*N*/ double *pTotal = new double [nColCnt];
-/*N*/ SdrObjList **pRowLists = new SdrObjList* [nRowCnt];
-/*N*/ SdrObjList **pDescrLists = new SdrObjList* [nRowCnt];
+/*N*/ double *pTotal = ArrayHelper<double>::create_long_size(nColCnt);
+/*N*/ SdrObjList **pRowLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+/*N*/ SdrObjList **pDescrLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
/*N*/ DataDescription* pDescription = NULL;
/*N*/ Size aDescrOfs;
/*N*/
@@ -288,7 +289,15 @@ namespace binfilter {
/*N*/ bShowYAxisTitle = FALSE;
/*N*/ bShowZAxisTitle = FALSE;
/*N*/
-/*N*/ SchObjGroup** pDescrGroups=new SchObjGroup*[nRowCnt];
+/*N*/ SchObjGroup** pDescrGroups = ArrayHelper<SchObjGroup*>::create_long_size(nRowCnt);
+ if( !pTotal || !pRowLists || !pDescrLists || !pDescrGroups )
+ {
+ delete[] pTotal;
+ delete[] pRowLists;
+ delete[] pDescrLists;
+ delete[] pDescrGroups;
+ return pGroup;
+ }
/*N*/ for(nRow=0;nRow<nRowCnt;nRow++)
/*N*/ pDescrGroups[nRow]=NULL;
/*N*/
@@ -530,8 +539,14 @@ namespace binfilter {
/*N*/
/*N*/ Create2DBackplane(aRect, *pList, TRUE,CHSTACK_NONE);
/*N*/
-/*N*/ SdrObjList ** pRowLists = new SdrObjList*[nRowCnt];
-/*N*/ SdrObjList ** pStatLists = new SdrObjList*[nRowCnt];
+/*N*/ SdrObjList ** pRowLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+/*N*/ SdrObjList ** pStatLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+ if( !pRowLists || !pStatLists )
+ {
+ delete[] pRowLists;
+ delete[] pStatLists;
+ return pGroup;
+ }
/*N*/ Size aLegendSize (((SvxFontWidthItem &) pLegendAttr->Get (EE_CHAR_FONTWIDTH)).GetWidth (),
/*N*/ ((SvxFontHeightItem &) pLegendAttr->Get (EE_CHAR_FONTHEIGHT)).GetHeight ());
/*N*/
@@ -551,8 +566,6 @@ namespace binfilter {
/*N*/ pStatLists [0] = 0;
/*N*/
/*N*/ XPolygon aPolygon ((unsigned short)nColCnt);
-/*N*/ ::std::vector< ::std::pair< double, double > > aSplinePoints;
-/*N*/ bool bIsSplineChart = ( IsSplineChart() != FALSE );
/*N*/
/*N*/ SfxItemSet aLineAttr(*pItemPool, XATTR_LINE_FIRST, XATTR_LINE_LAST, 0);
/*N*/
@@ -589,7 +602,6 @@ namespace binfilter {
/*N*/ long nPoints = 0;
/*N*/ pLineObject = NULL;
/*N*/
-/*N*/ aSplinePoints.clear();
/*N*/
/*N*/ for (nCol = 0; nCol < nColCnt; nCol++)
/*N*/ {
@@ -617,13 +629,6 @@ namespace binfilter {
/*N*/ }
/*N*/ aPolygon [(USHORT) nPoints].X () = nXPos;
/*N*/ aPolygon [(USHORT) nPoints].Y () = nYPos;
-/*N*/ if( bIsSplineChart )
-/*N*/ {
-/*N*/ aSplinePoints.push_back(
-/*N*/ ::std::pair< double, double >(
-/*N*/ static_cast< double >( nXPos ),
-/*N*/ static_cast< double >( nYPos )));
-/*N*/ }
/*N*/ nPoints ++;
/*N*/
/*N*/ aPoint.X () = nXPos;
@@ -664,28 +669,7 @@ namespace binfilter {
/*N*/ {
/*N*/ XPolyPolygon aSeriesPoly;
/*N*/
-/*N*/ if( bIsSplineChart )
-/*N*/ {
-/*?*/ if (!( (eChartStyle == CHSTYLE_2D_CUBIC_SPLINE_XY)
- || (eChartStyle == CHSTYLE_2D_CUBIC_SPLINE_SYMBOL_XY)
- )
- )
-/*?*/ {
-/*?*/ XPolygon aMeshPoly;
-/*?*/ approxMesh( nGranularity, aMeshPoly, aPolygon, nPoints - 1, nSplineDepth );
-/*?*/ SchCalculationHelper::IntersectPolygonWithRectangle(
-/*?*/ aMeshPoly, aClipRect, aSeriesPoly );
-/*?*/ }
-/*?*/
-/*?*/ if( pLineObject )
-/*?*/ pLineObject->NbcSetPathPoly( aSeriesPoly );
-/*?*/ else
-/*?*/ {
-/*?*/ pLineObject = new SdrPathObj( OBJ_PLIN, aSeriesPoly );
-/*?*/ pRowLists[ nRow ]->NbcInsertObject( pLineObject);
-/*?*/ }
-/*?*/ }
-/*N*/ else // series consits of lines
+ // line (or stripped spline)
/*N*/ {
/*N*/ SchCalculationHelper::IntersectPolygonWithRectangle( aPolygon, aClipRect, aSeriesPoly );
/*N*/
@@ -750,8 +734,14 @@ namespace binfilter {
/*N*/ USHORT eStackMode = bStacked ? CHSTACK_MINMAX : CHSTACK_NONE;
/*N*/
/*N*/ Size aYDescrSize;
-/*N*/ SdrObjList ** pRowLists = new SdrObjList*[nRowCnt];
-/*N*/ SdrObjList ** pDescrLists = new SdrObjList*[nRowCnt];
+/*N*/ SdrObjList ** pRowLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+/*N*/ SdrObjList ** pDescrLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+ if( !pRowLists || !pDescrLists )
+ {
+ delete[] pRowLists;
+ delete[] pDescrLists;
+ return pGroup;
+ }
/*N*/ DataDescription* pDescription = NULL;
/*N*/ SdrObjList *pYAxisList = pChartYAxis->IsVisible()
/*N*/ ? CreateGroup (*pList, CHOBJID_DIAGRAM_Y_AXIS, 0)
@@ -804,7 +794,7 @@ namespace binfilter {
/*N*/
/*N*/ XPolygon aLine (2);
/*N*/ double fSteps = pChartYAxis->GetMax();
-/*N*/ double* fOldData = new double[nColCnt];
+/*N*/ double* fOldData = ArrayHelper<double>::create_long_size(nColCnt);
/*N*/ double fAngle = F_PI / 2;
/*N*/
/*N*/ Size aLegendSize (((SvxFontWidthItem &) pLegendAttr->Get (EE_CHAR_FONTWIDTH)).GetWidth (),
@@ -1026,11 +1016,13 @@ namespace binfilter {
/*?*/ }
/*N*/ }
/*N*/
-/*N*/ if (bStacked && !nRow) fOldData[nCol] = pChartYAxis->GetOrigin();
+/*N*/ if (bStacked && !nRow && fOldData)
+ fOldData[nCol] = pChartYAxis->GetOrigin();
/*N*/
/*N*/ if (fData != DBL_MIN)
/*N*/ {
-/*N*/ if (bStacked && nRow) fData += fOldData[nCol];
+/*N*/ if (bStacked && nRow && fOldData)
+ fData += fOldData[nCol];
/*N*/
/*N*/ double fLength = nLength * pChartYAxis->CalcFact(fData);
/*N*/
@@ -1056,7 +1048,8 @@ namespace binfilter {
/*N*/ }
/*N*/ }
/*N*/
-/*N*/ fOldData [nCol] = fData;
+ if( fOldData )
+/*N*/ fOldData [nCol] = fData;
/*N*/ }
/*N*/ else
/*N*/ {
diff --git a/binfilter/bf_sch/source/core/sch_chtmod3d.cxx b/binfilter/bf_sch/source/core/sch_chtmod3d.cxx
index a66c7c55b..051a4d7d3 100644
--- a/binfilter/bf_sch/source/core/sch_chtmod3d.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmod3d.cxx
@@ -53,6 +53,7 @@
#include <bf_svx/svdopath.hxx>
#include <bf_svx/xlnwtit.hxx>
+#include "arrayhelper.hxx"
#include "pairs.hxx"
#include "chmod3d.hxx"
#include "chaxis.hxx"
@@ -762,6 +763,8 @@ namespace binfilter {
/*N*/ long nRowCnt = GetRowCount();
/*N*/ short nCol, nRow;
/*N*/
+ if( nColCnt<0 || (static_cast< unsigned long>(nColCnt) > static_cast<unsigned long>((std::numeric_limits<sal_uInt16>::max()-1)/2)) )
+ return (SdrObjGroup*) pScene;
/*N*/ Polygon aFrontExtrude(1+nColCnt*2);
/*N*/
/*N*/ long nGapX = nW * nGapWidth / 1000;
@@ -1267,7 +1270,9 @@ namespace binfilter {
/*N*/ {
/*N*/ DataDescription* pDescription = NULL;
/*N*/
-/*N*/ double* fOldData = new double[nColCnt];
+/*N*/ double* fOldData = ArrayHelper<double>::create_long_size(nColCnt);
+ if( !fOldData )
+ return (SdrObjGroup*) pScene;
/*N*/ a3DPos.Z() += nBarWidthZ;
/*N*/
/*N*/ for (nRow = 0; nRow < nRowCnt; nRow++)
@@ -1385,7 +1390,9 @@ namespace binfilter {
/*N*/
/*N*/ // #100288# same structure as all other charts (no stacked and special groups)
/*N*/ // create groups for all series
-/*N*/ E3dScene ** pDataGroup = new E3dScene * [ nRowCnt ];
+/*N*/ E3dScene ** pDataGroup = ArrayHelper<E3dScene*>::create_long_size( nRowCnt );
+ if(!pDataGroup)
+ return (SdrObjGroup*) pScene;
/*N*/
/*N*/ // create 3d sub-scenes for each data series. Insertion into the
/*N*/ // main scene is done at the end of the for loop (#109628#)
@@ -1941,10 +1948,7 @@ namespace binfilter {
/*N*/ {
/*N*/ // FG: Das ist eine Variable die in BuildChart gesetzt wird, kutz bevor
/*N*/ // das Objekt zerstoert wird.
-/*?*/ double fRelativeXPosition = ((double) aTitleXAxisPosition.X()) / aInitialSizefor3d.Width();
-/*?*/ double fRelativeYPosition = ((double) aTitleXAxisPosition.Y()) / aInitialSizefor3d.Height();
-/*?*/ aXAxesTitlePosition.X() = (long)(aPageSize.Width() * fRelativeXPosition);
-/*?*/ aXAxesTitlePosition.Y() = (long)(aPageSize.Height() * fRelativeYPosition);
+/*?*/ aXAxesTitlePosition = calcRelativePosition( aTitleXAxisPosition, aInitialSizefor3d, aPageSize );
/*N*/ }
/*N*/ else
/*N*/ {
@@ -1973,10 +1977,7 @@ namespace binfilter {
/*N*/ {
/*N*/ // FG: Das ist eine Variable die in BuildChart gesetzt wird, kutz bevor
/*N*/ // das Objekt zerstoert wird.
-/*N*/ double fRelativeXPosition = ((double) aTitleYAxisPosition.X()) / aInitialSizefor3d.Width();
-/*N*/ double fRelativeYPosition = ((double) aTitleYAxisPosition.Y()) / aInitialSizefor3d.Height();
-/*N*/ aYAxesTitlePosition.X() = (long)(aPageSize.Width() * fRelativeXPosition);
-/*N*/ aYAxesTitlePosition.Y() = (long)(aPageSize.Height() * fRelativeYPosition);
+/*N*/ aYAxesTitlePosition = calcRelativePosition( aTitleYAxisPosition, aInitialSizefor3d, aPageSize );
/*N*/ }
/*N*/ else
/*N*/ {
@@ -2010,10 +2011,7 @@ namespace binfilter {
/*N*/ {
/*N*/ // FG: Das ist eine Variable die in BuildChart gesetzt wird, kutz bevor
/*N*/ // das Objekt zerstoert wird.
-/*N*/ double fRelativeXPosition = ((double) aTitleZAxisPosition.X()) / aInitialSizefor3d.Width();
-/*N*/ double fRelativeYPosition = ((double) aTitleZAxisPosition.Y()) / aInitialSizefor3d.Height();
-/*N*/ aZAxesTitlePosition.X() = (long)(aPageSize.Width() * fRelativeXPosition);
-/*N*/ aZAxesTitlePosition.Y() = (long)(aPageSize.Height() * fRelativeYPosition);
+/*N*/ aZAxesTitlePosition = calcRelativePosition( aTitleZAxisPosition, aInitialSizefor3d, aPageSize );
/*N*/ }
/*N*/ else if(aZAxesTitlePosition.Y()<aZAxisOutRect.GetHeight()/2)
/*N*/ {
diff --git a/binfilter/bf_sch/source/core/sch_chtmode1.cxx b/binfilter/bf_sch/source/core/sch_chtmode1.cxx
index ccbac1476..c11c5d71b 100644
--- a/binfilter/bf_sch/source/core/sch_chtmode1.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmode1.cxx
@@ -59,6 +59,7 @@
#include <bf_svx/xlnclit.hxx>
#include <bf_svx/xlnwtit.hxx>
+#include "arrayhelper.hxx"
#include "pairs.hxx"
#include "memchrt.hxx"
#include "chaxis.hxx"
@@ -475,22 +476,24 @@ namespace binfilter {
/*N*/
/*N*/ if (nCnt != nPieSegCount)
/*N*/ {
-/*N*/ long *pOfs = new long[nCnt];
-/*N*/
-/*N*/ if (nPieSegCount > nCnt)
-/*N*/ for (i = 0; i < nCnt; i++)
-/*N*/ pOfs[i] = pPieSegOfs[i];
-/*N*/ else
-/*N*/ {
-/*N*/ for (i = 0; i < nPieSegCount; i++)
-/*N*/ pOfs[i] = pPieSegOfs[i];
-/*N*/ for (; i < nCnt; i++)
-/*N*/ pOfs[i] = 0;
-/*N*/ }
-/*N*/
-/*N*/ delete[] pPieSegOfs;
-/*N*/ pPieSegOfs = pOfs;
-/*N*/ nPieSegCount = nCnt;
+/*N*/ long *pOfs = ArrayHelper<long>::create_short_size(nCnt);
+ if( pOfs )
+ {
+/*N*/ if (nPieSegCount > nCnt)
+/*N*/ for (i = 0; i < nCnt; i++)
+/*N*/ pOfs[i] = pPieSegOfs[i];
+/*N*/ else
+/*N*/ {
+/*N*/ for (i = 0; i < nPieSegCount; i++)
+/*N*/ pOfs[i] = pPieSegOfs[i];
+/*N*/ for (; i < nCnt; i++)
+/*N*/ pOfs[i] = 0;
+/*N*/ }
+/*N*/
+/*N*/ delete[] pPieSegOfs;
+/*N*/ pPieSegOfs = pOfs;
+/*N*/ nPieSegCount = nCnt;
+ }
/*N*/ }
/*N*/
/*N*/
@@ -780,13 +783,16 @@ namespace binfilter {
/*N*/ {
/*N*/ const SchColorTable& aDefCols = pOptions->GetDefaultColors();
/*N*/ nCount = aDefCols.Count();
-/*N*/ pDefaultCol = new ColorData[ nCount ];
+/*N*/ pDefaultCol = ArrayHelper<ColorData>::create_long_size( nCount );
/*N*/ DBG_ASSERT( nCount == ROW_COLOR_COUNT, "Chart: dynamic default color array size not supported yet" );
/*N*/
-/*N*/ for( size_t i=0; i<nCount; i++ )
-/*N*/ {
-/*N*/ pDefaultCol[ i ] = aDefCols.GetColorData( i );
-/*N*/ }
+ if(pDefaultCol)
+ {
+/*N*/ for( size_t i=0; i<nCount; i++ )
+/*N*/ {
+/*N*/ pDefaultCol[ i ] = aDefCols.GetColorData( i );
+/*N*/ }
+ }
/*N*/ }
/*N*/ else
/*N*/ {
diff --git a/binfilter/bf_sch/source/core/sch_chtmode2.cxx b/binfilter/bf_sch/source/core/sch_chtmode2.cxx
index ab4fa4944..c7463200f 100644
--- a/binfilter/bf_sch/source/core/sch_chtmode2.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmode2.cxx
@@ -67,6 +67,7 @@
#include "pairs.hxx"
#include "chaxis.hxx"
+#include "arrayhelper.hxx"
#include <legacysmgr/legacy_binfilters_smgr.hxx>
@@ -190,14 +191,17 @@ enum ChartStyleV0
/*N*/
/*N*/ long nLineMaxY = 0; //#50082#
/*N*/
-/*N*/ long* pHeightOfEntry = new long[nCnt*2]; // FG: Wirkliche Hoehe der Zeilen
-/*N*/ long* pWidthOfEntry = new long[nCnt*2]; // FG: Wirkliche Breite der Zeilen
+/*N*/ long* pHeightOfEntry = ArrayHelper<long>::create_long_size(nCnt,long(2)); // FG: Wirkliche Hoehe der Zeilen
+/*N*/ long* pWidthOfEntry = ArrayHelper<long>::create_long_size(nCnt,long(2)); // FG: Wirkliche Breite der Zeilen
+ if( !pHeightOfEntry || !pWidthOfEntry )
+ {
+ delete[] pHeightOfEntry;
+ delete[] pWidthOfEntry;
+ return 0;
+ }
/*N*/ long nLines = 0; // Anzahl Zeilen
/*N*/ long nActualColumn = 1; // FG: Zaehlt die Anzahl Spalten
/*N*/
-/*N*/ long* pRegressNr = new long [nCnt];
-/*N*/ memset (pRegressNr, 0, sizeof (long) * nCnt);
-/*N*/
/*N*/ SfxItemSet aTextAttr(*pItemPool, nTextWhichPairs);
/*N*/
/*N*/ aTextAttr.Put(*pLegendAttr);
@@ -257,7 +261,6 @@ enum ChartStyleV0
/*?*/ nMaxX = Max (nMaxX, pWidthOfEntry[nLines+nCnt]);
/*?*/ nMaxY = Max (nMaxY, pHeightOfEntry[nLines+nCnt]);
/*?*/
-/*?*/ pRegressNr [nLines] = i;
/*?*/ nLines ++;
/*N*/ }
/*N*/ }
@@ -480,7 +483,6 @@ enum ChartStyleV0
/*N*/ TRUE, TRUE, pLegendAttr), 0);
/*N*/ }
/*N*/
-/*N*/ delete[] pRegressNr;
/*N*/ delete[] pHeightOfEntry;
/*N*/ delete[] pWidthOfEntry;
/*N*/ }
@@ -1169,16 +1171,18 @@ enum ChartStyleV0
/*N*/ switch ((ChartDataId)nInt16)
/*N*/ {
/*N*/ case CHDATAID_MEMCHART_PLUS :
-/*?*/ pChartData = new SchMemChart (CHDATAID_MEMCHART_PLUS);
-/*?*/ rIn >> *(SchMemChart*)pChartData;
-/*?*/ pChartData->IncreaseRefCount();
-/*?*/ break;
-/*?*/
/*?*/ case CHDATAID_DYNCHART:
/*N*/ case CHDATAID_MEMCHART:
-/*N*/ pChartData = new SchMemChart (CHDATAID_MEMCHART);
+ if( CHDATAID_MEMCHART_PLUS==(ChartDataId)nInt16)
+/*?*/ pChartData = new SchMemChart (CHDATAID_MEMCHART_PLUS);
+ else
+/*N*/ pChartData = new SchMemChart (CHDATAID_MEMCHART);
/*N*/ rIn >> *(SchMemChart*)pChartData;
/*N*/ pChartData->IncreaseRefCount();
+ if( rIn.GetError() != 0 ) //read error
+ {
+ return;
+ }
/*N*/ break;
/*N*/
/*N*/ default :
@@ -1190,8 +1194,8 @@ enum ChartStyleV0
/*N*/ if (nVersion >= 8) rIn >> fMinData;
/*N*/ else if (pChartData)
/*N*/ {
-/*?*/ long nColCnt = GetColCount();
-/*?*/ long nRowCnt = GetRowCount();
+/*?*/ short nColCnt = GetColCount();
+/*?*/ short nRowCnt = GetRowCount();
/*?*/
/*?*/ for (short nCol = 0; nCol < nColCnt; nCol++)
/*?*/ for (short nRow = 0; nRow < nRowCnt; nRow++)
@@ -1316,16 +1320,26 @@ enum ChartStyleV0
/*N*/
/*N*/ if (nVersion >= 6)
/*N*/ {
-/*N*/ rIn >> nInt16; nPieSegCount = (short)nInt16;
-/*N*/ pPieSegOfs = new long[nPieSegCount];
-/*N*/
-/*N*/ BOOL bNullify = (nVersion < 17) && eChartStyle == CHSTYLE_2D_PIE;
-/*N*/
-/*N*/ for( i = 0; i < nPieSegCount; i++ )
-/*N*/ {
-/*N*/ rIn >> nInt32;
-/*N*/ pPieSegOfs[ i ] = bNullify? 0: (long)nInt32;
-/*N*/ }
+ nInt16=0;
+/*N*/ rIn >> nInt16;
+ nPieSegCount = static_cast<short>(nInt16);
+ delete[] pPieSegOfs; pPieSegOfs=0;
+ if( nPieSegCount!=0 )
+ {
+ pPieSegOfs = ArrayHelper< long >::create_short_size( nPieSegCount );
+ if(!pPieSegOfs)
+ {
+ nPieSegCount=0;
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return;
+ }
+/*N*/ BOOL bNullify = (nVersion < 17) && eChartStyle == CHSTYLE_2D_PIE;
+/*N*/ for( i = 0; i < nPieSegCount; i++ )
+/*N*/ {
+/*N*/ rIn >> nInt32;
+/*N*/ pPieSegOfs[ i ] = bNullify? 0: (long)nInt32;
+/*N*/ }
+ }
/*N*/ }
/*N*/
/*N*/ rIn >> nInt16; nXAngle = (short)nInt16;
diff --git a/binfilter/bf_sch/source/core/sch_chtmode3.cxx b/binfilter/bf_sch/source/core/sch_chtmode3.cxx
index beda65ca6..3df2d181d 100644
--- a/binfilter/bf_sch/source/core/sch_chtmode3.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmode3.cxx
@@ -67,6 +67,9 @@
#include "chaxis.hxx"
+#include <limits>
+#include <algorithm>
+
namespace binfilter {
/*************************************************************************
@@ -270,20 +273,17 @@ namespace binfilter {
/*N*/ const SfxItemSet& ChartModel::GetDataRowAttr( long nRow ) const
/*N*/ {
-/*N*/ if( nRow < (long)aDataRowAttrList.size() )
+/*N*/ if( nRow>=0 && nRow < (long)aDataRowAttrList.size() )
/*N*/ {
/*N*/ SfxItemSet* pSet = aDataRowAttrList[ nRow ];
/*N*/ DBG_ASSERT( pSet, "Invalid ItemSet" );
-/*N*/ return *pSet;
-/*N*/ }
-/*N*/ else
-/*N*/ {
-/*N*/ OSL_FAIL( "Requested data row attribute is unavailable" );
-/*N*/
-/*N*/ // return something
-/*?*/ DBG_ASSERT( pChartAttr, "Invalid Chart-ItemSet" );
-/*?*/ return *pChartAttr;
+ if( pSet )
+/*N*/ return *pSet;
/*N*/ }
+/*N*/ OSL_FAIL( "Requested data row attribute is unavailable" );
+/*N*/ // return something
+/*?*/ DBG_ASSERT( pChartAttr, "Invalid Chart-ItemSet" );
+/*?*/ return *pChartAttr;
/*N*/ }
/*************************************************************************
@@ -675,11 +675,25 @@ namespace binfilter {
/*N*/ ? &aSwitchDataPointAttrList
/*N*/ : &aDataPointAttrList;
/*N*/
-/*N*/ SfxItemSet* pItemSet = (*pAttrList)[ nCol * GetRowCount() + nRow ];
+ if( nCol < 0 || nRow < 0 )
+ return;
+ const long nRowCount = GetRowCount();
+ const long nColCount = GetColCount();
+ if( nColCount <= 0 || nRowCount <= 0 )
+ return;
+ if( nCol >= nColCount || nRow >= nRowCount )
+ return;
+ if( nCol > ::std::numeric_limits<long>::max()/nRowCount ) //sal_uIntPtr is the type of the index parameter for method pAttrList->GetObject
+ return;
+ if( nRowCount*nCol > ::std::numeric_limits<long>::max() - nRow )
+ return;
+ sal_uIntPtr nIndex = static_cast<sal_uIntPtr>(nCol) * nRowCount + nRow;
+
+/*N*/ SfxItemSet* pItemSet = (*pAttrList)[ nCol * GetRowCount() + nRow ];
/*N*/ if (pItemSet == NULL)
/*N*/ {
/*N*/ pItemSet = new SfxItemSet(*pItemPool, nRowWhichPairs);
-/*N*/ (*pAttrList)[nCol * GetRowCount() + nRow] = pItemSet;
+/*N*/ (*pAttrList)[nIndex] = pItemSet;
/*N*/ }
/*N*/ if(!bMerge)
/*?*/ pItemSet->ClearItem();
@@ -774,10 +788,11 @@ namespace binfilter {
/*N*/ SfxItemSet aAttr( GetDataRowAttr( nCol % nPieCount ));
/*N*/
/*N*/ if( ( nCol >= nPieCount ) &&
-/*N*/ pDefaultColors )
+/*N*/ pDefaultColors && pDefaultColors->size()>0 )
/*N*/ {
/*?*/ XColorEntry* pColEntry = (*pDefaultColors)[ nCol % pDefaultColors->size() ];
-/*?*/ aAttr.Put( XFillColorItem( pColEntry->GetName(), pColEntry->GetColor()));
+ if( pColEntry )
+/*?*/ aAttr.Put( XFillColorItem( pColEntry->GetName(), pColEntry->GetColor()));
/*N*/ }
/*N*/
/*N*/ // add description attributes of series
diff --git a/binfilter/bf_sch/source/core/sch_chtmode4.cxx b/binfilter/bf_sch/source/core/sch_chtmode4.cxx
index cd0cc0845..a02975175 100644
--- a/binfilter/bf_sch/source/core/sch_chtmode4.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmode4.cxx
@@ -155,11 +155,19 @@ namespace binfilter {
/*N*/ void ChartModel::ResizeText (SfxItemSet *pTextAttr, Size aPageSize, BOOL bResizePage )
/*N*/ {
-/*N*/ double fRatio;
+/*N*/ double fRatio = 1.0;
/*N*/ if( bResizePage )
-/*N*/ fRatio = (double)aPageSize.Height() / (double)aInitialSize.Height();
+ {
+ double fDenominator = aInitialSize.Height();
+ if( fDenominator != 0 )
+/*N*/ fRatio = (double)aPageSize.Height() / fDenominator;
+ }
/*N*/ else
-/*?*/ fRatio = (double)aDiagramRectangle.GetHeight() / (double)aLastDiagramRectangle.GetHeight();
+ {
+ double fDenominator = aLastDiagramRectangle.GetHeight();
+ if( fDenominator != 0 )
+/*?*/ fRatio = (double)aDiagramRectangle.GetHeight() / fDenominator;
+ }
/*N*/
/*N*/ // resize all three fonts
/*N*/ static const USHORT nWhichIds[ 3 ] = {
@@ -643,6 +651,21 @@ namespace binfilter {
/*N*/ }
/*N*/ }
+Point ChartModel::calcRelativePosition( const Point& rStartPoint, const Size& rInitialSize, const Size& rNewSize )
+{
+ Point aRet( rStartPoint );
+ double fX_Denominator = rInitialSize.Width();
+ double fY_Denominator = rInitialSize.Height();
+ if( fX_Denominator != 0.0 && fY_Denominator != 0.0 )
+ {
+ double fRelativXPosition = rStartPoint.X() / fX_Denominator;
+ double fRelativYPosition = rStartPoint.Y() / fY_Denominator;
+ aRet.X() = static_cast<long>( rNewSize.Width() * fRelativXPosition );
+ aRet.Y() = static_cast<long>( rNewSize.Height() * fRelativYPosition );
+ }
+ return aRet;
+}
+
/*************************************************************************
|*
|* Sub-Methode von BuildChart(), Anzeige des Haupttitels
@@ -657,10 +680,7 @@ namespace binfilter {
/*N*/ if (bUseRelativePositionsForChartGroups && (aTitleTopCenter.X() >= 0) &&
/*N*/ (aTitleTopCenter.Y() >= 0) && GetMainTitleHasBeenMoved())
/*N*/ {
-/*N*/ double fRelativXPosition = ((double) aTitleTopCenter.X()) / aInitialSize.Width();
-/*N*/ double fRelativYPosition = ((double) aTitleTopCenter.Y()) / aInitialSize.Height();
-/*N*/ aTitlePosition.X() = (long)((double)rPageSize.Width() * fRelativXPosition );
-/*N*/ aTitlePosition.Y() = (long)((double)rPageSize.Height() * fRelativYPosition );
+/*N*/ aTitlePosition = calcRelativePosition( aTitleTopCenter, aInitialSize, rPageSize );
/*N*/ }
/*N*/ else
/*N*/ {
@@ -676,7 +696,6 @@ namespace binfilter {
/*N*/ pObj->SetResizeProtect(TRUE);
/*N*/ pPage->NbcInsertObject(pObj, rIndex++);
/*N*/ }
-
/*************************************************************************
|*
|* Sub-Methode von BuildChart(), man koennte vermutlich DoShowMainTitle und
@@ -692,10 +711,7 @@ namespace binfilter {
/*N*/ if (bUseRelativePositionsForChartGroups && (aSubTitleTopCenter.X() >= 0) &&
/*N*/ (aSubTitleTopCenter.Y() >= 0) && GetSubTitleHasBeenMoved())
/*N*/ {
-/*N*/ double fRelativeXPosition = ((double) aSubTitleTopCenter.X()) / aInitialSize.Width();
-/*N*/ double fRelativeYPosition = ((double) aSubTitleTopCenter.Y()) / aInitialSize.Height();
-/*N*/ aSubTitlePosition.X() = (long)((double)rPageSize.Width() * fRelativeXPosition );
-/*N*/ aSubTitlePosition.Y() = (long)((double)rPageSize.Height() * fRelativeYPosition );
+/*N*/ aSubTitlePosition = calcRelativePosition( aSubTitleTopCenter, aInitialSize, rPageSize );
/*N*/ }
/*N*/ else
/*N*/ {
@@ -738,17 +754,7 @@ namespace binfilter {
/*N*/ if (bUseRelativePositionsForChartGroups && (aLegendTopLeft.X() >= 0) &&
/*N*/ (aLegendTopLeft.Y() >= 0) && GetLegendHasBeenMoved())
/*N*/ {
-/*N*/ double fRatioX =
-/*N*/ static_cast< double >( rPageSize.Width() ) /
-/*N*/ static_cast< double >( aInitialSize.Width() );
-/*N*/ double fRatioY =
-/*N*/ static_cast< double >( rPageSize.Height() ) /
-/*N*/ static_cast< double >( aInitialSize.Height() );
-/*N*/
-/*N*/ aLegendPosition.X() = static_cast< long >(
-/*N*/ static_cast< double >( aLegendTopLeft.X() ) * fRatioX );
-/*N*/ aLegendPosition.Y() = static_cast< long >(
-/*N*/ static_cast< double >( aLegendTopLeft.Y() ) * fRatioY );
+/*N*/ aLegendPosition = calcRelativePosition( aLegendTopLeft, aInitialSize, rPageSize );
/*N*/
/*N*/ if( bAdjustMarginsForLegend )
/*N*/ {
@@ -883,7 +889,9 @@ namespace binfilter {
/*N*/ aSet.Put(pObj->GetItemSet());
/*N*/
/*N*/ aSet.ClearInvalidItems();
-/*N*/ aDataRowAttrList[ nRow ]->Put( aSet );
+ SfxItemSet* pItemSet = aDataRowAttrList[ nRow ];
+ if(pItemSet)
+/*N*/ pItemSet->Put( aSet );
/*N*/ aSet.ClearItem();
/*N*/ }
/*N*/ else if( pDataPoint )
@@ -1079,17 +1087,23 @@ namespace binfilter {
//
// Previously the constraints to fullfill have been tighter:
// All four border lines had to lie inside the chart rectangle.
+ double fFactorX = 1.0;
+ double fFactorY = 1.0;
+ double fX_Denominator = aInitialSize.Width();
+ double fY_Denominator = aInitialSize.Height();
+ if( fX_Denominator != 0.0 && fY_Denominator != 0.0 )
+ {
+ fFactorX = rPageSize.Width() / fX_Denominator;
+ fFactorY = rPageSize.Height() / fY_Denominator;
+ }
+
/*N*/ if ( (aDiagramRectangle.nLeft < aDiagramRectangle.nRight)
/*N*/ && (aDiagramRectangle.nTop < aDiagramRectangle.nBottom) )
/*N*/ {
-/*?*/ double fRelativeXPosition = ((double) aDiagramRectangle.Left()) / aInitialSize.Width();
-/*?*/ double fRelativeYPosition = ((double) aDiagramRectangle.Top()) / aInitialSize.Height();
-/*?*/ aChartRect.nLeft = (long)((double)rPageSize.Width() * fRelativeXPosition );
-/*?*/ aChartRect.nTop = (long)((double)rPageSize.Height() * fRelativeYPosition );
-/*?*/ fRelativeXPosition = ((double) aDiagramRectangle.Right()) / aInitialSize.Width();
-/*?*/ fRelativeYPosition = ((double) aDiagramRectangle.Bottom()) / aInitialSize.Height();
-/*?*/ aChartRect.nRight = (long)((double)rPageSize.Width() * fRelativeXPosition );
-/*?*/ aChartRect.nBottom = (long)((double)rPageSize.Height() * fRelativeYPosition );
+/*?*/ aChartRect.nLeft = static_cast<long>( aDiagramRectangle.Left() * fFactorX );
+/*?*/ aChartRect.nTop = static_cast<long>( aDiagramRectangle.Top() * fFactorY );
+/*?*/ aChartRect.nRight = static_cast<long>( aDiagramRectangle.Right() * fFactorX );
+/*?*/ aChartRect.nBottom = static_cast<long>( aDiagramRectangle.Bottom() * fFactorY );
/*?*/ }
/*N*/ }
/*N*/ }
diff --git a/binfilter/bf_sch/source/core/sch_chtmode7.cxx b/binfilter/bf_sch/source/core/sch_chtmode7.cxx
index 9d993a4e3..cc13ebed2 100644
--- a/binfilter/bf_sch/source/core/sch_chtmode7.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmode7.cxx
@@ -104,7 +104,7 @@ namespace binfilter {
/*N*/ DBG_ASSERT( nCol < nPieSegCount, "pie segment requested is out of bounds" );
/*N*/
/*N*/ if( IsPieChart() &&
-/*N*/ nCol < nPieSegCount )
+/*N*/ nCol >= 0 && nCol < nPieSegCount )
/*N*/ {
/*N*/ return pPieSegOfs[ nCol ];
/*N*/ }
@@ -489,7 +489,7 @@ namespace binfilter {
/*N*/ DBG_ASSERT( pPieSegOfs, "Invalid Array" );
/*N*/ DBG_ASSERT( nCol < nPieSegCount, "trying to set pie offset out of bounds" );
/*N*/
-/*N*/ if( nCol < nPieSegCount )
+/*N*/ if( nCol >= 0 && nCol < nPieSegCount )
/*N*/ pPieSegOfs[ nCol ] = nOfs;
/*N*/ }
diff --git a/binfilter/bf_sch/source/core/sch_chtmode9.cxx b/binfilter/bf_sch/source/core/sch_chtmode9.cxx
index 7f3fcc8cc..051ebd322 100644
--- a/binfilter/bf_sch/source/core/sch_chtmode9.cxx
+++ b/binfilter/bf_sch/source/core/sch_chtmode9.cxx
@@ -62,6 +62,7 @@
#include <float.h>
#include "glob.hrc"
+#include "arrayhelper.hxx"
#include "chaxis.hxx"
#include "chdescr.hxx"
#include "calculat.hxx"
@@ -383,6 +384,16 @@ namespace binfilter {
/*N*/ SdrPage *pPage = GetPage(0);
/*N*/ Size aPageSize = pPage->GetSize();
/*N*/
+ double fFactorX = 1.0;
+ double fFactorY = 1.0;
+ double fX_Denominator = aInitialSize.Width();
+ double fY_Denominator = aInitialSize.Height();
+ if( fX_Denominator != 0.0 && fY_Denominator != 0.0 )
+ {
+ fFactorX = aPageSize.Width() / fX_Denominator;
+ fFactorY = aPageSize.Height() / fY_Denominator;
+ }
+
/*N*/ if(bShowXAxisTitle)
/*N*/ {
/*N*/ SdrObject *pXAxisTitleObj = GetObjWithId(CHOBJID_DIAGRAM_TITLE_X_AXIS,*pPage);
@@ -398,10 +409,8 @@ namespace binfilter {
/*N*/ {
/*N*/ // FG: Das ist eine Variable die in BuildChart gesetzt wird, kurz bevor
/*N*/ // das Objekt zerstoert wird.
-/*N*/ double fRelativeXPosition = ((double) aTitleXAxisPosition.X()) / aInitialSize.Width();
-/*N*/ double fRelativeYPosition = ((double) aTitleXAxisPosition.Y()) / aInitialSize.Height();
-/*N*/ aXAxesTitlePosition.X() = (int) (aPageSize.Width() * fRelativeXPosition + 0.5);
-/*N*/ aXAxesTitlePosition.Y() = (int) (aPageSize.Height() * fRelativeYPosition + 0.5);
+/*N*/ aXAxesTitlePosition.X() = static_cast<int>( aTitleXAxisPosition.X() * fFactorX + 0.5 );
+/*N*/ aXAxesTitlePosition.Y() = static_cast<int>( aTitleXAxisPosition.Y() * fFactorY + 0.5 );
/*N*/ }
/*N*/ else
/*N*/ {
@@ -429,10 +438,8 @@ namespace binfilter {
/*N*/ {
/*N*/ // FG: Das ist eine Variable die in BuildChart gesetzt wird, kurz bevor
/*N*/ // das Objekt zerstoert wird.
-/*N*/ double fRelativeXPosition = ((double) aTitleYAxisPosition.X()) / aInitialSize.Width();
-/*N*/ double fRelativeYPosition = ((double) aTitleYAxisPosition.Y()) / aInitialSize.Height();
-/*N*/ aYAxesTitlePosition.X() = (int) (aPageSize.Width() * fRelativeXPosition + 0.5);
-/*N*/ aYAxesTitlePosition.Y() = (int) (aPageSize.Height() * fRelativeYPosition + 0.5);
+/*N*/ aYAxesTitlePosition.X() = static_cast<int>( aTitleYAxisPosition.X() * fFactorX + 0.5);
+/*N*/ aYAxesTitlePosition.Y() = static_cast<int>( aTitleYAxisPosition.Y() * fFactorY + 0.5);
/*N*/ }
/*N*/ else
/*N*/ {
@@ -519,19 +526,32 @@ namespace binfilter {
/*N*/ aBarY2.Create(aRect,nColCnt,nR2);
/*N*/ ChartBarDescriptor* pBar=&aBarY1;
/*N*/
-/*N*/ SdrObjList **pRowLists = new SdrObjList*[nRowCnt];
-/*N*/ SdrObjList **pStatLists = new SdrObjList*[nRowCnt];
+/*N*/ SdrObjList **pRowLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+/*N*/ SdrObjList **pStatLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+ if( !pRowLists || !pStatLists )
+ {
+ delete[] pRowLists;
+ delete[] pStatLists;
+ return pGroup;
+ }
/*N*/
/*N*/ ChartDataDescription aDescr(nColCnt,nRowCnt,pList,this,bShowDataDescr);
/*N*/
/*N*/ Point *pTracePoint=0;
/*N*/ if(m_nDefaultColorSet&CHSPECIAL_TRACELINES)
/*N*/ {
-/*?*/ pTracePoint = new Point[nRowCnt];//#50149#
+/*?*/ pTracePoint = ArrayHelper<Point>::create_long_size(nRowCnt);//#50149#
/*N*/ }
/*N*/
/*N*/
-/*N*/ XPolygon *pLine = new XPolygon[nLines]; //#50149#
+/*N*/ XPolygon *pLine = ArrayHelper<XPolygon>::create_long_size(nLines); //#50149#
+ if( !pLine )
+ {
+ delete[] pRowLists;
+ delete[] pStatLists;
+ delete[] pTracePoint;
+ return pGroup;
+ }
/*N*/ BOOL bStartPointIsValid(FALSE); // Indicates wether the first point of a line
/*N*/ // segment is valid.
/*N*/
@@ -1147,8 +1167,14 @@ namespace binfilter {
/*N*/ long nPartWidth = aRect.GetWidth() / nBackColCnt;
/*N*/ double fPartWidth = ((double) aRect.GetWidth() / (double) nBackColCnt);
/*N*/
-/*N*/ SdrObjList** pRowLists = new SdrObjList*[nRowCnt];
-/*N*/ SdrObjList** pStatLists = new SdrObjList*[nRowCnt];
+/*N*/ SdrObjList** pRowLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+/*N*/ SdrObjList** pStatLists = ArrayHelper<SdrObjList*>::create_long_size(nRowCnt);
+ if( !pRowLists || !pStatLists )
+ {
+ delete[] pRowLists;
+ delete[] pStatLists;
+ return pGroup;
+ }
/*N*/
/*N*/ ChartDataDescription aDescr(nColCnt,nRowCnt,pList,this,bShowDataDescr);
/*N*/
@@ -1167,9 +1193,6 @@ namespace binfilter {
/*N*/
/*N*/ Polygon aPolygon( nColCnt + 16 ); // +4 -> +16: let some more points be possible. Is set to exact size later
/*N*/
-/*N*/ //Ab hier speziell fuer (Sp)Line-Charts:
-/*N*/ XPolygon *pSpline = new XPolygon(nColCnt * nGranularity);
-/*N*/
/*N*/ long nStartX=aRect.Left();
/*N*/ if(bPartDescr)
/*N*/ nStartX+=nPartWidth/2;
@@ -1283,32 +1306,6 @@ namespace binfilter {
/*?*/ {
/*?*/ if( nPoints > 1 )
/*?*/ {
-/*?*/ if( IsSplineChart() )
-/*?*/ {
-/*?*/ Polygon aNewPoly( nPoints );
-/*?*/ for( USHORT i = 0; i < nPoints; i++ )
-/*?*/ aNewPoly[ i ] = aPolygon[ i ];
-/*?*/
-/*?*/ XPolygon aXPoly( aNewPoly );
-/*?*/ if ((eChartStyle == CHSTYLE_2D_CUBIC_SPLINE) ||
-/*?*/ (eChartStyle == CHSTYLE_2D_CUBIC_SPLINE_SYMBOL))
-/*?*/ {
-/*?*/ CubicSpline( aXPoly, nPoints - 1, nGranularity, *pSpline );
-/*?*/ }
-/*?*/ else
-/*?*/ {
-/*?*/ approxMesh( nGranularity, *pSpline, aXPoly, nPoints - 1, nSplineDepth );
-/*?*/ }
-/*?*/
-/*?*/ XPolygon aSplinePoly( *pSpline );
-/*?*/ aSplinePoly.SetSize( (nPoints - 1) * nGranularity );
-/*?*/
-/*?*/ // #67488# crop polygon
-/*?*/ XPolyPolygon aResult;
-/*?*/ SchCalculationHelper::IntersectPolygonWithRectangle( aSplinePoly, aClipRect, aResult );
-/*?*/ pObj = new SdrPathObj( OBJ_PLIN, aResult );
-/*?*/ }
-/*?*/ else
/*?*/ {
/*?*/ Polygon aNewPoly( nPoints );
/*?*/ for( USHORT i = 0; i < nPoints; i++ )
@@ -1341,37 +1338,8 @@ namespace binfilter {
/*N*/ {
/*N*/ pObj = NULL;
/*N*/
-/*N*/ if( IsSplineChart() )
-/*N*/ {
-/*N*/ if( nPoints > 1 )
-/*N*/ {
-/*N*/ Polygon aNewPoly( nPoints );
-/*N*/ for( USHORT i = 0; i < nPoints; i++ )
-/*N*/ aNewPoly[ i ] = aPolygon[ i ];
-/*N*/
-/*N*/ XPolygon aXPoly( aNewPoly );
-/*N*/ if ((eChartStyle == CHSTYLE_2D_CUBIC_SPLINE) ||
-/*N*/ (eChartStyle == CHSTYLE_2D_CUBIC_SPLINE_SYMBOL))
-/*N*/ {
-/*N*/ CubicSpline( aXPoly, nPoints - 1,nGranularity, *pSpline );
-/*N*/ }
-/*N*/ else
-/*N*/ {
-/*N*/ approxMesh( nGranularity, *pSpline, aXPoly, nPoints - 1, nSplineDepth );
-/*N*/ }
-/*N*/
-/*N*/ XPolygon aSplinePoly( *pSpline );
-/*N*/ aSplinePoly.SetSize( (nPoints - 1) * nGranularity );
-/*N*/
-/*N*/ // #67488# crop polygon
-/*N*/ XPolyPolygon aResult;
-/*N*/ SchCalculationHelper::IntersectPolygonWithRectangle( aSplinePoly, aClipRect, aResult );
-/*N*/ pObj = new SdrPathObj( OBJ_PLIN, aResult );
-/*N*/ }
-/*N*/ }
-/*N*/ else
/*N*/ {
-/*N*/ if( bArea )
+/*N*/ if( bArea && !IsSplineChart() )
/*N*/ {
/*N*/ Polygon aNewPoly( nPoints + 3 );
/*N*/ for( USHORT i = 0; i < nPoints + 3; i++ )
@@ -1391,7 +1359,7 @@ namespace binfilter {
/*N*/ pObj->SetModel( this );
/*N*/ SetObjectAttr( pObj,CHOBJID_DIAGRAM_ROWS, TRUE, TRUE, (SfxItemSet *)&rDataRowAttr );
/*N*/ }
-/*N*/ else if( nPoints > 1 ) // line
+/*N*/ else if( nPoints > 1 ) // line (or stripped spline)
/*N*/ {
/*N*/ // #67488# crop polygon
/*N*/ Polygon aNewPoly( nPoints );
@@ -1422,8 +1390,6 @@ namespace binfilter {
/*N*/ } // if( nPoints )
/*N*/ } //for nRow
/*N*/
-/*N*/ delete pSpline;
-/*N*/
/*N*/ //Ab hier wieder wie in Create2DRow(Area)Chart:
/*N*/
/*N*/ aDescr.Build(TRUE);
@@ -1703,6 +1669,9 @@ namespace binfilter {
/*N*/ break;
/*N*/ }
/*N*/
+ if( nLastSeries<0 )
+ return;
+
/*N*/ // #101164# map fill-/line colors
/*N*/ if( nNumLinesInColChart > nOldNumLines )
/*N*/ {
@@ -1712,7 +1681,8 @@ namespace binfilter {
/*N*/ {
/*N*/ SfxItemSet * pSet = aDataRowAttrList[ nLastSeries - i ];
/*N*/ OSL_ASSERT( pSet );
-/*N*/ pSet->Put( XLineColorItem(
+/*N*/ if( pSet )
+/*N*/ pSet->Put( XLineColorItem(
/*N*/ String(),
/*N*/ static_cast< const XFillColorItem & >(
/*N*/ pSet->Get( XATTR_FILLCOLOR )).GetValue() ));
@@ -1726,11 +1696,14 @@ namespace binfilter {
/*N*/ {
/*?*/ SfxItemSet * pSet = aDataRowAttrList[ nLastSeries - i ];
/*?*/ OSL_ASSERT( pSet );
-/*?*/ pSet->Put( XFillColorItem(
+/*?*/ if( pSet )
+/*?*/ {
+/*?*/ pSet->Put( XFillColorItem(
/*?*/ String(),
/*?*/ static_cast< const XLineColorItem & >(
/*?*/ pSet->Get( XATTR_LINECOLOR )).GetValue() ));
-/*?*/ pSet->Put( XLineColorItem( String(), RGBColor( COL_BLACK ) ));
+/*?*/ pSet->Put( XLineColorItem( String(), RGBColor( COL_BLACK ) ));
+/*?*/ }
/*N*/ }
/*N*/ }
/*N*/ }
diff --git a/binfilter/bf_sch/source/core/sch_globfunc.cxx b/binfilter/bf_sch/source/core/sch_globfunc.cxx
index 2b35e9c9b..019e5769a 100644
--- a/binfilter/bf_sch/source/core/sch_globfunc.cxx
+++ b/binfilter/bf_sch/source/core/sch_globfunc.cxx
@@ -129,250 +129,6 @@ namespace binfilter {
/*N*/ return (SchObjGroup *) SetObjectAttr (new SchObjGroup, nID, bProtect, bResize, 0);
/*N*/ }
-
-/*************************************************************************
-|*
-|* Berechne kub. Spline
-|*
-\************************************************************************/
-
-/*N*/ void CubicSpline (XPolygon &pKnownPoints,
-/*N*/ int n,
-/*N*/ int splineSize,
-/*N*/ XPolygon &pSplines)
-/*N*/ {
-/*N*/ double *h = new double [n + 1];
-/*N*/ double *m = new double [n + 1];
-/*N*/ double *q = new double [n + 1];
-/*N*/ double *u = new double [n + 1];
-/*N*/
-/*N*/ for (int k = 1;
-/*N*/ k <= n;
-/*N*/ k ++)
-/*N*/ h [k] = pKnownPoints [k].X () - pKnownPoints [k - 1].X ();
-/*N*/
-/*N*/ double p;
-/*N*/ double lambda = 0.0;
-/*N*/ double d = 0.0;
-/*N*/ double mue;
-/*N*/
-/*N*/ q [0] = -lambda / 2.0;
-/*N*/ u [0] = d / 2.0;
-/*N*/
-/*N*/ int j;
-/*N*/ for (j = 1;
-/*N*/ j <= n;
-/*N*/ j ++)
-/*N*/ {
-/*N*/ mue = (j < n)
-/*N*/ ? h[j] / (h [j] + h [j + 1])
-/*N*/ : 0.0;
-/*N*/ p = mue * q [j - 1] + 2.0;
-/*N*/ lambda = 1.0 - mue;
-/*N*/ q [j] = -lambda / p;
-/*N*/ d = (j < n)
-/*N*/ ? 6.0 * ((pKnownPoints [j + 1].Y () - pKnownPoints [j].Y ()) / h [j + 1] -
-/*N*/ (pKnownPoints [j].Y () - pKnownPoints [j - 1].Y ()) / h [j]) / (h [j] + h [j + 1])
-/*N*/ : 0.0;
-/*N*/ u [j] = (d - mue * u [j - 1]) / p;
-/*N*/ }
-/*N*/
-/*N*/ m [n] = u [n];
-/*N*/
-/*N*/ for (j = n - 1;
-/*N*/ j >= 0;
-/*N*/ j --)
-/*N*/ m [j] = q [j] * m [j + 1] + u [j];
-/*N*/
-/*N*/ for (j = 0;
-/*N*/ j < n;
-/*N*/ j ++)
-/*N*/ {
-/*N*/ double xStep = (pKnownPoints [j + 1].X () - pKnownPoints [j].X ()) / splineSize;
-/*N*/ double x = pKnownPoints [j].X ();
-/*N*/
-/*N*/ double alpha = pKnownPoints [j].Y ();
-/*N*/ double gamma = m [j] / 2;
-/*N*/ double beta = (pKnownPoints [j + 1].Y () - pKnownPoints [j].Y ()) / h [j + 1] -
-/*N*/ ((2 * m [j] + m [j + 1]) * h [j + 1]) / 6;
-/*N*/ double delta = (m [j + 1] - m [j]) / (6 * h [j + 1]);
-/*N*/
-/*N*/ for (int i = 0;
-/*N*/ i < splineSize;
-/*N*/ i ++)
-/*N*/ {
-/*N*/ double xdiff = (x - pKnownPoints [j].X ());
-/*N*/ int index = j * splineSize + i;
-/*N*/
-/*N*/ pSplines [(short) index].Y () = long(alpha + xdiff * (beta + xdiff * (gamma + xdiff * delta)));
-/*N*/ pSplines [(short) index].X () = long(x);
-/*N*/ x += xStep;
-/*N*/ }
-/*N*/ }
-/*N*/
-/*N*/ pSplines [n * splineSize].Y () = pKnownPoints [n].Y ();
-/*N*/ pSplines [n * splineSize].X () = pKnownPoints [n].X ();
-/*N*/
-/*N*/ delete[] h;
-/*N*/ delete[] m;
-/*N*/ delete[] q;
-/*N*/ delete[] u;
-/*N*/ }
-
-/*************************************************************************
-|*
-|* Bestimme Knotenvektor fuer B-Spline
-|*
-\************************************************************************/
-
-/*N*/ void TVector (int n,
-/*N*/ int k,
-/*N*/ double *t)
-/*N*/ {
-/*N*/ for (int i = 0;
-/*N*/ i <= n + k;
-/*N*/ i ++)
-/*N*/ {
-/*N*/ if (i < k) t [i] = 0;
-/*N*/ else if (i <= n) t [i] = i - k + 1;
-/*N*/ else t [i] = n - k + 2;
-/*N*/ }
-/*N*/ }
-
-/*************************************************************************
-|*
-|* Berechne linken Knotenvektor
-|*
-\************************************************************************/
-
-/*N*/ double TLeft (double x,
-/*N*/ int i,
-/*N*/ int k,
-/*N*/ double *t)
-/*N*/ {
-/*N*/ double deltaT = t [i + k - 1] - t [i];
-/*N*/
-/*N*/ return (deltaT == 0.0)
-/*N*/ ? 0.0
-/*N*/ : (x - t [i]) / deltaT;
-/*N*/ }
-
-/*************************************************************************
-|*
-|* Berechne rechten Knotenvektor
-|*
-\************************************************************************/
-
-/*N*/ double TRight (double x,
-/*N*/ int i,
-/*N*/ int k,
-/*N*/ double *t)
-/*N*/ {
-/*N*/ double deltaT = t [i + k] - t [i + 1];
-/*N*/
-/*N*/ return (deltaT == 0.0)
-/*N*/ ? 0.0
-/*N*/ : (t [i + k] - x) / deltaT;
-/*N*/ }
-
-/*************************************************************************
-|*
-|* Berechne Gewichtungsvektor
-|*
-\************************************************************************/
-
-/*N*/ void BVector (double x,
-/*N*/ int n,
-/*N*/ int k,
-/*N*/ double *b,
-/*N*/ double *t)
-/*N*/ {
-/*N*/ for (int i = 0;
-/*N*/ i <= n + k;
-/*N*/ i ++)
-/*N*/ b [i] = 0;
-/*N*/
-/*N*/ int i0 = (int) floor (x) + k - 1;
-/*N*/ b [i0] = 1;
-/*N*/
-/*N*/ for (int j = 2;
-/*N*/ j <= k;
-/*N*/ j ++)
-/*N*/ for (int i = 0;
-/*N*/ i <= i0;
-/*N*/ i ++)
-/*N*/ b [i] = TLeft (x, i, j, t) * b [i] + TRight (x, i, j, t) * b [i + 1];
-/*N*/ }
-
-/*************************************************************************
-|*
-|* Berechne einzelnen Punkt
-|*
-\************************************************************************/
-
-/*N*/ void BSPoint (int n,
-/*N*/ Point &p1,
-/*N*/ Point &p2,
-/*N*/ XPolygon &pKnownPoints,
-/*N*/ double *b)
-/*N*/ {
-/*N*/ for (int i = 0;
-/*N*/ i <= n;
-/*N*/ i ++)
-/*N*/ {
-/*N*/ p1.Y () = long(p1.Y () + b [i] * pKnownPoints [i].Y ());
-/*N*/ p2.Y () = long(p2.Y () + b [n - i] * pKnownPoints [i].Y ());
-/*N*/ }
-/*N*/ }
-
-/*************************************************************************
-|*
-|* Berechne B-Spline
-|*
-\************************************************************************/
-
-/*N*/ void approxMesh (int splineSize,
-/*N*/ XPolygon &pSplines,
-/*N*/ XPolygon &pKnownPoints,
-/*N*/ int n,
-/*N*/ int k)
-/*N*/ {
-/*N*/ int pCount = splineSize * n;
-/*N*/ double *b = new double [n + k + 1];
-/*N*/ double *t = new double [n + k + 2];
-/*N*/ double xStep = ((double) n - (double) k + 2.0) / (double) pCount;
-/*N*/ double dStep = ((double) pKnownPoints [n].X () - (double) pKnownPoints [0].X ()) / (double) pCount;
-/*N*/ double dXUp = pKnownPoints [0].X ();
-/*N*/ double dXDown = pKnownPoints [n].X ();
-/*N*/ double x = 0.0;
-/*N*/ int nEnd = pCount / 2 + 1;
-/*N*/
-/*N*/ TVector (n, k, t);
-/*N*/
-/*N*/ for (int j = 0;
-/*N*/ j <= nEnd;
-/*N*/ j ++)
-/*N*/ {
-/*N*/ Point aPoint1;
-/*N*/ Point aPoint2;
-/*N*/
-/*N*/ BVector (x, n, k, b, t);
-/*N*/ BSPoint (n, aPoint1, aPoint2, pKnownPoints, b);
-/*N*/
-/*N*/ pSplines [j].X () = (int)(floor(dXUp)+0.5);
-/*N*/ pSplines [j].Y () = aPoint1.Y ();
-/*N*/ pSplines [pCount - j].X () = (int)(floor(dXDown)+0.5);
-/*N*/ pSplines [pCount - j].Y () = aPoint2.Y ();
-/*N*/
-/*N*/ x += xStep;
-/*N*/ dXUp += dStep;
-/*N*/ dXDown -= dStep;
-/*N*/ }
-/*N*/
-/*N*/ delete[] t;
-/*N*/ delete[] b;
-/*N*/ }
-
/*************************************************************************
|*
|* Passe untere Grenze an den Wertebereich an
diff --git a/binfilter/bf_sch/source/core/sch_memchrt.cxx b/binfilter/bf_sch/source/core/sch_memchrt.cxx
index 3fc12d1f1..b5df29611 100644
--- a/binfilter/bf_sch/source/core/sch_memchrt.cxx
+++ b/binfilter/bf_sch/source/core/sch_memchrt.cxx
@@ -36,6 +36,7 @@
#include <functional>
#include <algorithm>
+
namespace binfilter {
// ========================================
@@ -149,14 +150,14 @@ namespace binfilter {
/*N*/ {
/*N*/ nRowCnt = nRows;
/*N*/ nColCnt = nCols;
-/*N*/ pData = new double[nColCnt * nRowCnt];
-/*N*/
-/*N*/ pRowNumFmtId= new sal_Int32 [nRowCnt];
-/*N*/ pColNumFmtId= new sal_Int32 [nColCnt];
+ pData = ArrayHelper< double >::create_short_size( nColCnt, nRowCnt );
+
+ pRowNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nRowCnt );
+ pColNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nColCnt );
/*N*/ InitNumFmt();
-/*N*/
-/*N*/ pRowTable = new sal_Int32 [nRowCnt];
-/*N*/ pColTable = new sal_Int32 [nColCnt];
+
+ pRowTable = ArrayHelper< sal_Int32 >::create_short_size( nRowCnt );
+ pColTable = ArrayHelper< sal_Int32 >::create_short_size( nColCnt );
/*N*/ ResetTranslation(pRowTable,nRowCnt);
/*N*/ ResetTranslation(pColTable,nColCnt);
/*N*/
@@ -169,8 +170,29 @@ namespace binfilter {
/*N*/ *(pFill ++) = 0.0;
/*N*/ }
/*N*/
-/*N*/ pColText = new String[nColCnt];
-/*N*/ pRowText = new String[nRowCnt];
+ pColText = ArrayHelper< String >::create_short_size( nColCnt );
+ pRowText = ArrayHelper< String >::create_short_size( nRowCnt );
+
+ if ( !pData || !pRowNumFmtId || !pColNumFmtId || !pRowTable || !pColTable || !pColText || !pRowText )
+ {
+ delete[] pData;
+ pData = 0;
+ delete[] pRowNumFmtId;
+ pRowNumFmtId = 0;
+ delete[] pColNumFmtId;
+ pColNumFmtId = 0;
+ delete[] pRowTable;
+ pRowTable = 0;
+ delete[] pColTable;
+ pColTable = 0;
+ delete[] pColText;
+ pColText = 0;
+ delete[] pRowText;
+ pRowText = 0;
+
+ nRowCnt = 0;
+ nColCnt = 0;
+ }
/*N*/ }
/*************************************************************************
|*
@@ -194,10 +216,20 @@ namespace binfilter {
/*N*/ long nRows=MIN(nRowCnt,rMemChart.nRowCnt);
/*N*/
/*N*/ short i;
-/*N*/ for (i = 0; i < nCols; i++)
-/*N*/ pColText[i] = rMemChart.pColText[i];
-/*N*/ for (i = 0; i < nRows; i++)
-/*N*/ pRowText[i] = rMemChart.pRowText[i];
+ if ( pColText )
+ {
+ for ( i = 0; i < nCols; i++ )
+ {
+ pColText[i] = rMemChart.pColText[i];
+ }
+ }
+ if ( pRowText )
+ {
+ for ( i = 0; i < nRows; i++ )
+ {
+ pRowText[i] = rMemChart.pRowText[i];
+ }
+ }
/*N*/
/*N*/ // copy chart range
/*N*/ SetChartRange( rMemChart.GetChartRange());
@@ -232,27 +264,33 @@ namespace binfilter {
/*N*/ aSomeData2 = ((SchMemChart&) rMemChart).SomeData2 ();
/*N*/ aSomeData3 = ((SchMemChart&) rMemChart).SomeData3 ();
/*N*/ aSomeData4 = ((SchMemChart&) rMemChart).SomeData4 ();
-/*N*/ pData = new double[nColCnt * nRowCnt];
-/*N*/
-/*N*/ pRowNumFmtId= new sal_Int32 [nRowCnt];
-/*N*/ pColNumFmtId= new sal_Int32 [nColCnt];
-/*N*/ pRowTable = new sal_Int32 [nRowCnt];
-/*N*/ pColTable = new sal_Int32 [nColCnt];
+ pData = ArrayHelper< double >::create_short_size( nColCnt, nRowCnt );
+
+ pRowNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nRowCnt );
+ pColNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nColCnt );
+ pRowTable = ArrayHelper< sal_Int32 >::create_short_size( nRowCnt );
+ pColTable = ArrayHelper< sal_Int32 >::create_short_size( nColCnt );
/*N*/
/*N*/ aAppLink = rMemChart.aAppLink;
/*N*/ nLastSelInfoReturn = rMemChart.nLastSelInfoReturn;
/*N*/
/*N*/ nTranslated = rMemChart.nTranslated;
-/*N*/ for(long i=0;i<nColCnt;i++)
-/*N*/ {
-/*N*/ pColTable[i] = rMemChart.pColTable[i];
-/*N*/ pColNumFmtId[i] = rMemChart.pColNumFmtId[i];
-/*N*/ }
-/*N*/ for(long i=0;i<nRowCnt;i++)
-/*N*/ {
-/*N*/ pRowTable[i] = rMemChart.pRowTable[i];
-/*N*/ pRowNumFmtId[i] = rMemChart.pRowNumFmtId[i];
-/*N*/ }
+ if ( pColTable && pColNumFmtId )
+ {
+ for (long i = 0; i < nColCnt; i++)
+ {
+ pColTable[i] = rMemChart.pColTable[i];
+ pColNumFmtId[i] = rMemChart.pColNumFmtId[i];
+ }
+ }
+ if ( pRowTable && pRowNumFmtId )
+ {
+ for (long i = 0; i < nRowCnt; i++)
+ {
+ pRowTable[i] = rMemChart.pRowTable[i];
+ pRowNumFmtId[i] = rMemChart.pRowNumFmtId[i];
+ }
+ }
/*N*/ mpNumFormatter=rMemChart.mpNumFormatter;
/*N*/
/*N*/ if (pData)
@@ -265,15 +303,23 @@ namespace binfilter {
/*N*/ *(pDest ++) = *(pSource ++);
/*N*/ }
/*N*/
-/*N*/ pColText = new String[nColCnt];
-/*N*/
-/*N*/ for (long i = 0; i < nColCnt; i++)
-/*N*/ pColText[i] = rMemChart.pColText[i];
-/*N*/
-/*N*/ pRowText = new String[nRowCnt];
-/*N*/
-/*N*/ for (long i = 0; i < nRowCnt; i++)
-/*N*/ pRowText[i] = rMemChart.pRowText[i];
+ pColText = ArrayHelper< String >::create_short_size( nColCnt );
+ if ( pColText )
+ {
+ for (long i = 0; i < nColCnt; i++)
+ {
+ pColText[i] = rMemChart.pColText[i];
+ }
+ }
+
+ pRowText = ArrayHelper< String >::create_short_size( nRowCnt );
+ if ( pRowText )
+ {
+ for (long i = 0; i < nRowCnt; i++)
+ {
+ pRowText[i] = rMemChart.pRowText[i];
+ }
+ }
/*N*/
/*N*/ bReadOnly = rMemChart.bReadOnly; // bm #69410#
/*N*/
@@ -283,6 +329,27 @@ namespace binfilter {
/*N*/
/*N*/ // copy chart range
/*N*/ SetChartRange( rMemChart.GetChartRange());
+
+ if ( !pData || !pRowNumFmtId || !pColNumFmtId || !pRowTable || !pColTable || !pColText || !pRowText )
+ {
+ delete[] pData;
+ pData = 0;
+ delete[] pRowNumFmtId;
+ pRowNumFmtId = 0;
+ delete[] pColNumFmtId;
+ pColNumFmtId = 0;
+ delete[] pRowTable;
+ pRowTable = 0;
+ delete[] pColTable;
+ pColTable = 0;
+ delete[] pColText;
+ pColText = 0;
+ delete[] pRowText;
+ pRowText = 0;
+
+ nRowCnt = 0;
+ nColCnt = 0;
+ }
/*N*/ }
//Überprüft, ob die Umordnung/Translation OK ist, Fehlerfall, wenn :
@@ -297,7 +364,7 @@ namespace binfilter {
/*N*/ BOOL SchMemChart::VerifyTranslation()
/*N*/ {
/*N*/ //Fehler ?
-/*N*/ if(nTranslated!=TRANS_COL)
+/*N*/ if(nTranslated!=TRANS_COL && pColTable)
/*N*/ {
/*N*/ for(long nCol=0;nCol<nColCnt;nCol++)
/*N*/ {
@@ -317,7 +384,7 @@ namespace binfilter {
/*N*/ }
/*N*/ }
/*N*/ }
-/*N*/ if(nTranslated!=TRANS_ROW)
+/*N*/ if(nTranslated!=TRANS_ROW && pRowTable)
/*N*/ {
/*N*/ for(long nRow=0;nRow<nRowCnt;nRow++)
/*N*/ {
@@ -339,7 +406,7 @@ namespace binfilter {
/*N*/ }
/*N*/
/*N*/ // Sortierung besteht noch ?
-/*N*/ if(nTranslated==TRANS_ROW)
+/*N*/ if(nTranslated==TRANS_ROW && pRowTable)
/*N*/ {
/*?*/ for(long nRow=0;nRow<nRowCnt;nRow++)
/*?*/ {
@@ -347,7 +414,7 @@ namespace binfilter {
/*?*/ return TRUE;
/*?*/ }
/*N*/ }
-/*N*/ if(nTranslated==TRANS_COL)
+/*N*/ if(nTranslated==TRANS_COL && pColTable)
/*N*/ {
/*?*/ for(long nCol=0;nCol<nColCnt;nCol++)
/*?*/ {
@@ -369,32 +436,84 @@ namespace binfilter {
/*N*/ double SchMemChart::GetTransData(long nCol,long nRow)
/*N*/ {
/*N*/ DBG_ASSERT(VerifyTranslation(), "Translation table corrupted in MemChart");
+ if ( !pColTable || !pRowTable || !IsValidColumn( nCol ) || !IsValidRow( nRow ) )
+ {
+ return DBL_MIN;
+ }
/*N*/ return GetData( (short)pColTable[nCol], (short)pRowTable[nRow]);
/*N*/ }
/*N*/ double SchMemChart::GetTransDataInPercent(long nCol, long nRow, BOOL bRowData) const
/*N*/ {
/*N*/ DBG_ASSERT(((SchMemChart*)this)->VerifyTranslation(), "Translation table corrupted in MemChart");
+ if ( !pColTable || !pRowTable || !IsValidColumn( nCol ) || !IsValidRow( nRow ) )
+ {
+ return DBL_MIN;
+ }
/*N*/ return GetDataInPercent( (short)pColTable[nCol], (short)pRowTable[nRow], bRowData);
/*N*/ }
/*N*/ const String& SchMemChart::GetTransColText(long nCol) const
/*N*/ {
/*N*/ DBG_ASSERT(((SchMemChart*)this)->VerifyTranslation(), "Translation table corrupted in MemChart");
+ if ( !pColTable || !IsValidColumn( nCol ) )
+ {
+ return String::EmptyString();
+ }
/*N*/ return GetColText( (short)pColTable[nCol] );
/*N*/ }
/*N*/ const String& SchMemChart::GetTransRowText(long nRow) const
/*N*/ {
/*N*/ DBG_ASSERT(((SchMemChart*)this)->VerifyTranslation(), "Translation table corrupted in MemChart");
+ if ( !pRowTable || !IsValidRow( nRow ) )
+ {
+ return String::EmptyString();
+ }
/*N*/ return GetRowText( (short)pRowTable[nRow] );
/*N*/ }
/*N*/ long SchMemChart::GetTransNumFormatIdRow(const long nRow) const
/*N*/ {
/*N*/ DBG_ASSERT(((SchMemChart*)this)->VerifyTranslation(), "Translation table corrupted in MemChart");
-/*N*/ return ( nTranslated == TRANS_ROW )? pRowNumFmtId[ pRowTable[ nRow ]]: pRowNumFmtId[ nRow ];
+ if ( pRowNumFmtId && IsValidRow( nRow ) )
+ {
+ if ( nTranslated == TRANS_ROW )
+ {
+ if ( pRowTable )
+ {
+ long nTransRow = pRowTable[ nRow ];
+ if ( IsValidRow( nTransRow ) )
+ {
+ return pRowNumFmtId[ nTransRow ];
+ }
+ }
+ }
+ else
+ {
+ return pRowNumFmtId[ nRow ];
+ }
+ }
+ return NUMBERFORMAT_UNDEFINED;
/*N*/ }
/*N*/ long SchMemChart::GetTransNumFormatIdCol(const long nCol) const
/*N*/ {
/*N*/ DBG_ASSERT(((SchMemChart*)this)->VerifyTranslation(), "Translation table corrupted in MemChart");
-/*N*/ return ( nTranslated == TRANS_COL ) ? pColNumFmtId[ pColTable[ nCol ]]: pColNumFmtId[ nCol ];
+ if ( pColNumFmtId && IsValidColumn( nCol ) )
+ {
+ if ( nTranslated == TRANS_COL )
+ {
+ if ( pColTable )
+ {
+ long nTransCol = pColTable[ nCol ];
+ if ( IsValidColumn( nTransCol ) )
+ {
+ return pColNumFmtId[ nTransCol ];
+ }
+ }
+ }
+ else
+ {
+ return pColNumFmtId[ nCol ];
+ }
+ }
+ return NUMBERFORMAT_UNDEFINED;
/*N*/ }
@@ -455,9 +574,16 @@ namespace binfilter {
/*N*/ double *pOut = rMemChart.pData;
/*N*/
/*N*/ short i;
-/*N*/ for (i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ for (short j = 0; j < rMemChart.nRowCnt; j++)
-/*N*/ rOut << *(pOut ++);
+ if ( pOut )
+ {
+ for ( i = 0; i < rMemChart.nColCnt; i++ )
+ {
+ for ( short j = 0; j < rMemChart.nRowCnt; j++ )
+ {
+ rOut << *(pOut ++);
+ }
+ }
+ }
/*N*/
/*N*/ rOut << (INT16)aSysCharSet;
/*N*/ rOut.WriteUniOrByteString( rMemChart.aMainTitle, rOut.GetStreamCharSet() );
@@ -466,21 +592,41 @@ namespace binfilter {
/*N*/ rOut.WriteUniOrByteString( rMemChart.aYAxisTitle, rOut.GetStreamCharSet() );
/*N*/ rOut.WriteUniOrByteString( rMemChart.aZAxisTitle, rOut.GetStreamCharSet() );
/*N*/
-/*N*/ for (i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ rOut.WriteUniOrByteString( rMemChart.pColText[ i ], rOut.GetStreamCharSet() );
-/*N*/
-/*N*/ for (i = 0; i < rMemChart.nRowCnt; i++)
-/*N*/ rOut.WriteUniOrByteString( rMemChart.pRowText[ i ], rOut.GetStreamCharSet() );
+ if ( rMemChart.pColText )
+ {
+ for ( i = 0; i < rMemChart.nColCnt; i++ )
+ {
+ rOut.WriteUniOrByteString( rMemChart.pColText[ i ], rOut.GetStreamCharSet() );
+ }
+ }
+
+ if ( rMemChart.pRowText )
+ {
+ for ( i = 0; i < rMemChart.nRowCnt; i++ )
+ {
+ rOut.WriteUniOrByteString( rMemChart.pRowText[ i ], rOut.GetStreamCharSet() );
+ }
+ }
/*N*/
/*N*/ rOut << (INT16)rMemChart.eDataType;
/*N*/
/*N*/ //IOVersion = 1
/*N*/ long nIndex;
-/*N*/ for (nIndex = 0; nIndex < rMemChart.nColCnt; nIndex++)
-/*N*/ rOut << rMemChart.pColTable[nIndex];
-/*N*/
-/*N*/ for (nIndex = 0; nIndex < rMemChart.nRowCnt; nIndex++)
-/*N*/ rOut << rMemChart.pRowTable[nIndex];
+ if ( rMemChart.pColTable )
+ {
+ for ( nIndex = 0; nIndex < rMemChart.nColCnt; nIndex++ )
+ {
+ rOut << rMemChart.pColTable[nIndex];
+ }
+ }
+
+ if ( rMemChart.pRowTable )
+ {
+ for ( nIndex = 0; nIndex < rMemChart.nRowCnt; nIndex++ )
+ {
+ rOut << rMemChart.pRowTable[nIndex];
+ }
+ }
/*N*/
/*N*/ //IOVersion = 2
/*N*/ rOut << rMemChart.nTranslated;
@@ -501,16 +647,35 @@ namespace binfilter {
/*N*/
/*N*/ SchIOCompat aIO(rIn, STREAM_READ);
/*N*/
-/*N*/ rIn >> nInt16; rMemChart.nColCnt = (short)nInt16;
-/*N*/ rIn >> nInt16; rMemChart.nRowCnt = (short)nInt16;
-/*N*/
-/*N*/ rMemChart.pData = new double[rMemChart.nColCnt * rMemChart.nRowCnt];
-/*N*/
-/*N*/ double *pIn = rMemChart.pData;
-/*N*/
-/*N*/ for (short i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ for (short j = 0; j < rMemChart.nRowCnt; j++)
-/*N*/ rIn >> *(pIn ++);
+ short nCols=0;
+ short nRows=0;
+/*N*/ rIn >> nInt16; nCols = static_cast<short>(nInt16);
+/*N*/ rIn >> nInt16; nRows = static_cast<short>(nInt16);
+/*N*/
+ double* pTmpData = ArrayHelper< double >::create_short_size( nCols, nRows );
+ if ( !pTmpData )
+ {
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return rIn;
+ }
+
+ rMemChart.nColCnt = nCols;
+ rMemChart.nRowCnt = nRows;
+
+ delete[] rMemChart.pData;
+ rMemChart.pData = pTmpData;
+
+ double *pIn = rMemChart.pData;
+ if ( pIn )
+ {
+ for (short i = 0; i < rMemChart.nColCnt; i++)
+ {
+ for ( short j = 0; j < rMemChart.nRowCnt; j++ )
+ {
+ rIn >> *(pIn ++);
+ }
+ }
+ }
/*N*/
/*N*/ INT16 nCharSet;
/*N*/ rIn >> nCharSet;
@@ -524,34 +689,74 @@ namespace binfilter {
/*N*/ rMemChart.aYAxisTitle = rIn.ReadUniOrByteString( rIn.GetStreamCharSet() );
/*N*/ rMemChart.aZAxisTitle = rIn.ReadUniOrByteString( rIn.GetStreamCharSet() );
/*N*/
-/*N*/ rMemChart.pColText = new String[rMemChart.nColCnt];
-/*N*/
-/*N*/ for (short i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ {
-/*N*/ rMemChart.pColText[ i ] = rIn.ReadUniOrByteString( rIn.GetStreamCharSet() );
-/*N*/ }
-/*N*/
-/*N*/ rMemChart.pRowText = new String[rMemChart.nRowCnt];
-/*N*/
-/*N*/ for (short i = 0; i < rMemChart.nRowCnt; i++)
-/*N*/ {
-/*N*/ rMemChart.pRowText[ i ] = rIn.ReadUniOrByteString( rIn.GetStreamCharSet() );
-/*N*/ }
+ delete[] rMemChart.pColText;
+ rMemChart.pColText = ArrayHelper< String >::create_short_size( rMemChart.nColCnt );
+ if ( !rMemChart.pColText )
+ {
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return rIn;
+ }
+ for (short i = 0; i < rMemChart.nColCnt; i++ )
+ {
+ rMemChart.pColText[ i ] = rIn.ReadUniOrByteString( rIn.GetStreamCharSet() );
+ }
+
+ delete[] rMemChart.pRowText;
+ rMemChart.pRowText = ArrayHelper< String >::create_short_size( rMemChart.nRowCnt );
+ if ( !rMemChart.pRowText )
+ {
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return rIn;
+ }
+ for (short i = 0; i < rMemChart.nRowCnt; i++ )
+ {
+ rMemChart.pRowText[ i ] = rIn.ReadUniOrByteString( rIn.GetStreamCharSet() );
+ }
/*N*/
/*N*/ rIn >> nInt16; rMemChart.eDataType = (short)nInt16;
/*N*/
-/*N*/ rMemChart.pRowNumFmtId = new sal_Int32 [rMemChart.nRowCnt];
-/*N*/ rMemChart.pColNumFmtId = new sal_Int32 [rMemChart.nColCnt];
-/*N*/ rMemChart.pRowTable = new sal_Int32 [rMemChart.nRowCnt];
-/*N*/ rMemChart.pColTable = new sal_Int32 [rMemChart.nColCnt];
+ delete[] rMemChart.pRowNumFmtId;
+ rMemChart.pRowNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( rMemChart.nRowCnt );
+ if ( !rMemChart.pRowNumFmtId )
+ {
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return rIn;
+ }
+
+ delete[] rMemChart.pColNumFmtId;
+ rMemChart.pColNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( rMemChart.nColCnt );
+ if ( !rMemChart.pColNumFmtId )
+ {
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return rIn;
+ }
+
+ delete[] rMemChart.pRowTable;
+ rMemChart.pRowTable = ArrayHelper< sal_Int32 >::create_short_size( rMemChart.nRowCnt );
+ if ( !rMemChart.pRowTable )
+ {
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return rIn;
+ }
+
+ delete[] rMemChart.pColTable;
+ rMemChart.pColTable = ArrayHelper< sal_Int32 >::create_short_size( rMemChart.nColCnt );
+ if ( !rMemChart.pColTable )
+ {
+ rIn.SetError( ERRCODE_IO_GENERAL );
+ return rIn;
+ }
/*N*/
/*N*/ if(aIO.GetVersion()>=1)
/*N*/ {
-/*N*/ for (long i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ rIn >> rMemChart.pColTable[i];
-/*N*/
-/*N*/ for (long i = 0; i < rMemChart.nRowCnt; i++)
-/*N*/ rIn >> rMemChart.pRowTable[i];
+ for (long i = 0; i < rMemChart.nColCnt; i++)
+ {
+ rIn >> rMemChart.pColTable[i];
+ }
+ for (long i = 0; i < rMemChart.nRowCnt; i++)
+ {
+ rIn >> rMemChart.pRowTable[i];
+ }
/*N*/
/*N*/ if(aIO.GetVersion()>=2)
/*N*/ rIn >> rMemChart.nTranslated;
@@ -579,11 +784,21 @@ namespace binfilter {
/*N*/ void SchMemChart::InitNumFmt()
/*N*/ {
/*N*/ long i;
-/*N*/ for(i=0;i<nColCnt;i++)
-/*N*/ pColNumFmtId[i]=-1; //uninitialised!
-/*N*/
-/*N*/ for(i=0;i<nRowCnt;i++)
-/*N*/ pRowNumFmtId[i]=-1;
+ if ( pColNumFmtId )
+ {
+ for ( i = 0; i < nColCnt; i++ )
+ {
+ pColNumFmtId[i] = -1; //uninitialised!
+ }
+ }
+
+ if ( pRowNumFmtId )
+ {
+ for ( i = 0; i < nRowCnt; i++ )
+ {
+ pRowNumFmtId[i] = -1;
+ }
+ }
/*N*/ }
diff --git a/binfilter/inc/bf_sch/arrayhelper.hxx b/binfilter/inc/bf_sch/arrayhelper.hxx
new file mode 100644
index 000000000..85b01c529
--- /dev/null
+++ b/binfilter/inc/bf_sch/arrayhelper.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+#ifndef _SCH_ARRAYHELPER_HXX
+#define _SCH_ARRAYHELPER_HXX
+
+#include <limits>
+
+namespace binfilter {
+
+/** Helper class for creating an array of type T and size nSize.
+ The create methods are protected against integer overflow in
+ operator new[].
+ */
+template< typename T >
+class ArrayHelper
+{
+public:
+ static T* create_short_size( short n );
+ static T* create_short_size( short m, short n );
+ static T* create_long_size( long n );
+ static T* create_long_size( long m, long n );
+};
+
+template< typename T >
+T* ArrayHelper< T >::create_short_size( short n )
+{
+ T* pRet = 0;
+ if ( n > 0 &&
+ static_cast< unsigned short >( n ) <= ( ::std::numeric_limits< size_t >::max() / sizeof( T ) ) )
+ {
+ pRet = new (std::nothrow) T[ n ];
+ }
+ return pRet;
+}
+
+template< typename T >
+T* ArrayHelper< T >::create_short_size( short m, short n )
+{
+ T* pRet = 0;
+ if ( m > 0 && n > 0 &&
+ static_cast< unsigned short >( m ) <= ( ( ::std::numeric_limits< size_t >::max() / n ) / sizeof( T ) ) )
+ {
+ pRet = new (std::nothrow) T[ static_cast< size_t >( m ) * n ];
+ }
+ return pRet;
+}
+
+template< typename T >
+T* ArrayHelper< T >::create_long_size( long n )
+{
+ T* pRet = 0;
+ if ( n > 0 &&
+ static_cast< unsigned long >( n ) <= ( ::std::numeric_limits< size_t >::max() / sizeof( T ) ) )
+ {
+ pRet = new (std::nothrow) T[ n ];
+ }
+ return pRet;
+}
+
+template< typename T >
+T* ArrayHelper< T >::create_long_size( long m, long n )
+{
+ T* pRet = 0;
+ if ( m > 0 && n > 0 &&
+ static_cast< unsigned long >( m ) <= ( ( ::std::numeric_limits< size_t >::max() / n ) / sizeof( T ) ) )
+ {
+ pRet = new (std::nothrow) T[ static_cast< size_t >( m ) * n ];
+ }
+ return pRet;
+}
+
+} //namespace binfilter
+#endif
diff --git a/binfilter/inc/bf_sch/calculat.hxx b/binfilter/inc/bf_sch/calculat.hxx
index 3f48c13c7..8fb4d4687 100644
--- a/binfilter/inc/bf_sch/calculat.hxx
+++ b/binfilter/inc/bf_sch/calculat.hxx
@@ -41,23 +41,6 @@ class XPolyPolygon;
class SchCalculationHelper
{
public:
- /** like Rectangle::IsInside, but the result is FALSE, if
- the Point is on the Border of the Rectangle
- */
-// static BOOL IsPointInsideRectangle( const Point& rPoint, const Rectangle& rRect );
-
- /** @descr The line is clipped at the rectangle. If the line lies completely or partly
- inside the clipping area then TRUE is returned and the line is modified accordingly.
- If the line lies completely outside the clipping area then FALSE is returned and the
- line remains unmodified.
- The line may be degenerate in that both of it's end points have the same
- coordinates.
- @param aLine The line to be clipped. It is modified to a part that lies completely
- inside the clipping area if such a part exists.
- @param rRectangle The clipping area.
- @return TRUE is returned if the line lies completely or partly inside the clipping area.
- */
-
/** @descr The intersection between an open polygon and a rectangle is
calculated and the resulting lines are placed into the poly-polygon aResult.
@param rPolygon The polygon is required to be open, ie. it's start and end point
@@ -69,35 +52,6 @@ public:
static void IntersectPolygonWithRectangle( const XPolygon& rPolygon, const Rectangle& rRectangle,
XPolyPolygon& aResult );
- /** @descr Calculates the intersection between a set of open polygons and a
- rectangle. This function iterates over all polygons contained in
- rPolyPolygon and calls IntersectPolygonWithRectangle() for it.
- The resulting XPolyPolygons are then put together into aResult.
- @param rPolyPolygon A set of polygons that must be open.
- @param rRectangle The clipping region
- @param rOutResult The resulting lines representing rPolyPolygon clipped
- at rRectangle.
- */
-
- /** @descr calculates natural cubic splines for the given set of points.
-
- @param rPoints is a vector of tuples containing x and y coordinate of
- points that are to be interpolated.
- @param nGranularity The number of interpolation points between two
- x-values given in rPoints
-
- @param rOutResult A polygon (split up into more, if the number of points
- is too high as to fit into a single XPolygon) that contains all
- line segments between the interpolated points. It should contain
- (rPoints.size() * nGranularity) points.
-
- @param nDPIX resolution in x-direction to reduce the number of points.
- A value of 0 (default) means do not take into account.
-
- @param nDPIY resolution in y-direction to reduce the number of points.
- A value of 0 (default) means do not take into account.
- */
-
private:
/** @descr The line given by it's two endpoints rP0 and rP1 is clipped at the rectangle
rRectangle. If there is at least a part of it visible then TRUE is returned and
diff --git a/binfilter/inc/bf_sch/chtmodel.hxx b/binfilter/inc/bf_sch/chtmodel.hxx
index 838e0eada..a86ee8daa 100644
--- a/binfilter/inc/bf_sch/chtmodel.hxx
+++ b/binfilter/inc/bf_sch/chtmodel.hxx
@@ -64,7 +64,6 @@ class SvNumberFormatterIndexTable;
class SdrObjGroup;
class SdrRectObj;
-class SchModelData;
class SchObjectId;
class ChartAxis;
class SchItemPool;
@@ -545,6 +544,8 @@ public:
inline BOOL GetUseRelativePositions() { return bUseRelativePositionsForChartGroups; }
void SetUseRelativePositions( BOOL value );
+ static Point calcRelativePosition( const Point& rStartPoint, const Size& rInitialSize, const Size& rNewSize );
+
void SetAdjustMarginsForLegend( BOOL value ) { bAdjustMarginsForLegend = value; }
BOOL GetAdjustMarginsForLegend() { return bAdjustMarginsForLegend; }
@@ -653,8 +654,6 @@ public:
friend SvStream & operator << ( SvStream & rOut, const ChartModel & rDoc );
friend SvStream & operator >> ( SvStream & rIn, ChartModel & rDoc );
- friend class SchModelData;
-
// protected:
// remark: currently there are no classes that are derived from ChartModel
// and also the distinction between private and protected was not very
diff --git a/binfilter/inc/bf_sch/globfunc.hxx b/binfilter/inc/bf_sch/globfunc.hxx
index af8306f9a..25a3246bc 100644
--- a/binfilter/inc/bf_sch/globfunc.hxx
+++ b/binfilter/inc/bf_sch/globfunc.hxx
@@ -70,44 +70,6 @@ SchObjGroup *CreateSimpleGroup (UINT16 nID,
BOOL bProtect,
BOOL bResize);
-
-void CubicSpline (XPolygon &pKnownPoints,
- int n,
- int splineSize,
- XPolygon &pSplines);
-
-void TVector (int n,
- int k,
- double *t);
-
-double TLeft (double x,
- int i,
- int k,
- double *t);
-
-double TRight (double x,
- int i,
- int k,
- double *t);
-
-void BVector (double x,
- int n,
- int k,
- double *b,
- double *t);
-
-void BSPoint (int n,
- Point &p1,
- Point &p2,
- XPolygon &pKnownPoints,
- double *b);
-
-void approxMesh (int splineSize,
- XPolygon &pSplines,
- XPolygon &pKnownPoints,
- int n,
- int k);
-
double SizeBounds (double,
double,
BOOL);
diff --git a/binfilter/inc/bf_sch/memchrt.hxx b/binfilter/inc/bf_sch/memchrt.hxx
index eb9553030..9c0e1ad52 100644
--- a/binfilter/inc/bf_sch/memchrt.hxx
+++ b/binfilter/inc/bf_sch/memchrt.hxx
@@ -31,6 +31,9 @@
#include <bf_sch/cellranges.hxx>
#include <com/sun/star/chart/ChartSeriesAddress.hpp>
+
+#include "arrayhelper.hxx"
+
class SvStream;
namespace binfilter {
@@ -277,10 +280,10 @@ public:
void SetNumberFormatter(SvNumberFormatter* pNumFormatter) { mpNumFormatter = pNumFormatter; }
SvNumberFormatter* GetNumberFormatter() const { return mpNumFormatter; }
- void SetNumFormatIdRow( const long nRow, const long nFmtId ) { if( pRowNumFmtId && nRow < nRowCnt ) pRowNumFmtId[ nRow ] = nFmtId; }
- void SetNumFormatIdCol( const long nCol, const long nFmtId ) { if( pColNumFmtId && nCol < nColCnt ) pColNumFmtId[ nCol ] = nFmtId; }
- long GetNumFormatIdRow( const long nRow ) const { return ( pRowNumFmtId && nRow < nRowCnt )? pRowNumFmtId[ nRow ]: -1; }
- long GetNumFormatIdCol( const long nCol ) const { return ( pColNumFmtId && nCol < nColCnt )? pColNumFmtId[ nCol ]: -1; }
+ void SetNumFormatIdRow( const long nRow, const long nFmtId ) { if ( pRowNumFmtId && IsValidRow( nRow ) ) pRowNumFmtId[ nRow ] = nFmtId; }
+ void SetNumFormatIdCol( const long nCol, const long nFmtId ) { if ( pColNumFmtId && IsValidColumn( nCol ) ) pColNumFmtId[ nCol ] = nFmtId; }
+ long GetNumFormatIdRow( const long nRow ) const { return ( pRowNumFmtId && IsValidRow( nRow ) ) ? pRowNumFmtId[ nRow ] : -1; }
+ long GetNumFormatIdCol( const long nCol ) const { return ( pColNumFmtId && IsValidColumn( nCol ) ) ? pColNumFmtId[ nCol ] : -1; }
long GetTransNumFormatIdRow( const long nRow ) const;
long GetTransNumFormatIdCol( const long nCol ) const;
@@ -311,11 +314,11 @@ public:
friend SvStream& operator << (SvStream& rOut, const SchMemChart& rMemChart);
friend SvStream& operator >> (SvStream& rIn, SchMemChart& rMemChart);
- const String& GetColText(short nCol) const { return pColText[nCol]; }
- const String& GetRowText(short nRow) const { return pRowText[nRow]; }
+ const String& GetColText(short nCol) const { return ( pColText && IsValidColumn( nCol ) ) ? pColText[ nCol ] : String::EmptyString(); }
+ const String& GetRowText(short nRow) const { return ( pRowText && IsValidRow( nRow ) ) ? pRowText[ nRow ] : String::EmptyString(); }
ChartDataId GetId() const { return myID; }
- double GetData(short nCol, short nRow) const { return pData[nCol * nRowCnt + nRow]; }
+ double GetData(short nCol, short nRow) const { return ( pData && IsValidColumn( nCol ) && IsValidRow( nRow ) ) ? pData[nCol * nRowCnt + nRow] : DBL_MIN; }
double GetDataInPercent(const short nCol , const short nRow, const BOOL bRowData) const;
inline void InsertCols(short nAtCol, short nCount);
@@ -326,7 +329,7 @@ public:
inline void SwapRows(int nAtRow1, int nAtRow2);
void SetData(short nCol, short nRow, const double& rVal)
- { pData[nCol * nRowCnt + nRow] = rVal; }
+ { if ( pData && IsValidColumn( nCol ) && IsValidRow( nRow ) ) pData[nCol * nRowCnt + nRow] = rVal; }
String& SomeData1() { return aSomeData1; }
String& SomeData2() { return aSomeData2; }
@@ -338,8 +341,8 @@ public:
const String& SomeData3() const { return aSomeData3; }
const String& SomeData4() const { return aSomeData4; }
- void SetColText(short nCol, const String& rText) { pColText[nCol] = rText; }
- void SetRowText(short nRow, const String& rText) { pRowText[nRow] = rText; }
+ void SetColText(short nCol, const String& rText) { if ( pColText && IsValidColumn( nCol ) ) pColText[nCol] = rText; }
+ void SetRowText(short nRow, const String& rText) { if ( pRowText && IsValidRow( nRow ) ) pRowText[nRow] = rText; }
@@ -410,6 +413,9 @@ public:
for all table numbers to fit in
*/
void parseTableNumberList( const ::rtl::OUString& rList );
+
+ bool IsValidColumn( const long nCol ) const { return nCol >= 0 && nCol < nColCnt; }
+ bool IsValidRow( const long nRow ) const { return nRow >= 0 && nRow < nRowCnt; }
};
// ==================== Inline Implementations ====================
@@ -486,11 +492,37 @@ inline void SchMemChart::UpdateTranslation(sal_Int32 *pTable,long nCnt)
inline void SchMemChart::InsertCols(short nAtCol, short nCount)
{
- double* pOldData = pData;
-
+ if ( nAtCol < 0 || nAtCol > nColCnt )
+ {
+ return;
+ }
+ if ( nColCnt <= 0 || nCount < 0 ||
+ nCount > ( ::std::numeric_limits< short >::max() - nColCnt ) )
+ {
+ return;
+ }
short nNewColCnt = nColCnt + nCount;
- pData = new double[nNewColCnt * nRowCnt];
+ double* pOldData = pData;
+ String* pOldColText = pColText;
+ sal_Int32* pOldColNumFmtId = pColNumFmtId;
+ sal_Int32* pOldColTable = pColTable;
+ pData = ArrayHelper< double >::create_short_size( nNewColCnt, nRowCnt );
+ pColText = ArrayHelper< String >::create_short_size( nNewColCnt );
+ pColNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nNewColCnt );
+ pColTable = ArrayHelper< sal_Int32 >::create_short_size( nNewColCnt );
+ if ( !pData || !pColText || !pColNumFmtId || !pColTable )
+ {
+ delete[] pData;
+ pData = pOldData;
+ delete[] pColText;
+ pColText = pOldColText;
+ delete[] pColNumFmtId;
+ pColNumFmtId = pOldColNumFmtId;
+ delete[] pColTable;
+ pColTable = pOldColTable;
+ return;
+ }
short i, j, nOld, nMax;
@@ -521,14 +553,6 @@ inline void SchMemChart::InsertCols(short nAtCol, short nCount)
}
delete[] pOldData;
- String *pOldColText = pColText;
- sal_Int32 *pOldColNumFmtId = pColNumFmtId;
- sal_Int32 *pOldColTable = pColTable;
-
- pColNumFmtId = new sal_Int32 [nNewColCnt];
- pColTable = new sal_Int32 [nNewColCnt];
- pColText = new String[nNewColCnt];
-
long nC=nNewColCnt;
while(nC--)
{
@@ -561,21 +585,40 @@ inline void SchMemChart::RemoveCols(short nAtCol, short nCount)
{
DBG_ASSERT( nAtCol < nColCnt, "column index overflow");
+ if ( nAtCol < 0 || nAtCol >= nColCnt )
+ {
+ return;
+ }
+ if ( nColCnt <= 0 || nCount < 0 ||
+ nCount > ( ::std::numeric_limits< short >::max() - nAtCol ) )
+ {
+ return;
+ }
if (nAtCol + nCount > nColCnt)
nCount = nColCnt - nAtCol;
short nNewColCnt = nColCnt - nCount;
double* pOldData = pData;
- pData = new double[nNewColCnt * nRowCnt];
-
- String* pOldColText = pColText;
- sal_Int32* pOldColNumFmtId = pColNumFmtId;
+ String* pOldColText = pColText;
+ sal_Int32* pOldColNumFmtId = pColNumFmtId;
sal_Int32* pOldColTable = pColTable;
-
- pColText = new String[nNewColCnt];
- pColNumFmtId = new sal_Int32 [nNewColCnt];
- pColTable = new sal_Int32 [nNewColCnt];
+ pData = ArrayHelper< double >::create_short_size( nNewColCnt, nRowCnt );
+ pColText = ArrayHelper< String >::create_short_size( nNewColCnt );
+ pColNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nNewColCnt );
+ pColTable = ArrayHelper< sal_Int32 >::create_short_size( nNewColCnt );
+ if ( !pData || !pColText || !pColNumFmtId || !pColTable )
+ {
+ delete[] pData;
+ pData = pOldData;
+ delete[] pColText;
+ pColText = pOldColText;
+ delete[] pColNumFmtId;
+ pColNumFmtId = pOldColNumFmtId;
+ delete[] pColTable;
+ pColTable = pOldColTable;
+ return;
+ }
short i, j, nOld;
@@ -606,11 +649,37 @@ inline void SchMemChart::RemoveCols(short nAtCol, short nCount)
inline void SchMemChart::InsertRows(short nAtRow, short nCount)
{
- double* pOldData = pData;
-
+ if ( nAtRow < 0 || nAtRow > nRowCnt )
+ {
+ return;
+ }
+ if ( nRowCnt <= 0 || nCount < 0 ||
+ nCount > ( ::std::numeric_limits< short >::max() - nRowCnt ) )
+ {
+ return;
+ }
short nNewRowCnt = nRowCnt + nCount;
- pData = new double[nColCnt * nNewRowCnt];
+ double* pOldData = pData;
+ String* pOldRowText = pRowText;
+ sal_Int32* pOldRowNumFmtId = pRowNumFmtId;
+ sal_Int32* pOldRowTable = pRowTable;
+ pData = ArrayHelper< double >::create_short_size( nColCnt, nNewRowCnt );
+ pRowText = ArrayHelper< String >::create_short_size( nNewRowCnt );
+ pRowNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nNewRowCnt );
+ pRowTable = ArrayHelper< sal_Int32 >::create_short_size( nNewRowCnt );
+ if ( !pData || !pRowText || !pRowNumFmtId || !pRowTable )
+ {
+ delete[] pData;
+ pData = pOldData;
+ delete[] pRowText;
+ pRowText = pOldRowText;
+ delete[] pRowNumFmtId;
+ pRowNumFmtId = pOldRowNumFmtId;
+ delete[] pRowTable;
+ pRowTable = pOldRowTable;
+ return;
+ }
short i, j, nOld, nMax, nGapEnd;
@@ -643,14 +712,6 @@ inline void SchMemChart::InsertRows(short nAtRow, short nCount)
}
delete[] pOldData;
- String *pOldRowText =pRowText;
- sal_Int32 *pOldRowNumFmtId =pRowNumFmtId;
- sal_Int32 *pOldRowTable =pRowTable;
-
- pRowNumFmtId = new sal_Int32 [nNewRowCnt];
- pRowTable = new sal_Int32 [nNewRowCnt];
- pRowText = new String[nNewRowCnt];
-
long nC=nNewRowCnt;
while(nC--) //init
{
@@ -683,13 +744,40 @@ inline void SchMemChart::RemoveRows(short nAtRow, short nCount)
{
DBG_ASSERT( nAtRow < nRowCnt, "row index overflow" );
+ if ( nAtRow < 0 || nAtRow >= nRowCnt )
+ {
+ return;
+ }
+ if ( nRowCnt <= 0 || nCount < 0 ||
+ nCount > ( ::std::numeric_limits< short >::max() - nAtRow ) )
+ {
+ return;
+ }
if (nAtRow + nCount > nRowCnt)
nCount = nRowCnt - nAtRow;
short nNewRowCnt = nRowCnt - nCount;
double* pOldData = pData;
- pData = new double[nColCnt * nNewRowCnt];
+ String* pOldRowText = pRowText;
+ sal_Int32* pOldRowNumFmtId = pRowNumFmtId;
+ sal_Int32* pOldRowTable = pRowTable;
+ pData = ArrayHelper< double >::create_short_size( nColCnt, nNewRowCnt );
+ pRowText = ArrayHelper< String >::create_short_size( nNewRowCnt );
+ pRowNumFmtId = ArrayHelper< sal_Int32 >::create_short_size( nNewRowCnt );
+ pRowTable = ArrayHelper< sal_Int32 >::create_short_size( nNewRowCnt );
+ if ( !pData || !pRowText || !pRowNumFmtId || !pRowTable )
+ {
+ delete[] pData;
+ pData = pOldData;
+ delete[] pRowText;
+ pRowText = pOldRowText;
+ delete[] pRowNumFmtId;
+ pRowNumFmtId = pOldRowNumFmtId;
+ delete[] pRowTable;
+ pRowTable = pOldRowTable;
+ return;
+ }
short i, j, nOld;
@@ -706,14 +794,6 @@ inline void SchMemChart::RemoveRows(short nAtRow, short nCount)
delete[] pOldData;
- String* pOldRowText = pRowText;
- sal_Int32* pOldRowNumFmtId = pRowNumFmtId;
- sal_Int32* pOldRowTable = pRowTable;
-
- pRowText = new String[nNewRowCnt];
- pRowNumFmtId = new sal_Int32 [nNewRowCnt];
- pRowTable = new sal_Int32 [nNewRowCnt];
-
for (i = 0, nOld = 0;; i++, nOld++)
{
if (nOld == nAtRow)