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:51:52 -0500 |
commit | 659d0ebda52cb7252590d9b11ebe0ef461df89a9 (patch) | |
tree | 7cb34e9db7724a8b503bda28ba47442871bb1e09 /sc | |
parent | bdc4f5c2c235ce5e7f501986d6593ef9dab47d33 (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 aa99070d9b77..40a10baa870b 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -823,7 +823,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 { @@ -904,6 +905,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()) |