diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2013-09-11 09:06:24 +0200 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-23 10:44:20 -0400 |
commit | 759bdbbc348d320994813a9de1a7927b795580a3 (patch) | |
tree | 897cb53c217866ce6b365f76943390e3e6368529 /sc/source/core/data/document.cxx | |
parent | ae88290f87acf693fed02140ca384ec15589616b (diff) |
Re-implement cell note storage using mdds::multi_type_vector.
Change-Id: I34ea91e360e2a6b85d65f970c6e43db687d213ca
Diffstat (limited to 'sc/source/core/data/document.cxx')
-rw-r--r-- | sc/source/core/data/document.cxx | 104 |
1 files changed, 95 insertions, 9 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index dee85dddab83..a6180bc946b4 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -101,6 +101,8 @@ #include <limits> #include <boost/scoped_ptr.hpp> +#include "mtvelements.hxx" + using ::editeng::SvxBorderLine; using namespace ::com::sun::star; @@ -3501,12 +3503,6 @@ bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const } -void ScDocument::InitializeNoteCaptions( SCTAB nTab, bool bForced ) -{ - if( ValidTab( nTab ) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[ nTab ] ) - maTabs[ nTab ]->InitializeNoteCaptions( bForced ); -} - void ScDocument::SetDirty() { bool bOldAutoCalc = GetAutoCalc(); @@ -6064,12 +6060,102 @@ bool ScDocument::IsInVBAMode() const return false; } -ScNotes* ScDocument::GetNotes(SCTAB nTab) +ScPostIt* ScDocument::GetNote(const ScAddress& rPos) +{ + return GetNote(rPos.Col(), rPos.Row(), rPos.Tab()); +} + +ScPostIt* ScDocument::GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab) { if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size())) - return maTabs[nTab]->GetNotes(); + return maTabs[nTab]->aCol[nCol].GetCellNote(nRow); + else + return NULL; - return NULL; +} +sc::CellNoteStoreType& ScDocument::GetColNotes(SCCOL nCol, SCTAB nTab) +{ + return maTabs[nTab]->aCol[nCol].maCellNotes; +} +void ScDocument::SetNote(const ScAddress& rPos, ScPostIt* pNote) +{ + return SetNote(rPos.Col(), rPos.Row(), rPos.Tab(), pNote); +} + +void ScDocument::SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, ScPostIt* pNote) +{ + return maTabs[nTab]->aCol[nCol].SetCellNote(nRow, pNote); +} + +bool ScDocument::HasNote(const ScAddress& rPos) +{ + return HasNote(rPos.Col(), rPos.Row(), rPos.Tab()); +} +bool ScDocument::HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) +{ + ScPostIt* pNote = maTabs[nTab]->aCol[nCol].GetCellNote(nRow); + return pNote != NULL; +} +bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab) +{ + return maTabs[nTab]->aCol[nCol].HasCellNotes(); +} + +bool ScDocument::HasTabNotes(SCTAB nTab) +{ + bool hasNotes = false; + for (SCCOL nCol=0; nCol<MAXCOLCOUNT && !hasNotes; ++nCol) + hasNotes = HasColNotes(nCol, nTab); + + return hasNotes; +} + +ScPostIt* ScDocument::ReleaseNote(const ScAddress& rPos) +{ + return ReleaseNote(rPos.Col(), rPos.Row(), rPos.Tab()); +} +ScPostIt* ScDocument::ReleaseNote(SCCOL nCol, SCROW nRow, SCTAB nTab) +{ + + ScPostIt* pPostIt = GetNote(nCol, nRow, nTab); + if (pPostIt != NULL) + maTabs[nTab]->aCol[nCol].DeleteCellNote(nRow); + + return pPostIt; +} + +ScPostIt* ScDocument::GetOrCreateNote(const ScAddress& rPos) +{ + if (HasNote(rPos)) + return GetNote(rPos); + else + return CreateNote(rPos); +} +ScPostIt* ScDocument::CreateNote(const ScAddress& rPos) +{ + ScPostIt* pPostIt = new ScPostIt(*this, rPos, false); + SetNote(rPos, pPostIt); + return pPostIt; +} + +sal_uLong ScDocument::CountNotes() +{ + sal_uLong nCount = 0; + SCTAB nTabCount = GetTableCount(); + for (SCTAB nTab=0; nTab<nTabCount; nTab++) + { + for (SCCOL nCol=0; nCol<MAXCOLCOUNT; nCol++) + { + sc::CellNoteStoreType& maCellNotes = GetColNotes(nCol, nTab); + sc::CellNoteStoreType::const_iterator it = maCellNotes.begin(), itEnd = maCellNotes.end(); + for (; it != itEnd; ++it) + { + if (it->type == sc::element_type_cellnote) + nCount +=it->size; + } + } + } + return nCount; } void ScDocument::SetAutoNameCache( ScAutoNameCache* pCache ) |