diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-01-12 00:01:23 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-01-12 21:56:20 -0500 |
commit | 0f2a0fc99deb7b9233dbc39e74e0bfdaf9d6efeb (patch) | |
tree | a5ebc48dbdbde6b14b3fd76a8fc85eaf4e81f9cf /sc | |
parent | 4c4c945f00f028a39bc3534f4f707bade677983b (diff) |
fdo#43077: Copy pivot tables when a sheet is copied.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/dpobject.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 24 |
3 files changed, 30 insertions, 2 deletions
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index dc2094484a20..769e0ac234e4 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -341,7 +341,7 @@ public: void DeleteOnTab( SCTAB nTab ); void UpdateReference( UpdateRefMode eUpdateRefMode, const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ); - + void CopyToTab( SCTAB nOld, SCTAB nNew ); bool RefsEqual( const ScDPCollection& r ) const; void WriteRefsTo( ScDPCollection& r ) const; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 8f2828b6a1b2..5917db0add8c 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -822,7 +822,8 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM { if (nNewPos >= static_cast<SCTAB>(maTabs.size())) { - maTabs.push_back( new ScTable(this, static_cast<SCTAB>(maTabs.size()), aName) ); + nNewPos = static_cast<SCTAB>(maTabs.size()); + maTabs.push_back(new ScTable(this, nNewPos, aName)); } else { @@ -903,6 +904,9 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM if (pDrawLayer) DrawCopyPage( static_cast<sal_uInt16>(nOldPos), static_cast<sal_uInt16>(nNewPos) ); + if (pDPCollection) + pDPCollection->CopyToTab(nOldPos, nNewPos); + maTabs[nNewPos]->SetPageStyle( maTabs[nOldPos]->GetPageStyle() ); maTabs[nNewPos]->SetPendingRowHeights( maTabs[nOldPos]->IsPendingRowHeights() ); diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 063c02adb5f3..a6f48db37ea6 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -2790,6 +2790,30 @@ void ScDPCollection::UpdateReference( UpdateRefMode eUpdateRefMode, maSheetCaches.updateReference(eUpdateRefMode, r, nDx, nDy, nDz); } +void ScDPCollection::CopyToTab( SCTAB nOld, SCTAB nNew ) +{ + TablesType aAdded; + TablesType::const_iterator it = maTables.begin(), itEnd = maTables.end(); + for (; it != itEnd; ++it) + { + const ScDPObject& rObj = *it; + ScRange aOutRange = rObj.GetOutRange(); + if (aOutRange.aStart.Tab() != nOld) + continue; + + ScAddress& s = aOutRange.aStart; + ScAddress& e = aOutRange.aEnd; + s.SetTab(nNew); + e.SetTab(nNew); + std::auto_ptr<ScDPObject> pNew(new ScDPObject(rObj)); + pNew->SetOutRange(aOutRange); + pDoc->ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), SC_MF_DP_TABLE); + aAdded.push_back(pNew); + } + + maTables.transfer(maTables.end(), aAdded.begin(), aAdded.end(), aAdded); +} + bool ScDPCollection::RefsEqual( const ScDPCollection& r ) const { if (maTables.size() != r.maTables.size()) |