incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1362838 [1/2] - in /incubator/ooo/trunk/main/binfilter: bf_sch/source/core/ inc/bf_sch/
Date Wed, 18 Jul 2012 10:05:59 GMT
Author: alg
Date: Wed Jul 18 10:05:58 2012
New Revision: 1362838

URL: http://svn.apache.org/viewvc?rev=1362838&view=rev
Log:
chart in binfilter made more safe
Patch by: iha

Modified:
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_calculat.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chartdoc.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chaxis.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod2a.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod3d.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode1.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode2.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode3.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode4.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode7.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode9.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_globfunc.cxx
    incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_memchrt.cxx
    incubator/ooo/trunk/main/binfilter/inc/bf_sch/calculat.hxx
    incubator/ooo/trunk/main/binfilter/inc/bf_sch/chtmodel.hxx
    incubator/ooo/trunk/main/binfilter/inc/bf_sch/globfunc.hxx
    incubator/ooo/trunk/main/binfilter/inc/bf_sch/memchrt.hxx

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_calculat.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_calculat.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_calculat.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_calculat.cxx Wed Jul 18 10:05:58 2012
@@ -37,13 +37,6 @@
 #include <rtl/logfile.hxx>
 #endif
 
-// 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>
@@ -197,9 +190,4 @@ using namespace ::std;
 
 // --------------------------------------------------------------------------------
 
-// Calculation of Splines
-
-
-// ----------------------------------------
-
 }

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chartdoc.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chartdoc.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chartdoc.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chartdoc.cxx Wed Jul 18 10:05:58 2012
@@ -271,6 +271,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();

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chaxis.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chaxis.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chaxis.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chaxis.cxx Wed Jul 18 10:05:58 2012
@@ -72,6 +72,7 @@
 #include <bf_svx/svxids.hrc>
 #endif
 
+#include "arrayhelper.hxx"
 #include "float.h"
 #include "chaxis.hxx"
 #include "pairs.hxx"
@@ -147,17 +148,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) :
@@ -293,14 +289,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*/ };
@@ -315,7 +315,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*/ {
@@ -342,7 +344,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*/ 			{
@@ -362,13 +364,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)
@@ -377,8 +379,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

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod2a.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod2a.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod2a.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod2a.cxx Wed Jul 18 10:05:58 2012
@@ -62,6 +62,7 @@
 
 #include "pairs.hxx"
 #include "globfunc.hxx"
+#include "arrayhelper.hxx"
 
 
 #ifndef _SVX_XLINIIT_HXX //autogen
@@ -320,9 +321,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*/ 
@@ -331,7 +332,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*/ 
@@ -597,8 +606,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*/ 
@@ -618,8 +633,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*/ 
@@ -660,7 +673,6 @@ namespace binfilter {
 // 			pStatLists[ nRow ]->NbcInsertObject( AverageValueY( nRow, FALSE, aRect,
            {DBG_BF_ASSERT(0, "STRIP"); }//STRIP001  pList->NbcInsertObject( AverageValueY( nRow, FALSE, aRect,
 
-/*N*/         aSplinePoints.clear();
 /*N*/ 
 /*N*/         for (nCol = 0; nCol < nColCnt; nCol++)
 /*N*/ 		{
@@ -688,13 +700,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;
@@ -740,28 +745,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))
-/*?*/                     {DBG_BF_ASSERT(0, "STRIP");
-/*?*/                     }
-/*?*/                     else
-/*?*/                     {
-/*?*/                         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*/ 
@@ -834,8 +818,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)
@@ -888,7 +878,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 (),
@@ -1120,11 +1110,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*/ 
@@ -1150,7 +1142,8 @@ namespace binfilter {
 /*N*/ 					}
 /*N*/ 				}
 /*N*/ 
-/*N*/ 				fOldData [nCol] = fData;
+                    if( fOldData )
+/*N*/ 				    fOldData [nCol] = fData;
 /*N*/ 
 /*N*/ 				ChartAdjust eAdjust;
 /*N*/ 

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod3d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod3d.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod3d.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmod3d.cxx Wed Jul 18 10:05:58 2012
@@ -73,6 +73,7 @@
 #include <bf_svx/xlnwtit.hxx>
 #endif
 
+#include "arrayhelper.hxx"
 #include "pairs.hxx"
 #include "chmod3d.hxx"
 #include "chaxis.hxx"
@@ -785,6 +786,8 @@ namespace binfilter {
 /*N*/ 	long	nRowCnt = GetRowCount();
 /*N*/ 	short	nCol, nRow;
 /*N*/ 
+        if( nColCnt<0 || (static_cast< unsigned long>(nColCnt) > (std::numeric_limits<sal_uInt16>::max()-1)/2) )
+            return (SdrObjGroup*) pScene;
 /*N*/ 	Polygon     aFrontExtrude(1+nColCnt*2);
 /*N*/ 
 /*N*/ 	long nGapX      = nW * nGapWidth / 1000;
@@ -1300,7 +1303,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++)
@@ -1433,7 +1438,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#)
@@ -2024,10 +2031,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*/ 			{
@@ -2056,10 +2060,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*/ 			{
@@ -2093,10 +2094,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*/ 			{

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode1.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode1.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode1.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode1.cxx Wed Jul 18 10:05:58 2012
@@ -110,6 +110,7 @@
 #include <bf_svx/xlnwtit.hxx>
 #endif
 
+#include "arrayhelper.hxx"
 #include "pairs.hxx"
 #include "datalog.hxx"
 
@@ -544,22 +545,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*/ 
@@ -854,13 +857,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( int i=0; i<nCount; i++ )
-/*N*/ 		{
-/*N*/ 			pDefaultCol[ i ] = aDefCols.GetColorData( i );
-/*N*/ 		}
+            if(pDefaultCol)
+            {
+/*N*/ 		    for( int i=0; i<nCount; i++ )
+/*N*/ 		    {
+/*N*/ 			    pDefaultCol[ i ] = aDefCols.GetColorData( i );
+/*N*/ 		    }
+            }
 /*N*/ 	}
 /*N*/ 	else
 /*N*/ 	{

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode2.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode2.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode2.cxx Wed Jul 18 10:05:58 2012
@@ -106,6 +106,7 @@
 
 #include "pairs.hxx"
 #include "chaxis.hxx"
+#include "arrayhelper.hxx"
 
 
 #ifndef _LEGACYBINFILTERMGR_HXX
@@ -231,14 +232,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);
@@ -301,7 +305,6 @@ enum ChartStyleV0
 /*?*/ 				   // nMaxX  = Max (nMaxX, pText->GetLogicRect().GetWidth());
 /*?*/ 				   // nMaxY  = Max (nMaxY, pText->GetLogicRect().GetHeight());
 /*?*/
-/*?*/ 					pRegressNr [nLines] = i;
 /*?*/ 					nLines ++;
 /*N*/ 				}
 /*N*/ 			}
@@ -475,10 +478,6 @@ enum ChartStyleV0
 /*N*/
 /*N*/ 					delete pSymbolAttr;
 /*N*/ 				}
-/*N*/ 				else //i >= nCnt
-/*N*/ 				{
-/*?*/ 					DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if (pRegressNr [i - nCnt])
-/*N*/ 				}
 /*N*/
 /*N*/               // FG: Jetzt wird aTextPos fuer den naechsten Legendeneintrag gesetzt
 /*N*/ 			   if (bWide)
@@ -532,7 +531,6 @@ enum ChartStyleV0
 /*N*/ 													TRUE, TRUE, pLegendAttr), 0);
 /*N*/ 		}
 /*N*/
-/*N*/ 		delete[] pRegressNr;
 /*N*/ 		delete[] pHeightOfEntry;
 /*N*/ 		delete[] pWidthOfEntry;
 /*N*/ 	}
@@ -1323,16 +1321,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 :
@@ -1344,8 +1344,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++)
@@ -1471,16 +1471,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;

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode3.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode3.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode3.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode3.cxx Wed Jul 18 10:05:58 2012
@@ -115,6 +115,9 @@
 
 #include "chaxis.hxx"
 
+#include <limits>
+#include <algorithm>
+
 namespace binfilter {
 
 /*************************************************************************
@@ -365,20 +368,17 @@ namespace binfilter {
 
 /*N*/ const SfxItemSet& ChartModel::GetDataRowAttr( long nRow ) const
 /*N*/ {
-/*N*/ 	if( nRow < (long)aDataRowAttrList.Count() )
+/*N*/ 	if( nRow>=0 && nRow < aDataRowAttrList.Count() )
 /*N*/ 	{
 /*N*/ 		SfxItemSet* pSet = aDataRowAttrList.GetObject( nRow );
 /*N*/ 		DBG_ASSERT( pSet, "Invalid ItemSet" );
-/*N*/ 		return *pSet;
-/*N*/ 	}
-/*N*/ 	else
-/*N*/ 	{
-/*N*/ 		DBG_ERROR( "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*/	DBG_ERROR( "Requested data row attribute is unavailable" );
+/*N*/	// return something
+/*?*/	DBG_ASSERT( pChartAttr, "Invalid Chart-ItemSet" );
+/*?*/	return *pChartAttr;
 /*N*/ }
 
 /*************************************************************************
@@ -789,11 +789,25 @@ namespace binfilter {
 /*N*/ 						   ? &aSwitchDataPointAttrList
 /*N*/ 						   : &aDataPointAttrList;
 /*N*/ 
-/*N*/ 	SfxItemSet* pItemSet = pAttrList->GetObject(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<sal_uIntPtr>::max()/nRowCount ) //sal_uIntPtr is the type of the index parameter for method pAttrList->GetObject
+            return;
+        if( nRowCount*nCol > ::std::numeric_limits<sal_uIntPtr>::max() - nRow )
+            return;
+        sal_uIntPtr nIndex = static_cast<sal_uIntPtr>(nCol) * nRowCount + nRow;
+
+/*N*/ 	SfxItemSet* pItemSet = pAttrList->GetObject(nIndex);
 /*N*/ 	if (pItemSet == NULL)
 /*N*/ 	{
 /*N*/ 		pItemSet = new SfxItemSet(*pItemPool, nRowWhichPairs);
-/*N*/ 		pAttrList->Replace (pItemSet, nCol * GetRowCount() + nRow);
+/*N*/ 		pAttrList->Replace (pItemSet, nIndex);
 /*N*/ 	}
 /*N*/ 	if(!bMerge)
 /*?*/ 		pItemSet->ClearItem();
@@ -888,10 +902,11 @@ namespace binfilter {
 /*N*/ 	SfxItemSet aAttr( GetDataRowAttr( nCol % nPieCount ));
 /*N*/ 
 /*N*/     if( ( nCol >= nPieCount ) &&
-/*N*/         pDefaultColors )
+/*N*/         pDefaultColors && pDefaultColors->Count()>0 )
 /*N*/     {
 /*?*/         XColorEntry* pColEntry = SAL_STATIC_CAST( XColorEntry*, pDefaultColors->GetObject( nCol % pDefaultColors->Count()));
-/*?*/         aAttr.Put( XFillColorItem( pColEntry->GetName(), pColEntry->GetColor()));
+              if( pColEntry )
+/*?*/             aAttr.Put( XFillColorItem( pColEntry->GetName(), pColEntry->GetColor()));
 /*N*/     }
 /*N*/ 
 /*N*/     // add description attributes of series

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode4.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode4.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode4.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode4.cxx Wed Jul 18 10:05:58 2012
@@ -208,11 +208,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 ] = {
@@ -721,6 +729,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
@@ -735,10 +758,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*/ 	{
@@ -754,7 +774,6 @@ namespace binfilter {
 /*N*/ 	pObj->SetResizeProtect(TRUE);
 /*N*/ 	pPage->NbcInsertObject(pObj, rIndex++);
 /*N*/ }
-
 /*************************************************************************
 |*
 |* Sub-Methode von BuildChart(), man koennte vermutlich DoShowMainTitle und
@@ -770,10 +789,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*/ 	{
@@ -816,17 +832,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*/ 				{
@@ -959,7 +965,9 @@ namespace binfilter {
 /*N*/ 				aSet.Put(pObj->GetItemSet());
 /*N*/ 
 /*N*/ 				aSet.ClearInvalidItems();
-/*N*/ 				aDataRowAttrList.GetObject( nRow )->Put( aSet );
+                    SfxItemSet* pItemSet = aDataRowAttrList.GetObject( nRow );
+                    if(pItemSet)
+/*N*/ 				    pItemSet->Put( aSet );
 /*N*/ 				aSet.ClearItem();
 /*N*/ 			}
 /*N*/ 			else if( pDataPoint )
@@ -1172,25 +1180,23 @@ namespace binfilter {
 			//	All four border lines had to lie inside the chart rectangle.
 			//	If the new solution, that solves error #88404# proves to work, then remove this
 			//	paragraph and the commented code below.
+                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) )
-//              if ((aDiagramRectangle.nLeft >= 0) && (aDiagramRectangle.nTop >= 0) &&
-//                  (aDiagramRectangle.nRight >= 0) && (aDiagramRectangle.nBottom >= 0))
 /*N*/ 			{
-/*?*/ 				double fRelativeXPosition = ((double) aDiagramRectangle.Left()) / aInitialSize.Width();
-/*?*/ 				double fRelativeYPosition = ((double) aDiagramRectangle.Top()) / aInitialSize.Height();
-//				if ((fRelativeXPosition <= 1.0) && (fRelativeYPosition <= 1.0))
-//				{
-/*?*/ 					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();
-//				if ((fRelativeXPosition <= 1.0) && (fRelativeYPosition <= 1.0))
-//				{
-/*?*/ 					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*/ 	}

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode7.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode7.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode7.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode7.cxx Wed Jul 18 10:05:58 2012
@@ -120,7 +120,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*/     }
@@ -554,7 +554,7 @@ UINT32& ChartModel::Percent DescrF ormat
 /*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*/ }
 

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode9.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode9.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode9.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_chtmode9.cxx Wed Jul 18 10:05:58 2012
@@ -86,6 +86,7 @@
 #include <float.h>
 #include "glob.hrc"
 
+#include "arrayhelper.hxx"
 #include "chaxis.hxx"
 #include "chdescr.hxx"
 #include "calculat.hxx"
@@ -407,6 +408,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);
@@ -422,10 +433,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*/ 			{
@@ -453,10 +462,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*/ 			{
@@ -543,19 +550,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;	//	Indicates wether the first point of a line
 /*N*/ 								//	segment is valid.
 /*N*/ 
@@ -1247,8 +1267,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*/ 
@@ -1267,9 +1293,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;
@@ -1399,32 +1422,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++ )
@@ -1458,37 +1455,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++ )
@@ -1508,7 +1476,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 );
@@ -1540,8 +1508,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);
@@ -1840,6 +1806,9 @@ namespace binfilter {
 /*N*/             break;
 /*N*/ 	}
 /*N*/ 
+          if( nLastSeries<0 )
+              return;
+
 /*N*/     // #101164# map fill-/line colors
 /*N*/     if( nNumLinesInColChart > nOldNumLines )
 /*N*/     {
@@ -1849,7 +1818,8 @@ namespace binfilter {
 /*N*/         {
 /*N*/             SfxItemSet * pSet = aDataRowAttrList.GetObject( 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() ));
@@ -1863,11 +1833,14 @@ namespace binfilter {
 /*N*/         {
 /*?*/             SfxItemSet * pSet = aDataRowAttrList.GetObject( 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*/ }

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_globfunc.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_globfunc.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_globfunc.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_globfunc.cxx Wed Jul 18 10:05:58 2012
@@ -172,250 +172,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

Modified: incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_memchrt.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_memchrt.cxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_memchrt.cxx (original)
+++ incubator/ooo/trunk/main/binfilter/bf_sch/source/core/sch_memchrt.cxx Wed Jul 18 10:05:58 2012
@@ -49,6 +49,7 @@
 
 #include <functional>
 #include <algorithm>
+
 namespace binfilter {
 
 // ========================================
@@ -162,14 +163,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*/ 
@@ -182,8 +183,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*/ }
 /*************************************************************************
 |*
@@ -207,10 +229,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());
@@ -245,28 +277,34 @@ 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*/ 	long i;
-/*N*/ 	for(i=0;i<nColCnt;i++)
-/*N*/ 	{
-/*N*/ 		pColTable[i]	= rMemChart.pColTable[i];
-/*N*/ 		pColNumFmtId[i]	= rMemChart.pColNumFmtId[i];
-/*N*/ 	}
-/*N*/ 	for(i=0;i<nRowCnt;i++)
-/*N*/ 	{
-/*N*/ 		pRowTable[i]	= rMemChart.pRowTable[i];
-/*N*/ 		pRowNumFmtId[i]	= rMemChart.pRowNumFmtId[i];
-/*N*/ 	}
+        if ( pColTable && pColNumFmtId )
+        {
+            for ( i = 0; i < nColCnt; i++ )
+            {
+                pColTable[i]	= rMemChart.pColTable[i];
+                pColNumFmtId[i]	= rMemChart.pColNumFmtId[i];
+            }
+        }
+        if ( pRowTable && pRowNumFmtId )
+        {
+            for ( i = 0; i < nRowCnt; i++ )
+            {
+                pRowTable[i]	= rMemChart.pRowTable[i];
+                pRowNumFmtId[i]	= rMemChart.pRowNumFmtId[i];
+            }
+        }
 /*N*/ 	mpNumFormatter=rMemChart.mpNumFormatter;
 /*N*/ 
 /*N*/ 	if (pData)
@@ -279,15 +317,23 @@ namespace binfilter {
 /*N*/ 				*(pDest ++) = *(pSource ++);
 /*N*/ 	}
 /*N*/ 
-/*N*/ 	pColText = new String[nColCnt];
-/*N*/ 
-/*N*/ 	for (i = 0; i < nColCnt; i++)
-/*N*/ 		pColText[i] = rMemChart.pColText[i];
-/*N*/ 
-/*N*/ 	pRowText = new String[nRowCnt];
-/*N*/ 
-/*N*/ 	for (i = 0; i < nRowCnt; i++)
-/*N*/ 		pRowText[i] = rMemChart.pRowText[i];
+        pColText = ArrayHelper< String >::create_short_size( nColCnt );
+        if ( pColText )
+        {
+            for ( i = 0; i < nColCnt; i++ )
+            {
+                pColText[i] = rMemChart.pColText[i];
+            }
+        }
+
+        pRowText = ArrayHelper< String >::create_short_size( nRowCnt );
+        if ( pRowText )
+        {
+            for ( i = 0; i < nRowCnt; i++ )
+            {
+                pRowText[i] = rMemChart.pRowText[i];
+            }
+        }
 /*N*/ 
 /*N*/ 	bReadOnly = rMemChart.bReadOnly;			// bm #69410#
 /*N*/ 
@@ -297,6 +343,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 :
@@ -311,7 +378,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*/ 		{
@@ -331,7 +398,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*/ 		{
@@ -353,7 +420,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++)
 /*?*/ 		{
@@ -361,7 +428,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++)
 /*?*/ 		{
@@ -383,32 +450,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*/ }
 
 
@@ -470,9 +589,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.WriteByteString( rMemChart.aMainTitle );
@@ -481,21 +607,41 @@ namespace binfilter {
 /*N*/ 	rOut.WriteByteString( rMemChart.aYAxisTitle );
 /*N*/ 	rOut.WriteByteString( rMemChart.aZAxisTitle );
 /*N*/ 
-/*N*/ 	for (i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ 		rOut.WriteByteString( rMemChart.pColText[ i ] );
-/*N*/ 
-/*N*/ 	for (i = 0; i < rMemChart.nRowCnt; i++)
-/*N*/ 		rOut.WriteByteString( rMemChart.pRowText[ i ] );
+        if ( rMemChart.pColText )
+        {
+            for ( i = 0; i < rMemChart.nColCnt; i++ )
+            {
+                rOut.WriteByteString( rMemChart.pColText[ i ] );
+            }
+        }
+
+        if ( rMemChart.pRowText )
+        {
+            for ( i = 0; i < rMemChart.nRowCnt; i++ )
+            {
+                rOut.WriteByteString( rMemChart.pRowText[ i ] );
+            }
+        }
 /*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;
@@ -516,17 +662,36 @@ 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*/ 	short i;
-/*N*/ 	for (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;
+
+        short i;
+        double *pIn = rMemChart.pData;
+        if ( pIn )
+        {
+            for ( i = 0; i < rMemChart.nColCnt; i++ )
+            {
+                for ( short j = 0; j < rMemChart.nRowCnt; j++ )
+                {
+                    rIn >> *(pIn ++);
+                }
+            }
+        }
 /*N*/ 
 /*N*/ 	INT16 nCharSet;
 /*N*/ 	rIn >> nCharSet;
@@ -541,35 +706,75 @@ namespace binfilter {
 /*N*/ 	rIn.ReadByteString( rMemChart.aYAxisTitle );
 /*N*/ 	rIn.ReadByteString( rMemChart.aZAxisTitle );
 /*N*/ 
-/*N*/ 	rMemChart.pColText = new String[rMemChart.nColCnt];
-/*N*/ 
-/*N*/ 	for (i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ 	{
-/*N*/ 		rIn.ReadByteString( rMemChart.pColText[ i ] );
-/*N*/ 	}
-/*N*/ 
-/*N*/ 	rMemChart.pRowText = new String[rMemChart.nRowCnt];
-/*N*/ 
-/*N*/ 	for (i = 0; i < rMemChart.nRowCnt; i++)
-/*N*/ 	{
-/*N*/ 		rIn.ReadByteString( rMemChart.pRowText[ i ] );
-/*N*/ 	}
+        delete[] rMemChart.pColText;
+        rMemChart.pColText = ArrayHelper< String >::create_short_size( rMemChart.nColCnt );
+        if ( !rMemChart.pColText )
+        {
+            rIn.SetError( ERRCODE_IO_GENERAL );
+            return rIn;
+        }
+        for ( i = 0; i < rMemChart.nColCnt; i++ )
+        {
+            rIn.ReadByteString( rMemChart.pColText[ i ] );
+        }
+
+        delete[] rMemChart.pRowText;
+        rMemChart.pRowText = ArrayHelper< String >::create_short_size( rMemChart.nRowCnt );
+        if ( !rMemChart.pRowText )
+        {
+            rIn.SetError( ERRCODE_IO_GENERAL );
+            return rIn;
+        }
+        for ( i = 0; i < rMemChart.nRowCnt; i++ )
+        {
+            rIn.ReadByteString( rMemChart.pRowText[ i ] );
+        }
 /*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*/ 		long i;
-/*N*/ 		for (i = 0; i < rMemChart.nColCnt; i++)
-/*N*/ 			rIn >> rMemChart.pColTable[i];
-/*N*/ 
-/*N*/ 		for (i = 0; i < rMemChart.nRowCnt; i++)
-/*N*/ 			rIn >> rMemChart.pRowTable[i];
+            for ( i = 0; i < rMemChart.nColCnt; i++ )
+            {
+                rIn >> rMemChart.pColTable[i];
+            }
+	        for ( i = 0; i < rMemChart.nRowCnt; i++ )
+            {
+		        rIn >> rMemChart.pRowTable[i];
+            }
 /*N*/ 
 /*N*/ 		if(aIO.GetVersion()>=2)
 /*N*/ 			rIn >> rMemChart.nTranslated;
@@ -603,11 +808,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*/ }
 
 /*************************************************************************

Modified: incubator/ooo/trunk/main/binfilter/inc/bf_sch/calculat.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/inc/bf_sch/calculat.hxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/inc/bf_sch/calculat.hxx (original)
+++ incubator/ooo/trunk/main/binfilter/inc/bf_sch/calculat.hxx Wed Jul 18 10:05:58 2012
@@ -45,23 +45,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
@@ -73,35 +56,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

Modified: incubator/ooo/trunk/main/binfilter/inc/bf_sch/chtmodel.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/inc/bf_sch/chtmodel.hxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/inc/bf_sch/chtmodel.hxx (original)
+++ incubator/ooo/trunk/main/binfilter/inc/bf_sch/chtmodel.hxx Wed Jul 18 10:05:58 2012
@@ -36,7 +36,6 @@
 //STRIP008 class SdrObjGroup;
 //STRIP008 class SdrRectObj;
 //STRIP008 
-//STRIP008 class SchModelData;
 
 #ifndef _E3D_POLYGON3D_HXX //autogen
 #include <bf_svx/polygn3d.hxx>
@@ -121,7 +120,6 @@ class SvNumberFormatterIndexTable;
 class SdrObjGroup;
 class SdrRectObj;
 
-class SchModelData;
 class SchObjectId;
 class ChartAxis;
 class SchItemPool;
@@ -643,6 +641,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; }
 
@@ -752,8 +752,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

Modified: incubator/ooo/trunk/main/binfilter/inc/bf_sch/globfunc.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/inc/bf_sch/globfunc.hxx?rev=1362838&r1=1362837&r2=1362838&view=diff
==============================================================================
--- incubator/ooo/trunk/main/binfilter/inc/bf_sch/globfunc.hxx (original)
+++ incubator/ooo/trunk/main/binfilter/inc/bf_sch/globfunc.hxx Wed Jul 18 10:05:58 2012
@@ -85,44 +85,6 @@ SchObjGroup *CreateSimpleGroup (UINT16 n
 								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);



Mime
View raw message