summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-08-03 23:37:40 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-08-03 23:37:40 +0200
commita660f4b2278cc2d7d45527fd0c8ada3c8b2368e8 (patch)
tree0465e79abc52ac3bc028f4bf364f9bf58ab31761 /sc
parent41f8f6d3503e91f23a6d58cbab5ae314f663aab9 (diff)
change from c-array to boost::ptr_vector
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/inc/datafdlg.hxx6
-rw-r--r--sc/source/ui/miscdlgs/datafdlg.cxx61
2 files changed, 30 insertions, 37 deletions
diff --git a/sc/source/ui/inc/datafdlg.hxx b/sc/source/ui/inc/datafdlg.hxx
index fea9e132f..fadc68836 100644
--- a/sc/source/ui/inc/datafdlg.hxx
+++ b/sc/source/ui/inc/datafdlg.hxx
@@ -39,6 +39,8 @@
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
+#include <boost/ptr_container/ptr_vector.hpp>
+
#define MAX_DATAFORM_COLS 256
#define MAX_DATAFORM_ROWS 32000
#define CTRL_HEIGHT 22
@@ -73,8 +75,8 @@ private:
SCTAB nTab;
sal_Bool bNoSelection;
- FixedText** pFixedTexts;
- Edit** pEdits;
+ boost::ptr_vector<FixedText> maFixedTexts;
+ boost::ptr_vector<Edit> maEdits;
public:
ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShell);
diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx
index fda275bdb..bc15f8a0f 100644
--- a/sc/source/ui/miscdlgs/datafdlg.cxx
+++ b/sc/source/ui/miscdlgs/datafdlg.cxx
@@ -174,8 +174,8 @@ ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri
aColLength = nEndCol - nStartCol + 1;
//new the controls
- pFixedTexts = new FixedText*[aColLength];
- pEdits = new Edit*[aColLength];
+ maFixedTexts.reserve(aColLength);
+ maEdits.reserve(aColLength);
for(sal_uInt16 nIndex = 0; nIndex < aColLength; nIndex++)
{
@@ -183,26 +183,26 @@ ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri
int nColWidth = pDoc->GetColWidth( nIndex + nStartCol, nTab );
if (nColWidth)
{
- pFixedTexts[nIndex] = new FixedText(this);
- pEdits[nIndex] = new Edit(this, WB_BORDER);
+ maFixedTexts.push_back( new FixedText(this) );
+ maEdits.push_back( new Edit(this, WB_BORDER) );
- pFixedTexts[nIndex]->SetSizePixel(nFixedSize);
- pEdits[nIndex]->SetSizePixel(nEditSize);
- pFixedTexts[nIndex]->SetPosPixel(Point(FIXED_LEFT, nTop));
- pEdits[nIndex]->SetPosPixel(Point(EDIT_LEFT, nTop));
- pFixedTexts[nIndex]->SetText(aFieldName);
- pFixedTexts[nIndex]->Show();
- pEdits[nIndex]->Show();
+ maFixedTexts[nIndex].SetSizePixel(nFixedSize);
+ maEdits[nIndex].SetSizePixel(nEditSize);
+ maFixedTexts[nIndex].SetPosPixel(Point(FIXED_LEFT, nTop));
+ maEdits[nIndex].SetPosPixel(Point(EDIT_LEFT, nTop));
+ maFixedTexts[nIndex].SetText(aFieldName);
+ maFixedTexts[nIndex].Show();
+ maEdits[nIndex].Show();
nTop += LINE_HEIGHT;
}
else
{
- pFixedTexts[nIndex] = NULL;
- pEdits[nIndex] = NULL;
+ maFixedTexts.push_back( NULL );
+ maEdits.push_back( NULL );
}
- if (pEdits[nIndex])
- pEdits[nIndex]->SetModifyHdl( HDL(Impl_DataModifyHdl) );
+ if (!maEdits.is_null(nIndex))
+ maEdits[nIndex].SetModifyHdl( HDL(Impl_DataModifyHdl) );
}
Size nDialogSize = this->GetSizePixel();
@@ -239,17 +239,7 @@ ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri
ScDataFormDlg::~ScDataFormDlg()
{
- for(sal_uInt16 i = 0; i < aColLength; i++)
- {
- if (pEdits[i])
- delete pEdits[i];
- if (pFixedTexts[i])
- delete pFixedTexts[i];
- }
- if (pEdits)
- delete[] pEdits;
- if (pFixedTexts)
- delete[] pFixedTexts;
+
}
void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
@@ -257,15 +247,15 @@ void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
String aFieldName;
for (sal_uInt16 i = 0; i < aColLength; ++i)
{
- if (pEdits[i])
+ if (!maEdits.is_null(i))
{
if (aCurrentRow<=nEndRow)
{
pDoc->GetString( i + nStartCol, aCurrentRow, nTab, aFieldName );
- pEdits[i]->SetText(aFieldName);
+ maEdits[i].SetText(aFieldName);
}
else
- pEdits[i]->SetText(String());
+ maEdits[i].SetText(String());
}
}
@@ -297,9 +287,10 @@ IMPL_LINK( ScDataFormDlg, Impl_NewHdl, PushButton*, EMPTYARG )
if ( pDoc )
{
sal_Bool bHasData = false;
- for(sal_uInt16 i = 0; i < aColLength; i++)
- if (pEdits[i])
- if ( pEdits[i]->GetText().Len() != 0 )
+ boost::ptr_vector<Edit>::iterator itr = maEdits.begin(), itrEnd = maEdits.end();
+ for(; itr != itrEnd; ++itr)
+ if (!boost::is_null(itr))
+ if ( (*itr).GetText().Len() != 0 )
{
bHasData = sal_True;
break;
@@ -307,7 +298,7 @@ IMPL_LINK( ScDataFormDlg, Impl_NewHdl, PushButton*, EMPTYARG )
if ( bHasData )
{
- pTabViewShell->DataFormPutData( aCurrentRow , nStartRow , nStartCol , nEndRow , nEndCol , pEdits , aColLength );
+ pTabViewShell->DataFormPutData( aCurrentRow , nStartRow , nStartCol , nEndRow , nEndCol , maEdits.c_array() , aColLength );
aCurrentRow++;
if (aCurrentRow >= nEndRow + 2)
{
@@ -410,8 +401,8 @@ void ScDataFormDlg::SetButtonState()
aBtnLast.Enable( false );
aBtnRestore.Enable( false );
- if ( pEdits )
- pEdits[0]->GrabFocus();
+ if ( maEdits.size()>=1 && !maEdits.is_null(0) )
+ maEdits[0].GrabFocus();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */