diff options
-rw-r--r-- | sc/inc/column.hxx | 2 | ||||
-rw-r--r-- | sc/inc/document.hxx | 1 | ||||
-rw-r--r-- | sc/inc/global.hxx | 7 | ||||
-rw-r--r-- | sc/inc/mtvelements.hxx | 2 | ||||
-rw-r--r-- | sc/inc/table.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 18 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 10 |
9 files changed, 57 insertions, 4 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 372aef84c24e..36ea217a481a 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -666,6 +666,8 @@ public: // Spaklines sc::SparklineCell* GetSparklineCell(SCROW nRow); void CreateSparklineCell(SCROW nRow, std::shared_ptr<sc::Sparkline> const& pSparkline); + void DeleteSparklineCells(sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2); + bool DeleteSparkline(SCROW nRow); // cell notes ScPostIt* GetCellNote( SCROW nRow ); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 84199c00de4c..420c0eb06e35 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1252,6 +1252,7 @@ public: SC_DLLPUBLIC sc::Sparkline* GetSparkline(ScAddress const & rPosition); SC_DLLPUBLIC sc::Sparkline* CreateSparkline(ScAddress const & rPosition, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup); SC_DLLPUBLIC sc::SparklineList* GetSparklineList(SCTAB nTab); + SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rPosition); /** Notes **/ SC_DLLPUBLIC ScPostIt* GetNote(const ScAddress& rPos); diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 5c6293432b67..decf343154ae 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -157,19 +157,20 @@ enum class InsertDeleteFlags : sal_uInt16 OBJECTS = 0x0080, /// Drawing objects. EDITATTR = 0x0100, /// Rich-text attributes. OUTLINE = 0x0800, /// Sheet / outlining (grouping) information + SPARKLINES = 0x4000, /// Sparklines in a cell. NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes. ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes. SPECIAL_BOOLEAN = 0x1000, FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes. ATTRIB = HARDATTR | STYLES, - CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE, - ALL = CONTENTS | ATTRIB | OBJECTS, + CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE | SPARKLINES, + ALL = CONTENTS | ATTRIB | OBJECTS | SPARKLINES, /// Copy flags for auto/series fill functions: do not touch notes and drawing objects. AUTOFILL = ALL & ~(NOTE | OBJECTS) }; namespace o3tl { - template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x3fff> {}; + template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x7fff> {}; } // This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work. //static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match"); diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx index ee669c0a6e6b..72f65d2b72ff 100644 --- a/sc/inc/mtvelements.hxx +++ b/sc/inc/mtvelements.hxx @@ -142,6 +142,7 @@ typedef mdds::mtv::soa::multi_type_vector<CellFunc, CellStoreTrait> CellStoreTyp struct ColumnBlockPosition { CellNoteStoreType::iterator miCellNotePos; + SparklineStoreType::iterator miSparklinePos; BroadcasterStoreType::iterator miBroadcasterPos; CellTextAttrStoreType::iterator miCellTextAttrPos; CellStoreType::iterator miCellPos; @@ -152,6 +153,7 @@ struct ColumnBlockPosition struct ColumnBlockConstPosition { CellNoteStoreType::const_iterator miCellNotePos; + SparklineStoreType::const_iterator miSparklinePos; CellTextAttrStoreType::const_iterator miCellTextAttrPos; CellStoreType::const_iterator miCellPos; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 996f9a579d70..00ae196f88ab 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -474,6 +474,7 @@ public: sc::Sparkline* GetSparkline(SCCOL nCol, SCROW nRow); sc::Sparkline* CreateSparkline(SCCOL nCol, SCROW nRow, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup); + bool DeleteSparkline(SCCOL nCol, SCROW nRow); sc::SparklineList& GetSparklineList(); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 1f0ca6aad9d2..b010cdb7aa73 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1971,6 +1971,8 @@ void ScColumn::PrepareBroadcastersForDestruction() } } +// Sparklines + sc::SparklineCell* ScColumn::GetSparklineCell(SCROW nRow) { return maSparklines.get<sc::SparklineCell*>(nRow); @@ -1981,6 +1983,20 @@ void ScColumn::CreateSparklineCell(SCROW nRow, std::shared_ptr<sc::Sparkline> co maSparklines.set(nRow, new sc::SparklineCell(pSparkline)); } +void ScColumn::DeleteSparklineCells(sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2) +{ + rBlockPos.miSparklinePos = maSparklines.set_empty(rBlockPos.miSparklinePos, nRow1, nRow2); +} + +bool ScColumn::DeleteSparkline(SCROW nRow) +{ + if (!GetDoc().ValidRow(nRow)) + return false; + + maSparklines.set_empty(nRow, nRow); + return true; +} + namespace { struct BroadcasterNoListenersPredicate @@ -2003,6 +2019,8 @@ void ScColumn::DeleteEmptyBroadcasters() mbEmptyBroadcastersPending = false; } +// Notes + ScPostIt* ScColumn::GetCellNote(SCROW nRow) { return maCellNotes.get<ScPostIt*>(nRow); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 4aa91b89d919..19d731c8b0c3 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -980,6 +980,11 @@ void ScColumn::DeleteArea( DeleteCellNotes(aBlockPos, nStartRow, nEndRow, bForgetCaptionOwnership); } + if (nDelFlag & InsertDeleteFlags::SPARKLINES) + { + DeleteSparklineCells(aBlockPos, nStartRow, nEndRow); + } + if ( nDelFlag & InsertDeleteFlags::EDITATTR ) { OSL_ENSURE( nContFlag == InsertDeleteFlags::NONE, "DeleteArea: Wrong Flags" ); @@ -1008,6 +1013,7 @@ void ScColumn::InitBlockPosition( sc::ColumnBlockPosition& rBlockPos ) rBlockPos.miCellNotePos = maCellNotes.begin(); rBlockPos.miCellTextAttrPos = maCellTextAttrs.begin(); rBlockPos.miCellPos = maCells.begin(); + rBlockPos.miSparklinePos = maSparklines.begin(); } void ScColumn::InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 59d05432ae5c..512d82a02081 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -6589,9 +6589,21 @@ sc::Sparkline* ScDocument::CreateSparkline(ScAddress const& rPosition, std::shar return nullptr; } +bool ScDocument::DeleteSparkline(ScAddress const & rPosition) +{ + SCTAB nTab = rPosition.Tab(); + + if (TableExists(nTab)) + { + return maTabs[nTab]->DeleteSparkline(rPosition.Col(), rPosition.Row()); + } + + return false; +} + sc::SparklineList* ScDocument::GetSparklineList(SCTAB nTab) { - if (ValidTab(nTab) && nTab < SCTAB(maTabs.size())) + if (TableExists(nTab)) { return &maTabs[nTab]->GetSparklineList(); } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 2027ded8b430..99e2af025baf 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1839,6 +1839,16 @@ sc::Sparkline* ScTable::CreateSparkline(SCCOL nCol, SCROW nRow, std::shared_ptr< return pSparkline.get(); } +bool ScTable::DeleteSparkline(SCCOL nCol, SCROW nRow) +{ + if (!ValidCol(nCol) || nCol >= GetAllocatedColumnsCount()) + return false; + + aCol[nCol].DeleteSparkline(nRow); + + return true; +} + sc::SparklineList& ScTable::GetSparklineList() { return maSparklineList; |