[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/qa sc/source

2023-03-02 Thread Kohei Yoshida (via logerrit)
 sc/Library_sc.mk   |1 
 sc/inc/broadcast.hxx   |   86 +++
 sc/inc/calcmacros.hxx  |4 
 sc/inc/column.hxx  |3 
 sc/inc/document.hxx|7 -
 sc/inc/grouparealistener.hxx   |3 
 sc/inc/table.hxx   |3 
 sc/qa/unit/ucalc_formula.cxx   |   85 +--
 sc/source/core/data/bcaslot.cxx|   59 -
 sc/source/core/data/broadcast.cxx  |  164 +
 sc/source/core/data/column4.cxx|   31 ++
 sc/source/core/data/document.cxx   |8 -
 sc/source/core/data/document10.cxx |   15 +++
 sc/source/core/data/table7.cxx |6 +
 sc/source/core/inc/bcaslot.hxx |   15 +--
 15 files changed, 400 insertions(+), 90 deletions(-)

New commits:
commit 687b950702c49c90cff9a43655ea97a0343799a0
Author: Kohei Yoshida 
AuthorDate: Tue Feb 21 22:16:30 2023 -0500
Commit: Kohei Yoshida 
CommitDate: Thu Mar 2 23:35:56 2023 +

Add a means to query the internal broadcaster state ...

... and use it in one unit test case.  Also, remove the code inside
DEBUG_AREA_BROADCASTER macro since it no longer builds & has been
superceded by this new state query method.

Change-Id: I38691a76df5c63034ff488522936dd566bf8b4e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148079
Tested-by: Kohei Yoshida 
Reviewed-by: Kohei Yoshida 

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 4d3c7398b43d..49c36cf27d3c 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -104,6 +104,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/core/data/attrib \
 sc/source/core/data/autonamecache \
 sc/source/core/data/bcaslot \
+sc/source/core/data/broadcast \
 sc/source/core/data/bigrange \
 sc/source/core/data/celltextattr \
 sc/source/core/data/cellvalue \
diff --git a/sc/inc/broadcast.hxx b/sc/inc/broadcast.hxx
new file mode 100644
index ..b095f819acb7
--- /dev/null
+++ b/sc/inc/broadcast.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include "address.hxx"
+
+#include 
+#include 
+#include 
+
+class ScFormulaCell;
+class SvtListener;
+
+namespace sc
+{
+class FormulaGroupAreaListener;
+
+struct BroadcasterState
+{
+enum class CellListenerType
+{
+FormulaCell,
+Generic,
+};
+
+enum class AreaListenerType
+{
+FormulaCell,
+FormulaGroup,
+Generic,
+};
+
+struct CellListener
+{
+using DataType = std::variant;
+
+CellListenerType eType;
+DataType pData;
+
+CellListener(const ScFormulaCell* p);
+CellListener(const SvtListener* p);
+};
+
+struct AreaListener
+{
+using DataType = std::variant;
+
+AreaListenerType eType;
+DataType pData;
+
+AreaListener(const ScFormulaCell* p);
+AreaListener(const sc::FormulaGroupAreaListener* p);
+AreaListener(const SvtListener* p);
+};
+
+std::map> aCellListenerStore;
+std::map> aAreaListenerStore;
+
+/**
+ * Check if a formula cell listens on a single cell.
+ */
+bool hasFormulaCellListener(const ScAddress& rBroadcasterPos,
+const ScAddress& rFormulaPos) const;
+
+/**
+ * Check if a formula cell listens on a single range.
+ */
+bool hasFormulaCellListener(const ScRange& rBroadcasterRange,
+const ScAddress& rFormulaPos) const;
+
+/**
+ * Dump all broadcaster state in YAML format.
+ */
+void dump(std::ostream& rStrm, const ScDocument* pDoc = nullptr) const;
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/calcmacros.hxx b/sc/inc/calcmacros.hxx
index c0c68d4487cf..ebe96654804a 100644
--- a/sc/inc/calcmacros.hxx
+++ b/sc/inc/calcmacros.hxx
@@ -12,7 +12,6 @@
 #define DEBUG_COLUMN_STORAGE 0
 #define DEBUG_PIVOT_TABLE 0
 #define DEBUG_FORMULA_COMPILER 0
-#define DEBUG_AREA_BROADCASTER 0
 
 #define DUMP_COLUMN_STORAGE 0
 #define DUMP_PIVOT_TABLE 0
@@ -26,8 +25,7 @@
 
 #if DUMP_PIVOT_TABLE || DEBUG_PIVOT_TABLE || \
 DUMP_COLUMN_STORAGE || DEBUG_COLUMN_STORAGE || \
-DEBUG_FORMULA_COMPILER || \
-DEBUG_AREA_BROADCASTER
+DEBUG_FORMULA_COMPILER
 #include 
 using std::cout;
 using std::cerr;
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 949ca30dd137..5c42f02794ab 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -42,6 +42,7 @@ namespace formula { struct VectorRefArray; }
 
 namespace sc {
 
+struct BroadcasterState;
 struct FormulaGroupEntry;
 

[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/qa sc/source

2022-05-11 Thread Luboš Luňák (via logerrit)
 sc/Library_sc.mk   |1 
 sc/inc/document.hxx|4 
 sc/inc/interpretercontext.hxx  |4 
 sc/inc/lookupcache.hxx |4 
 sc/inc/queryiter.hxx   |   56 +++-
 sc/inc/rangecache.hxx  |  109 +++
 sc/qa/unit/ucalc_sort.cxx  |2 
 sc/source/core/data/documen2.cxx   |   45 ++
 sc/source/core/data/queryiter.cxx  |  202 -
 sc/source/core/tool/interpr1.cxx   |   15 +-
 sc/source/core/tool/interpretercontext.cxx |   19 +-
 sc/source/core/tool/lookupcache.cxx|   11 -
 sc/source/core/tool/rangecache.cxx |   67 +
 13 files changed, 508 insertions(+), 31 deletions(-)

New commits:
commit 122e676ce35b34c289cc4c91bb72e25398dc9e12
Author: Luboš Luňák 
AuthorDate: Thu May 5 14:56:52 2022 +0200
Commit: Luboš Luňák 
CommitDate: Wed May 11 11:46:30 2022 +0200

introduce Calc cache for sorted handling of unsorted cells

The idea is that there's a cache for a given range, which keeps
a vector of SCROW items, sorted by values of those cells. This
allows some specific cases of e.g. COUNTIF to simply use
BinarySearch() to find the range that matches and work only with
that. This commit implements using this cache for COUNTIF.

Change-Id: I5b36b289b4aecb3b8245bbb447fbb299371262e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134120
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index c6f65d4ec495..f8e097d538a3 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/core/tool/progress \
 sc/source/core/tool/queryentry \
 sc/source/core/tool/queryparam \
+sc/source/core/tool/rangecache \
 sc/source/core/tool/rangelst \
 sc/source/core/tool/rangenam \
 sc/source/core/tool/rangeseq \
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 2242ba2450ac..2f79825979a9 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -182,6 +182,8 @@ class ScAutoNameCache;
 class ScTemporaryChartLock;
 class ScLookupCache;
 struct ScLookupCacheMap;
+class ScSortedRangeCache;
+struct ScSortedRangeCacheMap;
 class SfxUndoManager;
 class ScFormulaParserPool;
 struct ScClipParam;
@@ -1397,9 +1399,11 @@ public:
 /** Creates a ScLookupCache cache for the range if it
 doesn't already exist. */
 ScLookupCache & GetLookupCache( const ScRange & rRange, 
ScInterpreterContext* pContext );
+ScSortedRangeCache & GetSortedRangeCache( const ScRange & rRange, bool 
bDescending, ScInterpreterContext* pContext );
 /** Only ScLookupCache dtor uses RemoveLookupCache(), do
 not use elsewhere! */
 voidRemoveLookupCache( ScLookupCache & rCache );
+voidRemoveSortedRangeCache( ScSortedRangeCache & rCache );
 /** Zap all caches. */
 voidClearLookupCaches();
 
diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx
index 78156b005af1..07e20f3a887e 100644
--- a/sc/inc/interpretercontext.hxx
+++ b/sc/inc/interpretercontext.hxx
@@ -23,6 +23,7 @@ class FormulaToken;
 class ScDocument;
 class SvNumberFormatter;
 struct ScLookupCacheMap;
+struct ScSortedRangeCacheMap;
 class ScInterpreter;
 enum class SvNumFormatType : sal_Int16;
 
@@ -57,6 +58,7 @@ struct ScInterpreterContext
 std::vector maTokens;
 std::vector maDelayedSetNumberFormat;
 std::unique_ptr mxScLookupCache; // cache for lookups 
like VLOOKUP and MATCH
+std::unique_ptr mxScSortedRangeCache; // cache for 
unsorted lookups
 // Allocation cache for "aConditions" array in 
ScInterpreter::IterateParameterIfs()
 // This is populated/used only when formula-group threading is enabled.
 std::vector maConditions;
@@ -83,6 +85,7 @@ private:
 void SetDocAndFormatter(const ScDocument& rDoc, SvNumberFormatter* 
pFormatter);
 void Cleanup();
 void ClearLookupCache();
+void ClearSortedRangeCache();
 void initFormatTable();
 SvNumberFormatter* mpFormatter;
 mutable NFIndexAndFmtType maNFTypeCache;
@@ -136,6 +139,7 @@ class ScInterpreterContextPool
 public:
 // Only to be used to clear lookup cache in all pool elements
 static void ClearLookupCaches();
+static void ClearSortedRangeCaches();
 };
 
 class ScThreadedInterpreterContextGetterGuard
diff --git a/sc/inc/lookupcache.hxx b/sc/inc/lookupcache.hxx
index 57ee88a4fa28..ca1d333880fa 100644
--- a/sc/inc/lookupcache.hxx
+++ b/sc/inc/lookupcache.hxx
@@ -110,8 +110,8 @@ public:
 };
 
 /// MUST be new'd because Notify() deletes.
-ScLookupCache( ScDocument * pDoc, const ScRange & 
rRange, ScLookupCacheMap & cacheMap );
-virtual 

[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/qa sc/source

2022-04-04 Thread Tomaž Vajngerl (via logerrit)
 sc/Library_sc.mk |1 
 sc/inc/SparklineGroup.hxx|3 
 sc/inc/globstr.hrc   |1 
 sc/qa/unit/SparklineTest.cxx |   69 ++
 sc/source/ui/dialogs/SparklineDialog.cxx |  146 ++-
 sc/source/ui/docshell/docfunc.cxx|   12 +
 sc/source/ui/inc/SparklineDialog.hxx |6 
 sc/source/ui/inc/docfunc.hxx |4 
 sc/source/ui/inc/undo/UndoEditSparklineGroup.hxx |   44 ++
 sc/source/ui/sparklines/SparklineGroup.cxx   |6 
 sc/source/ui/undo/UndoEditSparklineGroup.cxx |   65 ++
 11 files changed, 279 insertions(+), 78 deletions(-)

New commits:
commit 12bb0d897d97c9231e86d6b0071f8a0d29c7e660
Author: Tomaž Vajngerl 
AuthorDate: Thu Mar 31 23:07:44 2022 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Apr 5 06:42:05 2022 +0200

sc: add SparklineGroup Undo/Redo

As SparklineAttributes are COW, we can just exchange them around
in the SparklineGroup when undoing and redoing.

This also changes SparklineDialog to work with a local copy of
SparklineAttributes when editing, or an empty initial copy when
inserting a new Sparkline into the sheet.

Change-Id: I36e9c887ca640f40266f381e98e57f027a5ca07f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132542
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index e97f6e04b4c2..294c36b4578c 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -555,6 +555,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/undo/undotab \
 sc/source/ui/undo/undoutil \
 sc/source/ui/undo/UndoInsertSparkline \
+sc/source/ui/undo/UndoEditSparklineGroup \
 sc/source/ui/undo/UndoDeleteSparkline \
 sc/source/ui/unoobj/ChartRangeSelectionListener \
 sc/source/ui/unoobj/addruno \
diff --git a/sc/inc/SparklineGroup.hxx b/sc/inc/SparklineGroup.hxx
index c5e917f059f3..7d2e75e6e9e3 100644
--- a/sc/inc/SparklineGroup.hxx
+++ b/sc/inc/SparklineGroup.hxx
@@ -29,12 +29,15 @@ public:
 SparklineAttributes& getAttributes() { return m_aAttributes; }
 SparklineAttributes const& getAttributes() const { return m_aAttributes; }
 
+void setAttributes(SparklineAttributes const& rAttributes) { m_aAttributes 
= rAttributes; };
+
 tools::Guid& getID() { return m_aGUID; }
 
 void setID(tools::Guid const& rGuid) { m_aGUID = rGuid; }
 
 SparklineGroup();
 SparklineGroup(SparklineGroup const& pOtherSparkline);
+SparklineGroup(SparklineAttributes const& rSparklineAttributes);
 
 SparklineGroup& operator=(const SparklineGroup&) = delete;
 };
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 0eb0e7929625..de33f2d4e61b 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -541,6 +541,7 @@
 #define STR_INDENTCELL  NC_("STR_INDENTCELL", "Indent: 
")
 #define STR_UNDO_INSERT_SPARKLINE_GROUP 
NC_("STR_UNDO_INSERT_SPARKLINE", "Insert Sparkline Group")
 #define STR_UNDO_DELETE_SPARKLINE   
NC_("STR_UNDO_DELETE_SPARKLINE", "Delete Sparkline")
+#define STR_UNDO_EDIT_SPARKLINE_GROUP   
NC_("STR_UNDO_EDIT_SPARKLINE_GROUP", "Edit Sparkline Group")
 
 #endif
 
diff --git a/sc/qa/unit/SparklineTest.cxx b/sc/qa/unit/SparklineTest.cxx
index 6e203131e9c5..42ac88467b6d 100644
--- a/sc/qa/unit/SparklineTest.cxx
+++ b/sc/qa/unit/SparklineTest.cxx
@@ -53,6 +53,7 @@ public:
 void testUndoRedoInsertSparkline();
 void testUndoRedoDeleteSparkline();
 void testUndoRedoClearContentForSparkline();
+void testUndoRedoEditSparklineGroup();
 
 CPPUNIT_TEST_SUITE(SparklineTest);
 CPPUNIT_TEST(testAddSparkline);
@@ -62,6 +63,7 @@ public:
 CPPUNIT_TEST(testUndoRedoInsertSparkline);
 CPPUNIT_TEST(testUndoRedoDeleteSparkline);
 CPPUNIT_TEST(testUndoRedoClearContentForSparkline);
+CPPUNIT_TEST(testUndoRedoEditSparklineGroup);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -427,6 +429,73 @@ void SparklineTest::testUndoRedoClearContentForSparkline()
 xDocSh->DoClose();
 }
 
+void SparklineTest::testUndoRedoEditSparklineGroup()
+{
+ScDocShellRef xDocSh = loadEmptyDocument();
+CPPUNIT_ASSERT(xDocSh);
+
+ScDocument& rDocument = xDocSh->GetDocument();
+ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false);
+CPPUNIT_ASSERT(pViewShell);
+
+auto& rDocFunc = xDocSh->GetDocFunc();
+
+auto pSparklineGroup = std::make_shared();
+{
+sc::SparklineAttributes& rAttibutes = pSparklineGroup->getAttributes();
+rAttibutes.setType(sc::SparklineType::Column);
+rAttibutes.setColorSeries(COL_YELLOW);
+rAttibutes.setColorAxis(COL_GREEN);
+}
+
+rDocument.CreateSparkline(ScAddress(0, 6, 0), pSparklineGroup);
+
+sc::SparklineAttributes aNewAttributes;
+aNewAttributes.setType(sc::SparklineType::Stacked);
+

[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/qa sc/source

2022-04-04 Thread Tomaž Vajngerl (via logerrit)
 sc/Library_sc.mk|2 
 sc/inc/SparklineAttributes.hxx  |  145 
 sc/inc/SparklineGroup.hxx   |  118 --
 sc/qa/unit/SparklineImportExportTest.cxx|  124 +-
 sc/source/filter/excel/export/SparklineExt.cxx  |   94 
 sc/source/filter/inc/export/SparklineExt.hxx|6 
 sc/source/filter/oox/SparklineFragment.cxx  |   80 +++
 sc/source/ui/dialogs/SparklineDialog.cxx|   70 +++---
 sc/source/ui/sparklines/SparklineAttributes.cxx |  273 
 sc/source/ui/sparklines/SparklineGroup.cxx  |   25 ++
 sc/source/ui/view/output.cxx|   79 +++---
 11 files changed, 684 insertions(+), 332 deletions(-)

New commits:
commit 634399594cfd1672caaf412ed4bc945f12aa4913
Author: Tomaž Vajngerl 
AuthorDate: Tue Mar 22 15:12:55 2022 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Apr 4 14:25:40 2022 +0200

sc: split attrs out of SparklineGroup into a COW class

The attributes can be independent of the actual SparklineGroup,
so they can be shared through multiple SparklineGroups and with
the attributes being COW, they can be safely changed without the
fear that it will impact a different SparklineGroup insstance.

Change-Id: I274b1243d014288ea34a213326ef765ceff86a58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132502
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 7a7cf817e004..2c78147abf62 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -512,7 +512,9 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/sidebar/NumberFormatControl \
 sc/source/ui/sidebar/NumberFormatPropertyPanel \
 sc/source/ui/sidebar/ScPanelFactory \
+sc/source/ui/sparklines/SparklineAttributes \
 sc/source/ui/sparklines/SparklineData \
+sc/source/ui/sparklines/SparklineGroup \
 sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog \
 sc/source/ui/StatisticsDialogs/CorrelationDialog \
 sc/source/ui/StatisticsDialogs/CovarianceDialog \
diff --git a/sc/inc/SparklineAttributes.hxx b/sc/inc/SparklineAttributes.hxx
new file mode 100644
index ..e89e15bc1a1b
--- /dev/null
+++ b/sc/inc/SparklineAttributes.hxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include "scdllapi.h"
+#include 
+#include 
+#include 
+#include 
+
+namespace sc
+{
+/** Supported sparkline types */
+enum class SparklineType
+{
+Line,
+Column,
+Stacked
+};
+
+/** The method of calculating the axis min or max value */
+enum class AxisType
+{
+Individual, // calculate the min/max of a sparkline
+Group, // calculate the min or max of the whole sparkline group
+Custom // user defined
+};
+
+/** Determines how to display the empty cells */
+enum class DisplayEmptyCellsAs
+{
+Span,
+Gap,
+Zero // empty cell equals zero
+};
+
+/** Common properties for a group of sparklines */
+class SC_DLLPUBLIC SparklineAttributes
+{
+private:
+class Implementation;
+o3tl::cow_wrapper m_aImplementation;
+
+public:
+SparklineAttributes();
+~SparklineAttributes();
+SparklineAttributes(const SparklineAttributes& rOther);
+SparklineAttributes(SparklineAttributes&& rOther);
+SparklineAttributes& operator=(const SparklineAttributes& rOther);
+SparklineAttributes& operator=(SparklineAttributes&& rOther);
+
+bool operator==(const SparklineAttributes& rOther) const;
+bool operator!=(const SparklineAttributes& rOther) const
+{
+return !(SparklineAttributes::operator==(rOther));
+}
+
+Color getColorSeries() const;
+void setColorSeries(Color aColorSeries);
+
+Color getColorNegative() const;
+void setColorNegative(Color aColorSeries);
+
+Color getColorAxis() const;
+void setColorAxis(Color aColorSeries);
+
+Color getColorMarkers() const;
+void setColorMarkers(Color aColorSeries);
+
+Color getColorFirst() const;
+void setColorFirst(Color aColorSeries);
+
+Color getColorLast() const;
+void setColorLast(Color aColorSeries);
+
+Color getColorHigh() const;
+void setColorHigh(Color aColorSeries);
+
+Color getColorLow() const;
+void setColorLow(Color aColorSeries);
+
+AxisType getMinAxisType() const;
+void setMinAxisType(AxisType eAxisType);
+
+AxisType getMaxAxisType() const;
+void setMaxAxisType(AxisType eAxisType);
+
+/** Line weigth or width in points */
+double getLineWeight() const;
+void setLineWeight(double nWeight);
+
+SparklineType getType() const;
+

[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/qa sc/source

2022-04-04 Thread Tomaž Vajngerl (via logerrit)
 sc/Library_sc.mk  |1 
 sc/inc/document.hxx   |1 
 sc/inc/globstr.hrc|2 
 sc/qa/unit/SparklineTest.cxx  |   69 ++-
 sc/source/core/data/document.cxx  |5 +
 sc/source/ui/docshell/docfunc.cxx |   16 +
 sc/source/ui/inc/docfunc.hxx  |2 
 sc/source/ui/inc/undo/UndoDeleteSparkline.hxx |   43 ++
 sc/source/ui/undo/UndoDeleteSparkline.cxx |   76 ++
 9 files changed, 212 insertions(+), 3 deletions(-)

New commits:
commit 20ed714f87dd22e5f11a65c4208045037dc20017
Author: Tomaž Vajngerl 
AuthorDate: Mon Mar 21 17:26:30 2022 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Apr 4 09:52:29 2022 +0200

sc: add Undo/Redo for deleting a Sparkline

Adds the code to delete the Sparkline via DocFunc + test.

Change-Id: I710a1ee59a5fe5f2bfb91f8bf487501ef39ce949
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132475
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 2a9c6f659a0a..7a7cf817e004 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -551,6 +551,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/undo/undotab \
 sc/source/ui/undo/undoutil \
 sc/source/ui/undo/UndoInsertSparkline \
+sc/source/ui/undo/UndoDeleteSparkline \
 sc/source/ui/unoobj/ChartRangeSelectionListener \
 sc/source/ui/unoobj/addruno \
 sc/source/ui/unoobj/afmtuno \
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 979f6d6985f1..3ae441f895e3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1250,6 +1250,7 @@ public:
 
 /** Spaklines */
 SC_DLLPUBLIC std::shared_ptr GetSparkline(ScAddress const & 
rPosition);
+SC_DLLPUBLIC bool HasSparkline(ScAddress const & rPosition);
 SC_DLLPUBLIC sc::Sparkline* CreateSparkline(ScAddress const & rPosition, 
std::shared_ptr const& pSparklineGroup);
 SC_DLLPUBLIC sc::SparklineList* GetSparklineList(SCTAB nTab);
 SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rPosition);
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 6ae26c9d4a0f..bed2e10f9b51 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -540,6 +540,8 @@
 #define STR_HYPHENATECELL_OFF   NC_("STR_HYPHENATECELL_OFF", 
"Hyphenate: Off")
 #define STR_INDENTCELL  NC_("STR_INDENTCELL", "Indent: 
")
 #define STR_UNDO_INSERT_SPARKLINE_GROUP 
NC_("STR_UNDO_INSERT_SPARKLINE", "Insert Sparkline Group")
+#define STR_UNDO_DELETE_SPARKLINE   
NC_("STR_UNDO_DELETE_SPARKLINE", "Delete Sparkline")
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/SparklineTest.cxx b/sc/qa/unit/SparklineTest.cxx
index 7fafeef861ef..6173cea5f297 100644
--- a/sc/qa/unit/SparklineTest.cxx
+++ b/sc/qa/unit/SparklineTest.cxx
@@ -47,17 +47,19 @@ public:
 }
 
 void testAddSparkline();
-void testDeleteSprkline();
+void testClearContentSprkline();
 void testCopyPasteSparkline();
 void testCutPasteSparkline();
 void testUndoRedoInsertSparkline();
+void testUndoRedoDeleteSparkline();
 
 CPPUNIT_TEST_SUITE(SparklineTest);
 CPPUNIT_TEST(testAddSparkline);
-CPPUNIT_TEST(testDeleteSprkline);
+CPPUNIT_TEST(testClearContentSprkline);
 CPPUNIT_TEST(testCopyPasteSparkline);
 CPPUNIT_TEST(testCutPasteSparkline);
 CPPUNIT_TEST(testUndoRedoInsertSparkline);
+CPPUNIT_TEST(testUndoRedoDeleteSparkline);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -117,7 +119,7 @@ void SparklineTest::testAddSparkline()
 xDocSh->DoClose();
 }
 
-void SparklineTest::testDeleteSprkline()
+void SparklineTest::testClearContentSprkline()
 {
 ScDocShellRef xDocSh = loadEmptyDocument();
 CPPUNIT_ASSERT(xDocSh);
@@ -288,6 +290,67 @@ void SparklineTest::testUndoRedoInsertSparkline()
 xDocSh->DoClose();
 }
 
+void SparklineTest::testUndoRedoDeleteSparkline()
+{
+ScDocShellRef xDocSh = loadEmptyDocument();
+CPPUNIT_ASSERT(xDocSh);
+
+ScDocument& rDocument = xDocSh->GetDocument();
+ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false);
+CPPUNIT_ASSERT(pViewShell);
+
+auto& rDocFunc = xDocSh->GetDocFunc();
+
+// Try to delete sparkline that doesn't exist - returns false
+CPPUNIT_ASSERT(!rDocFunc.DeleteSparkline(ScAddress(0, 6, 0)));
+
+// insert test data - A1:A6
+insertTestData(rDocument);
+
+// Sparkline range
+ScRange aRange(0, 6, 0, 0, 6, 0);
+
+// Check Sparkline at cell A7 doesn't exists
+auto pSparkline = rDocument.GetSparkline(aRange.aStart);
+CPPUNIT_ASSERT(!pSparkline);
+
+auto pSparklineGroup = std::make_shared();
+CPPUNIT_ASSERT(rDocFunc.InsertSparklines(ScRange(0, 0, 0, 0, 5, 0), 
aRange, pSparklineGroup));
+
+// Check Sparkline at cell A7 exists
+

[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/qa sc/source

2022-04-04 Thread Tomaž Vajngerl (via logerrit)
 sc/Library_sc.mk  |2 
 sc/inc/SparklineData.hxx  |   42 +++
 sc/inc/globstr.hrc|2 
 sc/qa/unit/SparklineTest.cxx  |   78 ++---
 sc/source/ui/dialogs/SparklineDialog.cxx  |   95 ++
 sc/source/ui/docshell/docfunc.cxx |   82 ++
 sc/source/ui/inc/docfunc.hxx  |7 +
 sc/source/ui/inc/undo/UndoInsertSparkline.hxx |   45 
 sc/source/ui/sparklines/SparklineData.cxx |   30 
 sc/source/ui/undo/UndoInsertSparkline.cxx |   78 +
 10 files changed, 364 insertions(+), 97 deletions(-)

New commits:
commit 54536bca332651051dc8a5ba02995c069cb75fd2
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 20 20:49:18 2022 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Apr 4 09:52:09 2022 +0200

sc: add Undo/Redo for inserting Sparklines

Move the code to insert a sparkline from the SparklineDialog to
DocFunc and inside the UndoInsertSparkline, so there is no code
duplication and the code can be tested.

Change-Id: I85f4020190ae835b33e706ec9cb2cda9fd6fc752
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132474
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index f145d3a7fbf2..2a9c6f659a0a 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -512,6 +512,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/sidebar/NumberFormatControl \
 sc/source/ui/sidebar/NumberFormatPropertyPanel \
 sc/source/ui/sidebar/ScPanelFactory \
+sc/source/ui/sparklines/SparklineData \
 sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog \
 sc/source/ui/StatisticsDialogs/CorrelationDialog \
 sc/source/ui/StatisticsDialogs/CovarianceDialog \
@@ -549,6 +550,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/undo/undostyl \
 sc/source/ui/undo/undotab \
 sc/source/ui/undo/undoutil \
+sc/source/ui/undo/UndoInsertSparkline \
 sc/source/ui/unoobj/ChartRangeSelectionListener \
 sc/source/ui/unoobj/addruno \
 sc/source/ui/unoobj/afmtuno \
diff --git a/sc/inc/SparklineData.hxx b/sc/inc/SparklineData.hxx
new file mode 100644
index ..80cc8a0329c2
--- /dev/null
+++ b/sc/inc/SparklineData.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include "address.hxx"
+#include "scdllapi.h"
+
+namespace sc
+{
+struct SC_DLLPUBLIC SparklineData
+{
+ScAddress maPosition;
+ScRange maData;
+
+SparklineData(ScAddress const& rPosition, ScRange const& rData)
+: maPosition(rPosition)
+, maData(rData)
+{
+}
+};
+
+enum class RangeOrientation
+{
+Unknown,
+Row,
+Col
+};
+
+SC_DLLPUBLIC RangeOrientation calculateOrientation(sal_Int32 nOutputSize,
+   ScRange const& rInputRange);
+
+} // end sc
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 793d3cb95d55..6ae26c9d4a0f 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -539,7 +539,7 @@
 #define STR_HYPHENATECELL_ONNC_("STR_HYPHENATECELL_ON", 
"Hyphenate: On")
 #define STR_HYPHENATECELL_OFF   NC_("STR_HYPHENATECELL_OFF", 
"Hyphenate: Off")
 #define STR_INDENTCELL  NC_("STR_INDENTCELL", "Indent: 
")
-
+#define STR_UNDO_INSERT_SPARKLINE_GROUP 
NC_("STR_UNDO_INSERT_SPARKLINE", "Insert Sparkline Group")
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/SparklineTest.cxx b/sc/qa/unit/SparklineTest.cxx
index 167c4e4d9e3d..7fafeef861ef 100644
--- a/sc/qa/unit/SparklineTest.cxx
+++ b/sc/qa/unit/SparklineTest.cxx
@@ -11,6 +11,8 @@
 #include 
 #include 
 #include 
+#include 
+
 #include 
 #include 
 
@@ -21,8 +23,6 @@ class SparklineTest : public ScBootstrapFixture
 private:
 uno::Reference m_xCalcComponent;
 
-sc::Sparkline* createTestSparkline(ScDocument& rDocument);
-
 public:
 SparklineTest()
 : ScBootstrapFixture("sc/qa/unit/data")
@@ -50,29 +50,38 @@ public:
 void testDeleteSprkline();
 void testCopyPasteSparkline();
 void testCutPasteSparkline();
+void testUndoRedoInsertSparkline();
 
 CPPUNIT_TEST_SUITE(SparklineTest);
 CPPUNIT_TEST(testAddSparkline);
 CPPUNIT_TEST(testDeleteSprkline);
 CPPUNIT_TEST(testCopyPasteSparkline);
 CPPUNIT_TEST(testCutPasteSparkline);
+CPPUNIT_TEST(testUndoRedoInsertSparkline);
 

[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/qa sc/source

2018-07-08 Thread Vikas Mahato
 sc/Library_sc.mk  |1 
 sc/inc/datamapper.hxx |6 +
 sc/qa/unit/data/dataprovider/xml/test1.xml|   19 +++
 sc/qa/unit/dataproviders_test.cxx |   44 
 sc/source/ui/dataprovider/dataprovider.cxx|   16 +++
 sc/source/ui/dataprovider/xmldataprovider.cxx |  128 ++
 sc/source/ui/dataprovider/xmldataprovider.hxx |   41 
 7 files changed, 255 insertions(+)

New commits:
commit e300efd3a029672e24114914355c5c690fb725d5
Author: Vikas Mahato 
Date:   Sun Jun 24 20:53:01 2018 +0530

Added XML data provider

Change-Id: Ib5727912977eb79cdf1f84bf874919beafc693eb
Reviewed-on: https://gerrit.libreoffice.org/56356
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard 

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 2f4f06b6ea25..5425d681caab 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -399,6 +399,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/dataprovider/dataprovider \
 sc/source/ui/dataprovider/datatransformation \
 sc/source/ui/dataprovider/htmldataprovider \
+sc/source/ui/dataprovider/xmldataprovider \
 sc/source/ui/dbgui/asciiopt \
 sc/source/ui/dbgui/consdlg \
 sc/source/ui/dbgui/csvcontrol \
diff --git a/sc/inc/datamapper.hxx b/sc/inc/datamapper.hxx
index 1d7e710051c0..9c59a7461b82 100644
--- a/sc/inc/datamapper.hxx
+++ b/sc/inc/datamapper.hxx
@@ -16,6 +16,8 @@
 
 #include 
 
+#include "orcusxml.hxx"
+
 class ScDocument;
 class ScDBData;
 
@@ -62,6 +64,8 @@ private:
  */
 OUString maID;
 
+ScOrcusImportXMLParam maParam;
+
 double mnUpdateFrequency;
 
 std::shared_ptr mpDataProvider;
@@ -83,10 +87,12 @@ public:
 void setID(const OUString& rID);
 void setURL(const OUString& rURL);
 void setProvider(const OUString& rProvider);
+void setXMLImportParam(const ScOrcusImportXMLParam& rParam);
 
 const OUString& getURL() const;
 const OUString& getProvider() const;
 const OUString& getID() const;
+const ScOrcusImportXMLParam& getXMLImportParam() const;
 double getUpdateFrequency() const;
 OUString getDBName() const;
 void setDBData(const OUString& rDBName);
diff --git a/sc/qa/unit/data/dataprovider/xml/test1.xml 
b/sc/qa/unit/data/dataprovider/xml/test1.xml
new file mode 100644
index ..03ba28288825
--- /dev/null
+++ b/sc/qa/unit/data/dataprovider/xml/test1.xml
@@ -0,0 +1,19 @@
+
+
+  
+1
+test1
+  
+  
+2
+test2
+  
+
+3
+test3
+  
+
+4
+test4
+  
+
\ No newline at end of file
diff --git a/sc/qa/unit/dataproviders_test.cxx 
b/sc/qa/unit/dataproviders_test.cxx
index 1960fa59eecf..aef3ec6abb05 100644
--- a/sc/qa/unit/dataproviders_test.cxx
+++ b/sc/qa/unit/dataproviders_test.cxx
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -29,11 +30,13 @@ public:
 void testCSVImport();
 void testDataLargerThanDB();
 void testHTMLImport();
+void testXMLImport();
 
 CPPUNIT_TEST_SUITE(ScDataProvidersTest);
 CPPUNIT_TEST(testCSVImport);
 CPPUNIT_TEST(testDataLargerThanDB);
 CPPUNIT_TEST(testHTMLImport);
+CPPUNIT_TEST(testXMLImport);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -137,6 +140,47 @@ void ScDataProvidersTest::testHTMLImport()
 }
 }
 
+void ScDataProvidersTest::testXMLImport()
+{
+ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10);
+bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData);
+CPPUNIT_ASSERT(bInserted);
+
+OUString aFileURL;
+ScOrcusImportXMLParam aParam;
+
+ScOrcusImportXMLParam::RangeLink aRangeLink;
+aRangeLink.maPos = ScAddress(0,0,0);
+aRangeLink.maFieldPaths.push_back("/bookstore/book/title");
+aRangeLink.maFieldPaths.push_back("/bookstore/book/author");
+aParam.maRangeLinks.push_back(aRangeLink);
+
+createFileURL("test1.", "xml", aFileURL);
+sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.xml", 
m_pDoc);
+aDataSource.setDBData("testDB");
+aDataSource.setXMLImportParam(aParam);
+
+
+m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource);
+auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources();
+CPPUNIT_ASSERT(!rDataSources.empty());
+
+rDataSources[0].refresh(m_pDoc, true);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(OUString("title"), m_pDoc->GetString(0, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("author"), m_pDoc->GetString(1, 0, 0));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 1, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("test1"), m_pDoc->GetString(1, 1, 0));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 2, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("test2"), m_pDoc->GetString(1, 2, 0));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0, 3, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("test3"), m_pDoc->GetString(1, 3, 0));
+CPPUNIT_ASSERT_EQUAL(4.0,