Kaydet (Commit) fb487ea4 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Use ptr_vector to replace vector with shared_ptr inside.

üst 0ce7d1bc
...@@ -356,8 +356,7 @@ void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels ) ...@@ -356,8 +356,7 @@ void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
{ {
aLabelDataArr.push_back(*rLabels[i]); aLabelDataArr.push_back(*rLabels[i]);
aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i); aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
ScDPFuncDataRef p(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask)); aSelectArr.push_back(new ScDPFuncData(aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask));
aSelectArr.push_back(p);
} }
aWndSelect.ResetScrollBar(); aWndSelect.ResetScrollBar();
aWndSelect.Paint(Rectangle()); aWndSelect.Paint(Rectangle());
...@@ -382,8 +381,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel ...@@ -382,8 +381,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel
continue; continue;
size_t nFieldIndex = pInitArr->size(); size_t nFieldIndex = pInitArr->size();
ScDPFuncDataRef p(new ScDPFuncData(nCol, nMask, itr->mnDupCount, itr->maFieldRef)); pInitArr->push_back(new ScDPFuncData(nCol, nMask, itr->mnDupCount, itr->maFieldRef));
pInitArr->push_back(p);
if (eType == TYPE_DATA) if (eType == TYPE_DATA)
{ {
...@@ -395,7 +393,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel ...@@ -395,7 +393,7 @@ void ScDPLayoutDlg::InitFieldWindow( const vector<PivotField>& rFields, ScDPFiel
OUString aStr = pData->maLayoutName; OUString aStr = pData->maLayoutName;
if (aStr.isEmpty()) if (aStr.isEmpty())
{ {
sal_uInt16 nInitMask = pInitArr->back()->mnFuncMask; sal_uInt16 nInitMask = pInitArr->back().mnFuncMask;
aStr = GetFuncString(nInitMask, pData->mbIsValue); aStr = GetFuncString(nInitMask, pData->mbIsValue);
aStr += pData->maName; aStr += pData->maName;
} }
...@@ -436,7 +434,7 @@ void ScDPLayoutDlg::InitFields() ...@@ -436,7 +434,7 @@ void ScDPLayoutDlg::InitFields()
void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos ) void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
{ {
ScDPFuncData fData( *(aSelectArr[nFromIndex]) ); ScDPFuncData fData = aSelectArr[nFromIndex];
bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
if (!bAllowed) if (!bAllowed)
...@@ -513,7 +511,7 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po ...@@ -513,7 +511,7 @@ void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Po
void ScDPLayoutDlg::AppendField(size_t nFromIndex, ScDPFieldType eToType) void ScDPLayoutDlg::AppendField(size_t nFromIndex, ScDPFieldType eToType)
{ {
ScDPFuncData aFuncData = *aSelectArr[nFromIndex]; ScDPFuncData aFuncData = aSelectArr[nFromIndex];
size_t nAt = 0; size_t nAt = 0;
ScDPFieldControlBase* toWnd = GetFieldWindow(eToType); ScDPFieldControlBase* toWnd = GetFieldWindow(eToType);
...@@ -608,7 +606,7 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF ...@@ -608,7 +606,7 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF
if ( fromArr && toArr && fromWnd && toWnd ) if ( fromArr && toArr && fromWnd && toWnd )
{ {
ScDPFuncData fData( *((*fromArr)[nFromIndex]) ); ScDPFuncData fData = (*fromArr)[nFromIndex];
bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType ); bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
size_t nAt = 0; size_t nAt = 0;
...@@ -682,7 +680,7 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF ...@@ -682,7 +680,7 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF
size_t nAt = 0; size_t nAt = 0;
Point aToPos; Point aToPos;
ScDPFuncData fData( *((*theArr)[nFromIndex]) ); ScDPFuncData fData = (*theArr)[nFromIndex];
if ( Contains( theArr, fData, nAt ) ) if ( Contains( theArr, fData, nAt ) )
{ {
...@@ -727,7 +725,7 @@ void ScDPLayoutDlg::MoveFieldToEnd( ScDPFieldType eFromType, size_t nFromIndex, ...@@ -727,7 +725,7 @@ void ScDPLayoutDlg::MoveFieldToEnd( ScDPFieldType eFromType, size_t nFromIndex,
if ( fromArr && toArr && fromWnd && toWnd ) if ( fromArr && toArr && fromWnd && toWnd )
{ {
ScDPFuncData fData( *((*fromArr)[nFromIndex]) ); ScDPFuncData fData = (*fromArr)[nFromIndex];
size_t nAt = 0; size_t nAt = 0;
if ( Contains( fromArr, fData, nAt ) ) if ( Contains( fromArr, fData, nAt ) )
...@@ -794,7 +792,7 @@ void ScDPLayoutDlg::MoveFieldToEnd( ScDPFieldType eFromType, size_t nFromIndex, ...@@ -794,7 +792,7 @@ void ScDPLayoutDlg::MoveFieldToEnd( ScDPFieldType eFromType, size_t nFromIndex,
Point aToPos; Point aToPos;
bool bDataArr = eFromType == TYPE_DATA; bool bDataArr = eFromType == TYPE_DATA;
ScDPFuncData fData( *((*theArr)[nFromIndex]) ); ScDPFuncData fData = (*theArr)[nFromIndex];
if ( Contains( theArr, fData, nAt ) ) if ( Contains( theArr, fData, nAt ) )
{ {
...@@ -939,7 +937,7 @@ PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt ) ...@@ -939,7 +937,7 @@ PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt )
case TYPE_DATA: fromArr = &aDataArr; break; case TYPE_DATA: fromArr = &aDataArr; break;
case TYPE_SELECT: fromArr = &aSelectArr; break; case TYPE_SELECT: fromArr = &aSelectArr; break;
} }
ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) ); ScDPFuncData fData = (*fromArr)[nDnDFromIndex];
if (IsOrientationAllowed( fData.mnCol, eCheckTarget )) if (IsOrientationAllowed( fData.mnCol, eCheckTarget ))
ePtr = lclGetPointerForField( eCheckTarget ); ePtr = lclGetPointerForField( eCheckTarget );
else else
...@@ -975,7 +973,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex ) ...@@ -975,7 +973,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
} }
size_t nArrPos = 0; size_t nArrPos = 0;
if( ScDPLabelData* pData = GetLabelData( (*pArr)[nFieldIndex]->mnCol, &nArrPos ) ) if( ScDPLabelData* pData = GetLabelData( (*pArr)[nFieldIndex].mnCol, &nArrPos ) )
{ {
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
...@@ -989,9 +987,9 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex ) ...@@ -989,9 +987,9 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
// list of names of all data fields // list of names of all data fields
vector<ScDPName> aDataFieldNames; vector<ScDPName> aDataFieldNames;
for( ScDPFuncDataVec::const_iterator aIt = aDataArr.begin(), aEnd = aDataArr.end(); for( ScDPFuncDataVec::const_iterator aIt = aDataArr.begin(), aEnd = aDataArr.end();
(aIt != aEnd) && aIt->get(); ++aIt ) (aIt != aEnd); ++aIt)
{ {
ScDPLabelData* pDFData = GetLabelData((*aIt)->mnCol); ScDPLabelData* pDFData = GetLabelData(aIt->mnCol);
if (!pDFData) if (!pDFData)
continue; continue;
...@@ -1002,7 +1000,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex ) ...@@ -1002,7 +1000,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
if (aLayoutName.isEmpty()) if (aLayoutName.isEmpty())
{ {
// No layout name exists. Use the stock name. // No layout name exists. Use the stock name.
sal_uInt16 nMask = (*aIt)->mnFuncMask; sal_uInt16 nMask = aIt->mnFuncMask;
OUString aFuncStr = GetFuncString(nMask); OUString aFuncStr = GetFuncString(nMask);
aLayoutName = aFuncStr + pDFData->maName; aLayoutName = aFuncStr + pDFData->maName;
} }
...@@ -1010,16 +1008,16 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex ) ...@@ -1010,16 +1008,16 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
} }
bool bLayout = (eType == TYPE_ROW) && bool bLayout = (eType == TYPE_ROW) &&
((aDataFieldNames.size() > 1) || ((nFieldIndex + 1 < pArr->size()) && (*pArr)[nFieldIndex+1].get())); ((aDataFieldNames.size() > 1) || (nFieldIndex + 1 < pArr->size()));
AbstractScDPSubtotalDlg* pDlg = pFact->CreateScDPSubtotalDlg( AbstractScDPSubtotalDlg* pDlg = pFact->CreateScDPSubtotalDlg(
this, RID_SCDLG_PIVOTSUBT, this, RID_SCDLG_PIVOTSUBT,
*xDlgDPObject, *pData, *(*pArr)[nFieldIndex], aDataFieldNames, bLayout ); *xDlgDPObject, *pData, (*pArr)[nFieldIndex], aDataFieldNames, bLayout );
if ( pDlg->Execute() == RET_OK ) if ( pDlg->Execute() == RET_OK )
{ {
pDlg->FillLabelData( *pData ); pDlg->FillLabelData( *pData );
(*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask; (*pArr)[nFieldIndex].mnFuncMask = pData->mnFuncMask;
} }
delete pDlg; delete pDlg;
} }
...@@ -1027,7 +1025,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex ) ...@@ -1027,7 +1025,7 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
case TYPE_DATA: case TYPE_DATA:
{ {
ScDPFuncData& rFuncData = *aDataArr[nFieldIndex]; ScDPFuncData& rFuncData = aDataArr[nFieldIndex];
AbstractScDPFunctionDlg* pDlg = pFact->CreateScDPFunctionDlg( AbstractScDPFunctionDlg* pDlg = pFact->CreateScDPFunctionDlg(
this, RID_SCDLG_DPDATAFIELD, this, RID_SCDLG_DPDATAFIELD,
aLabelDataArr, *pData, rFuncData); aLabelDataArr, *pData, rFuncData);
...@@ -1143,7 +1141,7 @@ bool ScDPLayoutDlg::Contains( ScDPFuncDataVec* pArr, const ScDPFuncData& rData, ...@@ -1143,7 +1141,7 @@ bool ScDPLayoutDlg::Contains( ScDPFuncDataVec* pArr, const ScDPFuncData& rData,
ScDPFuncDataVec::const_iterator itr, itrBeg = pArr->begin(), itrEnd = pArr->end(); ScDPFuncDataVec::const_iterator itr, itrBeg = pArr->begin(), itrEnd = pArr->end();
for (itr = itrBeg; itr != itrEnd; ++itr) for (itr = itrBeg; itr != itrEnd; ++itr)
{ {
if (**itr == rData) if (*itr == rData)
{ {
// found! // found!
nAt = ::std::distance(itrBeg, itr); nAt = ::std::distance(itrBeg, itr);
...@@ -1170,7 +1168,7 @@ void ScDPLayoutDlg::Insert( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, s ...@@ -1170,7 +1168,7 @@ void ScDPLayoutDlg::Insert( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, s
if (!pArr) if (!pArr)
return; return;
ScDPFuncDataRef p (new ScDPFuncData(rFData)); std::auto_ptr<ScDPFuncData> p(new ScDPFuncData(rFData));
if (nAt >= pArr->size()) if (nAt >= pArr->size())
pArr->push_back(p); pArr->push_back(p);
else else
...@@ -1400,7 +1398,7 @@ void ScDPLayoutDlg::AdjustDlgSize() ...@@ -1400,7 +1398,7 @@ void ScDPLayoutDlg::AdjustDlgSize()
namespace { namespace {
class PivotFieldInserter : public ::std::unary_function<void, boost::shared_ptr<ScDPFuncData> > class PivotFieldInserter : public ::std::unary_function<ScDPFuncData, void>
{ {
vector<PivotField>& mrFields; vector<PivotField>& mrFields;
public: public:
...@@ -1411,12 +1409,12 @@ public: ...@@ -1411,12 +1409,12 @@ public:
PivotFieldInserter(const PivotFieldInserter& r) : mrFields(r.mrFields) {} PivotFieldInserter(const PivotFieldInserter& r) : mrFields(r.mrFields) {}
void operator() (const ::boost::shared_ptr<ScDPFuncData>& p) void operator() (const ScDPFuncData& r)
{ {
PivotField aField; PivotField aField;
aField.nCol = p->mnCol; aField.nCol = r.mnCol;
aField.nFuncMask = p->mnFuncMask; aField.nFuncMask = r.mnFuncMask;
aField.maFieldRef = p->maFieldRef; aField.maFieldRef = r.maFieldRef;
mrFields.push_back(aField); mrFields.push_back(aField);
} }
}; };
...@@ -1670,7 +1668,7 @@ sal_uInt8 ScDPLayoutDlg::GetNextDupCount( ...@@ -1670,7 +1668,7 @@ sal_uInt8 ScDPLayoutDlg::GetNextDupCount(
bool bFound = false; bool bFound = false;
for (size_t i = 0, n = rArr.size(); i < n; ++i) for (size_t i = 0, n = rArr.size(); i < n; ++i)
{ {
const ScDPFuncData& r = *rArr[i]; const ScDPFuncData& r = rArr[i];
if (i == nDataIndex) if (i == nDataIndex)
// Skip itself. // Skip itself.
continue; continue;
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <boost/shared_ptr.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_ptr.hpp>
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
#include <vcl/scrbar.hxx> #include <vcl/scrbar.hxx>
...@@ -110,9 +111,8 @@ protected: ...@@ -110,9 +111,8 @@ protected:
virtual void Deactivate(); virtual void Deactivate();
private: private:
typedef boost::shared_ptr< ScDPFuncData > ScDPFuncDataRef; typedef boost::ptr_vector<ScDPFuncData> ScDPFuncDataVec;
typedef std::vector< ScDPFuncDataRef > ScDPFuncDataVec; typedef boost::scoped_ptr<ScDPObject> ScDPObjectPtr;
typedef std::auto_ptr< ScDPObject > ScDPObjectPtr;
FixedLine aFlLayout; FixedLine aFlLayout;
FixedText aFtPage; FixedText aFtPage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment