1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: memchrt.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SCH_MEMCHRT_HXX
32 #define _SCH_MEMCHRT_HXX
35 #include <bf_sfx2/sfxdefs.hxx>
37 #ifndef _SFXMODULE_HXX
38 #include <bf_sfx2/module.hxx>
41 #include <tools/color.hxx>
44 #include <tools/link.hxx>
47 #include <tools/string.hxx>
49 #ifndef _RTL_USTRBUF_HXX_
50 #include <rtl/ustrbuf.hxx>
52 #include <bf_sch/cellranges.hxx>
54 #ifndef _COM_SUN_STAR_CHART_CHARTSERIESADDRESS_HPP_
55 #include <com/sun/star/chart/ChartSeriesAddress.hpp>
62 class SvNumberFormatter
;
72 CHDATAID_MEMCHART_PLUS
75 // This struct contains information about selection in the chart, so that
76 // other apps (esp. calc) know what is currently selected
78 struct ChartSelectionInfo
80 ChartSelectionInfo() : nRow(0), nCol(0), fValue(0.0), nValue(0), nSelection(0) {}
81 ChartSelectionInfo(long sel
) : nRow(0), nCol(0), fValue(0.0), nValue(0), nSelection(sel
) {}
82 BOOL
operator == (const ChartSelectionInfo
& s
) const
86 && nSelection
== s
.nSelection
89 && aSelectionColor
== s
.aSelectionColor
;
91 long nRow
; // Datenzeilen-Koordinate
92 long nCol
; // Datenspaltenkoordinate
93 double fValue
; // neuer Wert fuer die Zelle (nCol,nRow)
94 long nValue
; // reserviert, evtl. fuer Numberformat und andere Informationen
95 long nSelection
; // s.u. , 31-Bit-Register (also besser Int32? -> return ist long)
96 Color aSelectionColor
; // Farbe des Selektions-Rahmens
99 // Flags fuer nSelection UND den Rueckgabewert der CallBackFunktion
100 // long ChartSelectionCallback(struct ChartSelectionInfo *pInfo), die mittels
101 // SchMemChart::SetSelectionCallback(...) am Chart angemeldet wird
103 #define CHART_SEL_NONE 1 // bestehende Selektion aufheben (derzeit default, da im Chart keine Multiselektion besteht)
104 #define CHART_SEL_ALL 2 // den gesamten MemChart-Datenbereich selektieren
105 #define CHART_SEL_ROW 4 // die DatenReihe nRow selektieren
106 #define CHART_SEL_COL 8 // die DatenSpalte nCol Selektieren
107 #define CHART_SEL_POINT 16 // den Datenpunkt selektieren
108 #define CHART_SEL_SETCURSOR 32 // Cursor an die Stelle (nCol,nRow) setzen
109 #define CHART_SEL_CHANGEVALUE 64 // Wert in der Tabelle aendern (auf fValue)
110 #define CHART_SEL_COLOR 128 // Farbinformation für farbigen Rahmen um den Selektionsbereich herum ist gesetzt
111 #define CHART_SEL_QUERYSUPPORT 256
112 #define CHART_SEL_QUERYPOSSIBLE 512
115 In der Callback-routine soll wie folgt verfahren werden:
116 Kann eine Aktion (z.B. Aenderung des Wertes) ausgefuehrt werden, so MUSS das
117 entsprechende Flag im Rueckgabewert gesetzt werden, kann die Aktion nicht ausgefuehrt
118 werden, so DARF das Flag NICHT gesetzt werden.
120 Prioritaet der Aktionen:
122 Prio 0 : CHART_SEL_QUERYSUPPORT
123 Prio 1 : CHART_SEL_NONE ; wichtig fuer (spaetere) Multiselektion.
124 Prio 2 : CHART_SEL_BORDERONLY ; Selektionsmodus, wird vorerst immer gesetzt sein
125 Prio n : der Rest....
127 CHART_SEL_QUERYSUPPORT:
128 Ist dieses Flag gesetzt, DARF die Aktion NICHT ausgefuehrt werden, sondern nur
129 zurueckgegeben werden, ob es moeglich waere!
133 Aufheben der Selektion, bei Multiselektion ist dieses Flag NICHT gesetzt, die neue Selektion
134 wird zusaetzlich angewand. (derzeit im Chart nicht implementiert, daher immer gesetzt)
138 // ============================================================
139 // ============================================================
141 // SchMemChart: class for chart data
143 // ============================================================
144 // ============================================================
149 #define TRANS_ERROR 3
154 long nLastSelInfoReturn
;
156 mutable String
* mpColNameBuffer
;
157 mutable String
* mpRowNameBuffer
;
179 // number formatter and format id
180 SvNumberFormatter
* mpNumFormatter
;
181 sal_Int32
*pRowNumFmtId
;
182 sal_Int32
*pColNumFmtId
;
184 // translation table for row-/column reordering (internal)
185 sal_Int32
*pRowTable
;
186 sal_Int32
*pColTable
;
187 ChartSelectionInfo aSelectionInfo
;
189 // is not copied in copy contrustor (?)
193 ::rtl::OUString maCategoriesRangeAddress
;
194 ::com::sun::star::uno::Sequence
<
195 ::com::sun::star::chart::ChartSeriesAddress
> maSeriesAddresses
;
197 /// contains all information necessary to write the source data ranges
198 SchChartRange maChartRange
;
200 ::rtl::OUStringBuffer
getXMLStringForCellAddress( const SchCellAddress
& rCell
);
201 void getSingleCellAddressFromXMLString( const ::rtl::OUString
& rXMLString
,
202 sal_Int32 nStartPos
, sal_Int32 nEndPos
,
203 SchSingleCell
& rSingleCell
);
204 bool getCellAddressFromXMLString( const ::rtl::OUString
& rXMLString
,
205 sal_Int32 nStartPos
, sal_Int32 nEndPos
,
206 SchCellAddress
& rOutCell
,
207 ::rtl::OUString
& rOutTableName
);
208 bool getCellRangeAddressFromXMLString( const ::rtl::OUString
& rXMLString
,
209 sal_Int32 nStartPos
, sal_Int32 nEndPos
,
210 SchCellRangeAddress
& rOutRange
);
214 inline void SetReadOnly( BOOL bNewValue
);
215 BOOL
IsReadOnly() { return bReadOnly
; }
217 SchMemChart(ChartDataId myID
);
218 SchMemChart(short nCols
, short nRows
);
219 SchMemChart(const SchMemChart
& rMemChart
);
227 delete[] pRowNumFmtId
;
229 delete[] pColNumFmtId
;
234 delete[] mpRowNameBuffer
;
235 delete[] mpColNameBuffer
;
238 // initialize number format, -1 means unset
241 // transfer chart selection to calc or writer
242 const ChartSelectionInfo
& GetSelectionInfo() const { return aSelectionInfo
; }
243 // methods for translation of data
244 inline void ResetTranslation(sal_Int32
*pTable
,long nCnt
);
245 #if OSL_DEBUG_LEVEL > 0
246 BOOL
VerifyTranslation();
248 long GetTranslation() const { return nTranslated
; }
249 inline void UpdateTranslation(sal_Int32
*pTable
,long nCnt
);
250 // for acces always use these Get-methods !
251 double GetTransData(long nCol
,long nRow
);
252 double GetTransDataInPercent(long nCol
,long nRow
,BOOL bRowData
) const;
253 const String
& GetTransColText(long nCol
) const;
254 const String
& GetTransRowText(long nRow
) const;
256 const sal_Int32
*GetRowTranslation() const { return pRowTable
; }
257 const sal_Int32
*GetColTranslation() const { return pColTable
; }
260 const sal_Int32
* GetRowNumFmtTable() const { return pRowNumFmtId
; }
261 const sal_Int32
* GetColNumFmtTable() const { return pColNumFmtId
; }
263 // ********************
264 // BM: Fix for #68864#
265 // Use these four methods with care! The arrays MUST have the correct size!
266 // ********************
267 void SetRowTranslation( const sal_Int32
* pTransTable
)
269 if( !pRowTable
) return;
270 for( sal_Int32 i
=0; i
<nRowCnt
; i
++ )
271 pRowTable
[ i
] = pTransTable
[ i
];
273 void SetColTranslation( const sal_Int32
* pTransTable
)
275 if( !pColTable
) return;
276 for( sal_Int32 i
=0; i
<nColCnt
; i
++ )
277 pColTable
[ i
] = pTransTable
[ i
];
279 void SetRowNumFmtTable( const sal_Int32
* pNumFmtTable
)
281 if( !pRowNumFmtId
) return;
282 for( sal_Int32 i
=0; i
<nRowCnt
; i
++ )
283 pRowNumFmtId
[ i
] = pNumFmtTable
[ i
];
285 void SetColNumFmtTable( const sal_Int32
* pNumFmtTable
)
287 if( !pColNumFmtId
) return;
288 for( sal_Int32 i
=0; i
<nColCnt
; i
++ )
289 pColNumFmtId
[ i
] = pNumFmtTable
[ i
];
291 // this is only valid if the corresponding translation table was set correctly!
292 void SetTranslation( long nTrans
) { nTranslated
= nTrans
; }
293 // ********************
300 void SetNumberFormatter(SvNumberFormatter
* pNumFormatter
) { mpNumFormatter
= pNumFormatter
; }
301 SvNumberFormatter
* GetNumberFormatter() const { return mpNumFormatter
; }
303 void SetNumFormatIdRow( const long nRow
, const long nFmtId
) { if( pRowNumFmtId
&& nRow
< nRowCnt
) pRowNumFmtId
[ nRow
] = nFmtId
; }
304 void SetNumFormatIdCol( const long nCol
, const long nFmtId
) { if( pColNumFmtId
&& nCol
< nColCnt
) pColNumFmtId
[ nCol
] = nFmtId
; }
305 long GetNumFormatIdRow( const long nRow
) const { return ( pRowNumFmtId
&& nRow
< nRowCnt
)? pRowNumFmtId
[ nRow
]: -1; }
306 long GetNumFormatIdCol( const long nCol
) const { return ( pColNumFmtId
&& nCol
< nColCnt
)? pColNumFmtId
[ nCol
]: -1; }
307 long GetTransNumFormatIdRow( const long nRow
) const;
308 long GetTransNumFormatIdCol( const long nCol
) const;
310 void SetSelectionHdl(const Link
& rLink
) { aAppLink
=rLink
; }
312 void SetNonNumericData(const SchMemChart
&rMemChart
);
314 void SetDataType(short eType
) { eDataType
= eType
; }
315 short GetDataType() const { return eDataType
; }
317 short GetColCount() const { return nColCnt
; }
318 short GetRowCount() const { return nRowCnt
; }
320 const String
& GetMainTitle() const { return aMainTitle
; }
321 const String
& GetSubTitle() const { return aSubTitle
; }
323 void SetMainTitle(const String
& rText
) { aMainTitle
= rText
; }
324 void SetSubTitle(const String
& rText
) { aSubTitle
= rText
; }
326 const String
& GetXAxisTitle() const { return aXAxisTitle
; }
327 const String
& GetYAxisTitle() const { return aYAxisTitle
; }
328 const String
& GetZAxisTitle() const { return aZAxisTitle
; }
330 void SetXAxisTitle(const String
& rText
) { aXAxisTitle
= rText
; }
331 void SetYAxisTitle(const String
& rText
) { aYAxisTitle
= rText
; }
332 void SetZAxisTitle(const String
& rText
) { aZAxisTitle
= rText
; }
334 friend SvStream
& operator << (SvStream
& rOut
, const SchMemChart
& rMemChart
);
335 friend SvStream
& operator >> (SvStream
& rIn
, SchMemChart
& rMemChart
);
337 const String
& GetColText(short nCol
) const { return pColText
[nCol
]; }
338 const String
& GetRowText(short nRow
) const { return pRowText
[nRow
]; }
340 ChartDataId
GetId() const { return myID
; }
341 double GetData(short nCol
, short nRow
) const { return pData
[nCol
* nRowCnt
+ nRow
]; }
342 double GetDataInPercent(const short nCol
, const short nRow
, const BOOL bRowData
) const;
344 inline void InsertCols(short nAtCol
, short nCount
);
345 inline void RemoveCols(short nAtCol
, short nCount
);
346 inline void InsertRows(short nAtRow
, short nCount
);
347 inline void RemoveRows(short nAtRow
, short nCount
);
348 inline void SwapCols(int nAtCol1
, int nAtCol2
);
349 inline void SwapRows(int nAtRow1
, int nAtRow2
);
351 void SetData(short nCol
, short nRow
, const double& rVal
)
352 { pData
[nCol
* nRowCnt
+ nRow
] = rVal
; }
354 String
& SomeData1() { return aSomeData1
; }
355 String
& SomeData2() { return aSomeData2
; }
356 String
& SomeData3() { return aSomeData3
; }
357 String
& SomeData4() { return aSomeData4
; }
359 const String
& SomeData1() const { return aSomeData1
; }
360 const String
& SomeData2() const { return aSomeData2
; }
361 const String
& SomeData3() const { return aSomeData3
; }
362 const String
& SomeData4() const { return aSomeData4
; }
364 void SetColText(short nCol
, const String
& rText
) { pColText
[nCol
] = rText
; }
365 void SetRowText(short nRow
, const String
& rText
) { pRowText
[nRow
] = rText
; }
371 friend class ChartModel
;
373 void IncreaseRefCount() { nRefCount
++; }
374 BOOL
DecreaseRefCount()
376 DBG_ASSERT( nRefCount
, "SchMemChart::DecreaseRefCount: illegal decrement of RefCount");
377 if(nRefCount
) nRefCount
--;
378 return (nRefCount
==0); // true iff object can be deleted
381 // get a string for default (column|row) labels
382 // the indexes start at 0, but the text starts with "(Column|Row) 1"
383 String
GetDefaultColumnText( sal_Int32 nCol
) const;
384 String
GetDefaultRowText( sal_Int32 nRow
) const;
386 // ====================
389 void SetCategoriesRangeAddress( const ::rtl::OUString
& rCellRangeAddress
)
390 { maCategoriesRangeAddress
= rCellRangeAddress
; }
393 void SetSeriesAddresses( const ::com::sun::star::uno::Sequence
< ::com::sun::star::chart::ChartSeriesAddress
>& rCellRangeAddresses
)
394 { maSeriesAddresses
= rCellRangeAddresses
; }
397 const ::rtl::OUString
&
398 GetCategoriesRangeAddress()
399 { return maCategoriesRangeAddress
; }
402 const ::com::sun::star::uno::Sequence
< ::com::sun::star::chart::ChartSeriesAddress
>&
404 { return maSeriesAddresses
; }
406 // --------------------
408 /// get table ranges for entire chart
409 const SchChartRange
& GetChartRange() const
410 { return maChartRange
; }
411 /// set table ranges for entire chart
412 void SetChartRange( const SchChartRange
& rRange
)
413 { maChartRange
= rRange
; }
415 /** convert SomeData string(s) to SchChartRange and vice versa for Writer
416 @return <TRUE/>, iff the conversion was successfully done.
418 bool ConvertChartRangeForWriter( BOOL bOldToNew
= TRUE
);
420 /** convert SomeData string(s) to SchChartRange and vice versa for Calc
421 @return <TRUE/>, iff the conversion was successfully done.
423 bool ConvertChartRangeForCalc( BOOL bOldToNew
= FALSE
);
425 ::rtl::OUString
getXMLStringForChartRange();
426 void getChartRangeForXMLString( const ::rtl::OUString
& rXMLString
);
428 /** create a string of form "1 2 3 4" containing a list of table numbers
429 in SchChartRange maChartRange to create SomeData for calc
431 ::rtl::OUString
createTableNumberList();
432 /** prerequisite: maChartRange must be set and have the correct dimension
433 for all table numbers to fit in
435 void parseTableNumberList( const ::rtl::OUString
& rList
);
438 // ==================== Inline Implementations ====================
440 inline void SchMemChart::ResetTranslation(sal_Int32
*pTable
,long nCnt
)
447 if(pTable
==pRowTable
&& nTranslated
==TRANS_ROW
)
448 nTranslated
=TRANS_NONE
;
449 if(pTable
==pColTable
&& nTranslated
==TRANS_COL
)
450 nTranslated
=TRANS_NONE
;
453 inline void SchMemChart::UpdateTranslation(sal_Int32
*pTable
,long nCnt
)
455 if( (pTable
==pRowTable
&& nTranslated
==TRANS_ROW
)
456 ||(pTable
==pColTable
&& nTranslated
==TRANS_COL
))
461 nMax
=Max(nMax
,pTable
[i
]);
463 if(nMax
>=nCnt
)//something added
465 long nStart
=-1,nEnd
=-1;
468 if(pTable
[i
]==-1)//markierung gefunden
477 long nDiff
=nEnd
-nStart
;//soviele sind neu
479 DBG_ASSERT( (nDiff
>0) && ((nEnd
-nStart
) == (nCnt
-nMax
)),"MemChart::Something went wrong!");
481 if( (nDiff
<=0) || ((nEnd
-nStart
)!=(nCnt
-nMax
)))
490 pTable
[i
]+=nDiff
; //nach hinten verschieben
492 else if (pTable
[i
]==-1)
494 pTable
[i
]=nNew
; //"einfuegen"
499 else //something removed
501 ResetTranslation(pTable
,nCnt
); //keine schoene Loesung....(ToDo:), Aufwand recht hoch...
506 ResetTranslation(pTable
,nCnt
); //Normale Reihenfolge, da nicht die Sortierte Tabelll geupdated wird
510 inline void SchMemChart::InsertCols(short nAtCol
, short nCount
)
512 double* pOldData
= pData
;
514 short nNewColCnt
= nColCnt
+ nCount
;
516 pData
= new double[nNewColCnt
* nRowCnt
];
518 short i
, j
, nOld
, nMax
;
520 for (i
= 0, nOld
= 0; i
< nAtCol
; i
++, nOld
++)
522 for (j
= 0; j
< nRowCnt
; j
++)
524 pData
[i
* nRowCnt
+ j
] = pOldData
[nOld
* nRowCnt
+ j
];
528 nMax
= nAtCol
+ nCount
;
530 for (; i
< nMax
; i
++)
532 for (j
= 0; j
< nRowCnt
; j
++)
534 pData
[i
* nRowCnt
+ j
] = 0.0;
538 for (; i
< nNewColCnt
; i
++, nOld
++)
540 for (j
= 0; j
< nRowCnt
; j
++)
542 pData
[i
* nRowCnt
+ j
] = pOldData
[nOld
* nRowCnt
+ j
];
547 String
*pOldColText
= pColText
;
548 sal_Int32
*pOldColNumFmtId
= pColNumFmtId
;
549 sal_Int32
*pOldColTable
= pColTable
;
551 pColNumFmtId
= new sal_Int32
[nNewColCnt
];
552 pColTable
= new sal_Int32
[nNewColCnt
];
553 pColText
= new String
[nNewColCnt
];
558 pColTable
[nC
] = -1; //init
559 pColNumFmtId
[nC
] = -1;
562 for (i
= 0, nOld
= 0;; i
++, nOld
++)
569 pColText
[i
] = pOldColText
[nOld
];
570 pColTable
[i
] = pOldColTable
[nOld
];
571 pColNumFmtId
[i
] = pOldColNumFmtId
[nOld
];
574 delete[] pOldColNumFmtId
;
575 delete[] pOldColTable
;
576 delete[] pOldColText
;
578 nColCnt
= nNewColCnt
;
580 UpdateTranslation(pColTable
,nColCnt
);
583 inline void SchMemChart::RemoveCols(short nAtCol
, short nCount
)
585 DBG_ASSERT( nAtCol
< nColCnt
, "column index overflow");
587 if (nAtCol
+ nCount
> nColCnt
)
588 nCount
= nColCnt
- nAtCol
;
590 short nNewColCnt
= nColCnt
- nCount
;
592 double* pOldData
= pData
;
593 pData
= new double[nNewColCnt
* nRowCnt
];
595 String
* pOldColText
= pColText
;
596 sal_Int32
* pOldColNumFmtId
= pColNumFmtId
;
597 sal_Int32
* pOldColTable
= pColTable
;
599 pColText
= new String
[nNewColCnt
];
600 pColNumFmtId
= new sal_Int32
[nNewColCnt
];
601 pColTable
= new sal_Int32
[nNewColCnt
];
605 for (i
= 0, nOld
= 0;; i
++, nOld
++)
612 for (j
= 0; j
< nRowCnt
; j
++)
613 pData
[i
* nRowCnt
+ j
] = pOldData
[nOld
* nRowCnt
+ j
];
615 pColText
[i
] = pOldColText
[nOld
];
616 pColTable
[i
] = pOldColTable
[nOld
];
617 pColNumFmtId
[i
] = pOldColNumFmtId
[nOld
];
621 delete[] pOldColText
;
622 delete[] pOldColTable
;
623 delete[] pOldColNumFmtId
;
625 nColCnt
= nNewColCnt
;
627 UpdateTranslation(pColTable
,nColCnt
);
630 inline void SchMemChart::InsertRows(short nAtRow
, short nCount
)
632 double* pOldData
= pData
;
634 short nNewRowCnt
= nRowCnt
+ nCount
;
636 pData
= new double[nColCnt
* nNewRowCnt
];
638 short i
, j
, nOld
, nMax
, nGapEnd
;
640 for (i
= 0; i
< nColCnt
; i
++)
642 for (j
= 0, nOld
= 0; j
< nAtRow
; j
++, nOld
++)
644 pData
[i
* nNewRowCnt
+ j
] = pOldData
[i
* nRowCnt
+ nOld
];
648 nMax
= nAtRow
+ nCount
;
650 for (i
= 0; i
< nColCnt
; i
++)
652 for (j
= nAtRow
; j
< nMax
; j
++)
654 pData
[i
* nNewRowCnt
+ j
] = 0.0;
660 for (i
= 0; i
< nColCnt
; i
++)
662 for (j
= nGapEnd
, nOld
= nAtRow
; j
< nNewRowCnt
; j
++, nOld
++)
664 pData
[i
* nNewRowCnt
+ j
] = pOldData
[i
* nRowCnt
+ nOld
];
669 String
*pOldRowText
=pRowText
;
670 sal_Int32
*pOldRowNumFmtId
=pRowNumFmtId
;
671 sal_Int32
*pOldRowTable
=pRowTable
;
673 pRowNumFmtId
= new sal_Int32
[nNewRowCnt
];
674 pRowTable
= new sal_Int32
[nNewRowCnt
];
675 pRowText
= new String
[nNewRowCnt
];
680 pRowNumFmtId
[nC
] = -1;
684 for (i
= 0, nOld
= 0;; i
++, nOld
++)
691 pRowNumFmtId
[i
] = pOldRowNumFmtId
[nOld
];
692 pRowTable
[i
] = pOldRowTable
[nOld
];
693 pRowText
[i
] = pOldRowText
[nOld
];
696 delete[] pOldRowText
;
697 delete[] pOldRowTable
;
698 delete[] pOldRowNumFmtId
;
700 nRowCnt
= nNewRowCnt
;
702 UpdateTranslation(pRowTable
,nRowCnt
);
705 inline void SchMemChart::RemoveRows(short nAtRow
, short nCount
)
707 DBG_ASSERT( nAtRow
< nRowCnt
, "row index overflow" );
709 if (nAtRow
+ nCount
> nRowCnt
)
710 nCount
= nRowCnt
- nAtRow
;
712 short nNewRowCnt
= nRowCnt
- nCount
;
714 double* pOldData
= pData
;
715 pData
= new double[nColCnt
* nNewRowCnt
];
719 for (i
= 0; i
< nColCnt
; i
++)
720 for (j
= 0, nOld
= 0;; j
++, nOld
++)
727 pData
[i
* nNewRowCnt
+ j
] = pOldData
[i
* nRowCnt
+ nOld
];
732 String
* pOldRowText
= pRowText
;
733 sal_Int32
* pOldRowNumFmtId
= pRowNumFmtId
;
734 sal_Int32
* pOldRowTable
= pRowTable
;
736 pRowText
= new String
[nNewRowCnt
];
737 pRowNumFmtId
= new sal_Int32
[nNewRowCnt
];
738 pRowTable
= new sal_Int32
[nNewRowCnt
];
740 for (i
= 0, nOld
= 0;; i
++, nOld
++)
747 pRowText
[i
] = pOldRowText
[nOld
];
748 pRowTable
[i
] = pOldRowTable
[nOld
];
749 pRowNumFmtId
[i
] = pOldRowNumFmtId
[nOld
];
752 delete[] pOldRowText
;
753 delete[] pOldRowTable
;
754 delete[] pOldRowNumFmtId
;
756 nRowCnt
= nNewRowCnt
;
758 UpdateTranslation(pRowTable
,nRowCnt
);
761 inline void SchMemChart::SwapCols(int nAtCol1
, int nAtCol2
)
763 // Wenn hier Aenderungen Stattfinden, mu?auch im Logbuch
765 if (nAtCol1
> nAtCol2
)
767 long nTemp
= nAtCol1
;
773 if (nAtCol1
>= nColCnt
- 1) nAtCol1
= nColCnt
- 2;
774 if (nAtCol2
>= nColCnt
) nAtCol2
= nColCnt
- 1;
776 nAtCol1
= Max(nAtCol1
, 0);
777 nAtCol2
= Max(nAtCol2
, 0);
778 //Insbesondere bis hier,, da dieses Handling autokorrigierend ist
780 double *pSrc
= pData
+ nAtCol1
* nRowCnt
;
781 double *pDest
= pData
+ nAtCol2
* nRowCnt
;
783 for (long nSwaps
= 0;
787 double fSwap
= *pSrc
;
796 String aTemp
= pColText
[nAtCol1
];
797 pColText
[nAtCol1
] = pColText
[nAtCol2
];
798 pColText
[nAtCol2
] = aTemp
;
800 long nTmp
= pColTable
[nAtCol1
];
801 pColTable
[nAtCol1
] = pColTable
[nAtCol2
];
802 pColTable
[nAtCol2
] = nTmp
;
804 nTmp
= pColNumFmtId
[nAtCol1
];
805 pColNumFmtId
[nAtCol1
] = pColNumFmtId
[nAtCol2
];
806 pColNumFmtId
[nAtCol2
] = nTmp
;
808 ResetTranslation(pColTable
,nColCnt
); //ToDo:???
811 inline void SchMemChart::SwapRows(int nAtRow1
,int nAtRow2
)
814 // Wenn hier Aenderungen Stattfinden, mu?auch im Logbuch
816 if (nAtRow1
> nAtRow2
)
818 long nTemp
= nAtRow1
;
824 if (nAtRow1
>= nRowCnt
- 1) nAtRow1
= nRowCnt
- 2;
825 if (nAtRow2
>= nRowCnt
) nAtRow2
= nRowCnt
- 1;
827 nAtRow1
= Max(nAtRow1
, 0);
828 nAtRow2
= Max(nAtRow2
, 0);
829 //Insbesondere bis hier,, da dieses Handling autokorrigierend ist
831 double *pSrc
= pData
+ nAtRow1
;
832 double *pDest
= pData
+ nAtRow2
;
834 for (long nSwaps
= 0;
838 double fSwap
= *pSrc
;
847 String aTemp
= pRowText
[nAtRow1
];
848 pRowText
[nAtRow1
] = pRowText
[nAtRow2
];
849 pRowText
[nAtRow2
] = aTemp
;
851 long nTmp
= pRowTable
[nAtRow1
];
852 pRowTable
[nAtRow1
] = pRowTable
[nAtRow2
];
853 pRowTable
[nAtRow2
] = nTmp
;
855 nTmp
= pRowNumFmtId
[nAtRow1
];
856 pRowNumFmtId
[nAtRow1
] = pRowNumFmtId
[nAtRow2
];
857 pRowNumFmtId
[nAtRow2
] = nTmp
;
859 ResetTranslation(pRowTable
,nRowCnt
);//ToDo:???
862 inline void SchMemChart::SetReadOnly( BOOL bNewValue
)
864 // do not set ReadOnly, if there is no external data set
865 if( bNewValue
&& maChartRange
.maRanges
.size() == 0 )
868 bReadOnly
= bNewValue
;
871 } //namespace binfilter
872 #endif // _SCH_MEMCHRT_HXX