[Libreoffice-commits] core.git: sc/source

2022-02-01 Thread tushar (via logerrit)
 sc/source/ui/dataprovider/datatransformation.cxx |7 ++-
 sc/source/ui/miscdlgs/dataproviderdlg.cxx|   53 +--
 2 files changed, 46 insertions(+), 14 deletions(-)

New commits:
commit cdd0a141094c9ceb690a702bb0e3d64c368c1160
Author: tushar 
AuthorDate: Sun Jul 4 12:50:27 2021 +0530
Commit: Heiko Tietze 
CommitDate: Tue Feb 1 11:20:54 2022 +0100

Fix issues of Data Transformations.

* Corrected Delete column Transformation considering the case when
  multiple columns are provided as input.
* Corrected implementation of Split Column Transformation.
* Provided valid ranges for Sort Transformation and corrected
  implementation .

Change-Id: I4558602f69bf4aa7836e1e84931fabd346f83465
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118368
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 

diff --git a/sc/source/ui/dataprovider/datatransformation.cxx 
b/sc/source/ui/dataprovider/datatransformation.cxx
index 393521dfc417..62c82adb93d4 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -49,9 +49,11 @@ ColumnRemoveTransformation::~ColumnRemoveTransformation()
 
 void ColumnRemoveTransformation::Transform(ScDocument& rDoc) const
 {
+sal_Int32 nIncrementIndex = 0;
 for (auto& rCol : maColumns)
 {
-rDoc.DeleteCol(0, 0, rDoc.MaxRow(), 0, rCol, 1);
+rDoc.DeleteCol(0, 0, rDoc.MaxRow(), 0, rCol - nIncrementIndex, 1);
+nIncrementIndex++;
 }
 }
 
@@ -73,6 +75,9 @@ SplitColumnTransformation::SplitColumnTransformation(SCCOL 
nCol, sal_Unicode cSe
 
 void SplitColumnTransformation::Transform(ScDocument& rDoc) const
 {
+if (mnCol == -1)
+return;
+
 rDoc.InsertCol(0, 0, rDoc.MaxRow(), 0, mnCol + 1, 1);
 
 SCROW nEndRow = getLastRow(rDoc, mnCol);
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx 
b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 8cb2d9d33a0c..16dc088aed4c 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -39,8 +39,31 @@ public:
 void updateIndex(sal_uInt32 nIndex) { mnIndex = nIndex; }
 
 virtual std::shared_ptr getTransformation() = 0;
+
+static SCROW getLastRow(const ScDocument& rDoc);
+static SCCOL getLastCol(const ScDocument& rDoc);
 };
 
+SCROW ScDataTransformationBaseControl::getLastRow(const ScDocument& rDoc)
+{
+SCROW nEndRow = rDoc.MaxRow();
+return rDoc.GetLastDataRow(0, 0, 0, nEndRow);
+}
+
+SCCOL ScDataTransformationBaseControl::getLastCol(const ScDocument& rDoc)
+{
+for (SCCOL nCol = 1; nCol <= rDoc.MaxCol(); ++nCol)
+{
+CellType eType;
+rDoc.GetCellType(nCol, 0, 0, eType);
+if (eType == CELLTYPE_NONE)
+{
+return static_cast(nCol - 1 );
+}
+}
+return rDoc.MaxCol();
+}
+
 
ScDataTransformationBaseControl::ScDataTransformationBaseControl(weld::Container*
 pParent, const OUString& rUIFile, sal_uInt32 nIndex)
 : mxBuilder(Application::CreateBuilder(pParent, rUIFile))
 , mxGrid(mxBuilder->weld_container("grid"))
@@ -130,25 +153,25 @@ private:
 std::unique_ptr mxSeparator;
 std::unique_ptr mxNumColumns;
 std::unique_ptr mxDelete;
-SCCOL mnCol;
 std::function maDeleteTransformation;
+const ScDocument* mpDoc;
 
 public:
-ScSplitColumnTransformationControl(weld::Container* pParent, SCCOL nCol, 
sal_uInt32 nIndex, std::function aDeleteTransformation);
+ScSplitColumnTransformationControl(const ScDocument* pDoc, 
weld::Container* pParent, sal_uInt32 nIndex, std::function 
aDeleteTransformation);
 
 virtual std::shared_ptr getTransformation() 
override;
 DECL_LINK(DeleteHdl, weld::Button&, void);
 };
 
 ScSplitColumnTransformationControl::ScSplitColumnTransformationControl(
-weld::Container* pParent, SCCOL nCol, sal_uInt32 nIndex,
+const ScDocument* pDoc, weld::Container* pParent, sal_uInt32 nIndex,
 std::function aDeleteTransformation)
 : ScDataTransformationBaseControl(pParent, 
"modules/scalc/ui/splitcolumnentry.ui", nIndex)
 , mxSeparator(mxBuilder->weld_entry("ed_separator"))
 , mxNumColumns(mxBuilder->weld_entry("num_cols"))
 , mxDelete(mxBuilder->weld_button("ed_delete"))
-, mnCol(nCol)
 , maDeleteTransformation(std::move(aDeleteTransformation))
+, mpDoc(pDoc)
 {
 mxDelete->connect_clicked(LINK(this,ScSplitColumnTransformationControl, 
DeleteHdl));
 }
@@ -157,6 +180,11 @@ std::shared_ptr 
ScSplitColumnTransformationControl::getT
 {
 OUString aSeparator = mxSeparator->get_text();
 sal_Unicode cSeparator = aSeparator.isEmpty() ? ',' : aSeparator[0];
+OUString aColStr = mxNumColumns->get_text();
+SCCOL mnCol = -1;
+sal_Int32 nCol = aColStr.toInt32();
+if (nCol > 0 && nCol <= mpDoc->MaxCol())
+mnCol = nCol - 1;
 return std::make_shared(mnCol, cSeparator);
 }
 
@@ -258,11 +286,13 @@ std::shared_ptr 
ScSortTransformationCont

[Libreoffice-commits] core.git: 2 commits - sc/source sc/uiconfig sc/UIConfig_scalc.mk

2021-08-30 Thread tushar (via logerrit)
 sc/UIConfig_scalc.mk |1 
 sc/source/filter/ftools/ftools.cxx   |   14 ++--
 sc/source/filter/inc/ftools.hxx  |2 
 sc/source/filter/inc/lotimpop.hxx|2 
 sc/source/filter/lotus/lotform.cxx   |   17 ++--
 sc/source/ui/dataprovider/datatransformation.cxx |   47 +
 sc/source/ui/inc/dataproviderdlg.hxx |1 
 sc/source/ui/inc/datatransformation.hxx  |   15 
 sc/source/ui/miscdlgs/dataproviderdlg.cxx|   56 
 sc/uiconfig/scalc/ui/swaprowsentry.ui|   80 +++
 10 files changed, 219 insertions(+), 16 deletions(-)

New commits:
commit a0b836f73f249138a231f01c1d0289a9b67dc62d
Author: tushar 
AuthorDate: Tue Aug 17 01:30:00 2021 +0530
Commit: Heiko Tietze 
CommitDate: Mon Aug 30 09:29:21 2021 +0200

Add Swap Rows Transformation.

Entries of given rows are swapped after applying transformation.

Change-Id: Iac9da1b15781656b4127bf74f6a95e8cb82fa3d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120556
Reviewed-by: Markus Mohrhard 
Tested-by: Jenkins

diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 114be7d8f602..ce625df9f301 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -171,6 +171,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/datetimetransformationentry \
sc/uiconfig/scalc/ui/findreplaceentry \
sc/uiconfig/scalc/ui/deleterowentry \
+   sc/uiconfig/scalc/ui/swaprowsentry \
sc/uiconfig/scalc/ui/movecopysheet \
sc/uiconfig/scalc/ui/movingaveragedialog \
sc/uiconfig/scalc/ui/multipleoperationsdialog \
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx 
b/sc/source/ui/dataprovider/datatransformation.cxx
index e1013baa1e47..004c82a3c024 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -1261,6 +1261,53 @@ const OUString& DeleteRowTransformation::getFindString() 
const
 return maFindString;
 }
 
+SwapRowsTransformation::SwapRowsTransformation(SCROW mRow, SCROW nRow)
+: mxRow(mRow)
+, nxRow(nRow)
+{
+}
+
+void SwapRowsTransformation::Transform(ScDocument& rDoc) const
+{
+if (mxRow == -1 || nxRow == -1)
+return;
+
+for (SCCOL nCol = 0; nCol <= rDoc.MaxCol(); ++nCol)
+{
+CellType aType;
+rDoc.GetCellType(nCol, mxRow, 0, aType);
+if (aType == CELLTYPE_STRING)
+{
+OUString aStr = rDoc.GetString(nCol, mxRow, 0);
+OUString bStr = rDoc.GetString(nCol, nxRow, 0);
+rDoc.SetString(nCol, mxRow, 0, bStr);
+rDoc.SetString(nCol, nxRow, 0, aStr);
+}
+else if (aType == CELLTYPE_VALUE)
+{
+double aVal = rDoc.GetValue(nCol, mxRow, 0);
+double bVal = rDoc.GetValue(nCol, nxRow, 0);
+rDoc.SetValue(nCol, mxRow, 0, bVal);
+rDoc.SetValue(nCol, nxRow, 0, aVal);
+}
+}
+}
+
+TransformationType SwapRowsTransformation::getTransformationType() const
+{
+return TransformationType::SWAPROWS_TRANSFORMATION;
+}
+
+SCROW SwapRowsTransformation::getFirstRow() const
+{
+return mxRow;
+}
+
+SCROW SwapRowsTransformation::getSecondRow() const
+{
+return nxRow;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx 
b/sc/source/ui/inc/dataproviderdlg.hxx
index ec054d283149..127b6361abbd 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -87,6 +87,7 @@ public:
 void dateTimeTransformation();
 void findReplaceTransformation();
 void deleteRowTransformation();
+void swapRowsTransformation();
 
 void updateApplyBtn(bool bValidConfig);
 void isValid();
diff --git a/sc/source/ui/inc/datatransformation.hxx 
b/sc/source/ui/inc/datatransformation.hxx
index e5bf96690da0..d575be4c4785 100644
--- a/sc/source/ui/inc/datatransformation.hxx
+++ b/sc/source/ui/inc/datatransformation.hxx
@@ -32,7 +32,8 @@ enum class TransformationType
 REMOVE_NULL_TRANSFORMATION,
 DATETIME_TRANSFORMATION,
 FINDREPLACE_TRANSFORMATION,
-DELETEROW_TRANSFORMATION
+DELETEROW_TRANSFORMATION,
+SWAPROWS_TRANSFORMATION
 };
 
 enum class TEXT_TRANSFORM_TYPE { TO_LOWER, TO_UPPER, CAPITALIZE, TRIM };
@@ -211,6 +212,18 @@ class DeleteRowTransformation : public DataTransformation
 const OUString & getFindString() const;
 };
 
+class SC_DLLPUBLIC SwapRowsTransformation : public DataTransformation
+{
+SCROW mxRow, nxRow;
+
+public:
+SwapRowsTransformation(SCROW mRow, SCROW nRow);
+virtual void Transform(ScDocument& rDoc) const override;
+virtual TransformationType getTransformationType() const override;
+SCROW getFirstRow() const;
+SCROW getSecondRow() const;
+};
+
 }
 
 /* vim:set sh

[Libreoffice-commits] core.git: sc/source sc/uiconfig sc/UIConfig_scalc.mk

2021-08-16 Thread tushar (via logerrit)
 sc/UIConfig_scalc.mk |1 
 sc/source/ui/dataprovider/datatransformation.cxx |   44 
 sc/source/ui/inc/dataproviderdlg.hxx |1 
 sc/source/ui/inc/datatransformation.hxx  |   16 
 sc/source/ui/miscdlgs/dataproviderdlg.cxx|   53 ++-
 sc/uiconfig/scalc/ui/deleterowentry.ui   |   80 +++
 6 files changed, 193 insertions(+), 2 deletions(-)

New commits:
commit 77814f90aef50902383cba3aa4e37c68b6ca2b12
Author: tushar 
AuthorDate: Wed Aug 11 01:36:34 2021 +0530
Commit: Heiko Tietze 
CommitDate: Tue Aug 17 07:56:03 2021 +0200

Add Delete Row Transformation.

Rows having specific value in a column will be deleted.

Change-Id: I0b39e1127215c59062db11351a656e75d71a04aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120296
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard 
Reviewed-by: Heiko Tietze 

diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index c7ddfa38f88f..114be7d8f602 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -170,6 +170,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/replacenulltransformationentry \
sc/uiconfig/scalc/ui/datetimetransformationentry \
sc/uiconfig/scalc/ui/findreplaceentry \
+   sc/uiconfig/scalc/ui/deleterowentry \
sc/uiconfig/scalc/ui/movecopysheet \
sc/uiconfig/scalc/ui/movingaveragedialog \
sc/uiconfig/scalc/ui/multipleoperationsdialog \
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx 
b/sc/source/ui/dataprovider/datatransformation.cxx
index 22861b8e4ccd..e1013baa1e47 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -1217,6 +1217,50 @@ const OUString& 
FindReplaceTransformation::getReplaceString() const
 return maReplaceString;
 }
 
+DeleteRowTransformation::DeleteRowTransformation(SCCOL nCol, const OUString& 
aFindString)
+: mnCol(nCol)
+, maFindString(aFindString)
+{
+}
+
+void DeleteRowTransformation::Transform(ScDocument& rDoc) const
+{
+sal_Int32 nIncrementIndex = 0;
+if (mnCol == -1)
+return;
+
+SCROW nEndRow = getLastRow(rDoc, mnCol);
+for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
+{
+CellType eType;
+rDoc.GetCellType(mnCol, nRow - nIncrementIndex, 0, eType);
+if (eType != CELLTYPE_NONE)
+{
+OUString aStr = rDoc.GetString(mnCol, nRow - nIncrementIndex, 0);
+if (aStr == maFindString)
+{
+rDoc.DeleteRow(0, 0, rDoc.MaxCol(), 0, nRow - nIncrementIndex, 
1);
+nIncrementIndex++;
+}
+}
+}
+}
+
+TransformationType DeleteRowTransformation::getTransformationType() const
+{
+return TransformationType::DELETEROW_TRANSFORMATION;
+}
+
+SCCOL DeleteRowTransformation::getColumn() const
+{
+return mnCol;
+}
+
+const OUString& DeleteRowTransformation::getFindString() const
+{
+return maFindString;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx 
b/sc/source/ui/inc/dataproviderdlg.hxx
index 5f275eace855..ec054d283149 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -86,6 +86,7 @@ public:
 void replaceNullTransformation();
 void dateTimeTransformation();
 void findReplaceTransformation();
+void deleteRowTransformation();
 
 void updateApplyBtn(bool bValidConfig);
 void isValid();
diff --git a/sc/source/ui/inc/datatransformation.hxx 
b/sc/source/ui/inc/datatransformation.hxx
index 5c0741553f64..c82422db5a38 100644
--- a/sc/source/ui/inc/datatransformation.hxx
+++ b/sc/source/ui/inc/datatransformation.hxx
@@ -31,7 +31,8 @@ enum class TransformationType
 NUMBER_TRANSFORMATION,
 REMOVE_NULL_TRANSFORMATION,
 DATETIME_TRANSFORMATION,
-FINDREPLACE_TRANSFORMATION
+FINDREPLACE_TRANSFORMATION,
+DELETEROW_TRANSFORMATION
 };
 
 enum class TEXT_TRANSFORM_TYPE { TO_LOWER, TO_UPPER, CAPITALIZE, TRIM };
@@ -197,6 +198,19 @@ class SC_DLLPUBLIC FindReplaceTransformation : public 
DataTransformation
 const OUString & getReplaceString() const;
 };
 
+class SC_DLLPUBLIC DeleteRowTransformation : public DataTransformation
+{
+SCCOL mnCol;
+OUString maFindString;
+
+public:
+DeleteRowTransformation(SCCOL nCol, const OUString& aFindString);
+virtual void Transform(ScDocument& rDoc) const override;
+virtual TransformationType getTransformationType() const override;
+SCCOL getColumn() const;
+const OUString & getFindString() const;
+};
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx 
b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 8ad7dd2177aa..8c11a831ebb3 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+

[Libreoffice-commits] core.git: sc/source sc/uiconfig sc/UIConfig_scalc.mk

2021-07-07 Thread tushar (via logerrit)
 sc/UIConfig_scalc.mk |1 
 sc/source/ui/dataprovider/datatransformation.cxx |   46 +++
 sc/source/ui/inc/dataproviderdlg.hxx |2 
 sc/source/ui/inc/datatransformation.hxx  |   18 
 sc/source/ui/miscdlgs/dataproviderdlg.cxx|   55 +
 sc/uiconfig/scalc/ui/findreplaceentry.ui |   94 +++
 6 files changed, 214 insertions(+), 2 deletions(-)

New commits:
commit 1f88af544ffe17c58806a6b947803e1a2b3db378
Author: tushar 
AuthorDate: Sun Jul 4 01:08:21 2021 +0530
Commit: Markus Mohrhard 
CommitDate: Wed Jul 7 10:07:33 2021 +0200

Added Find and Replace Transformation .

Change-Id: I6ba0cd27bfd8b90923fb35d019fe0223bc9f07f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118384
Reviewed-by: Heiko Tietze 
Reviewed-by: Markus Mohrhard 
Tested-by: Jenkins

diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 705aee221cbf..e19172e49bd3 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -169,6 +169,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/numbertransformationentry \
sc/uiconfig/scalc/ui/replacenulltransformationentry \
sc/uiconfig/scalc/ui/datetimetransformationentry \
+   sc/uiconfig/scalc/ui/findreplaceentry \
sc/uiconfig/scalc/ui/movecopysheet \
sc/uiconfig/scalc/ui/movingaveragedialog \
sc/uiconfig/scalc/ui/multipleoperationsdialog \
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx 
b/sc/source/ui/dataprovider/datatransformation.cxx
index dfdc72375cb1..7e9d51fdc004 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -1170,6 +1170,52 @@ const std::set& 
DateTimeTransformation::getColumn() const
 return mnCol;
 }
 
+FindReplaceTransformation::FindReplaceTransformation(SCCOL nCol, const 
OUString& aFindString, const OUString& aReplaceString)
+: mnCol(nCol)
+, maFindString(aFindString)
+, maReplaceString(aReplaceString)
+{
+}
+
+void FindReplaceTransformation::Transform(ScDocument& rDoc) const
+{
+if (mnCol == -1)
+return;
+
+SCROW nEndRow = getLastRow(rDoc, mnCol);
+for (SCROW nRow = 0; nRow <= nEndRow; ++nRow)
+{
+CellType eType;
+rDoc.GetCellType(mnCol, nRow, 0, eType);
+if (eType != CELLTYPE_NONE)
+{
+OUString aStr = rDoc.GetString(mnCol, nRow, 0);
+if (aStr == maFindString)
+rDoc.SetString(mnCol, nRow, 0, maReplaceString);
+}
+}
+}
+
+TransformationType FindReplaceTransformation::getTransformationType() const
+{
+return TransformationType::FINDREPLACE_TRANSFORMATION;
+}
+
+SCCOL FindReplaceTransformation::getColumn() const
+{
+return mnCol;
+}
+
+const OUString& FindReplaceTransformation::getFindString() const
+{
+return maFindString;
+}
+
+const OUString& FindReplaceTransformation::getReplaceString() const
+{
+return maReplaceString;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx 
b/sc/source/ui/inc/dataproviderdlg.hxx
index 582df71e5c22..5f275eace855 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -85,6 +85,8 @@ public:
 void deletefromList(sal_uInt32 nIndex);
 void replaceNullTransformation();
 void dateTimeTransformation();
+void findReplaceTransformation();
+
 void updateApplyBtn(bool bValidConfig);
 void isValid();
 
diff --git a/sc/source/ui/inc/datatransformation.hxx 
b/sc/source/ui/inc/datatransformation.hxx
index d5b19912e328..5c0741553f64 100644
--- a/sc/source/ui/inc/datatransformation.hxx
+++ b/sc/source/ui/inc/datatransformation.hxx
@@ -30,7 +30,8 @@ enum class TransformationType
 AGGREGATE_FUNCTION,
 NUMBER_TRANSFORMATION,
 REMOVE_NULL_TRANSFORMATION,
-DATETIME_TRANSFORMATION
+DATETIME_TRANSFORMATION,
+FINDREPLACE_TRANSFORMATION
 };
 
 enum class TEXT_TRANSFORM_TYPE { TO_LOWER, TO_UPPER, CAPITALIZE, TRIM };
@@ -181,6 +182,21 @@ class SC_DLLPUBLIC DateTimeTransformation : public 
DataTransformation
 const std::set& getColumn() const;
 };
 
+class SC_DLLPUBLIC FindReplaceTransformation : public DataTransformation
+{
+SCCOL mnCol;
+OUString maFindString;
+OUString maReplaceString;
+
+public:
+FindReplaceTransformation(SCCOL nCol, const OUString& aFindString, 
const OUString& aReplaceString);
+virtual void Transform(ScDocument& rDoc) const override;
+virtual TransformationType getTransformationType() const override;
+SCCOL getColumn() const;
+const OUString & getFindString() const;
+const OUString & getReplaceString() const;
+};
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx 
b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 757ea7

[Libreoffice-commits] core.git: sc/source sc/uiconfig sc/UIConfig_scalc.mk solenv/sanitizers

2021-07-03 Thread tushar (via logerrit)
 sc/UIConfig_scalc.mk   |1 
 sc/source/ui/inc/dataproviderdlg.hxx   |   39 +
 sc/source/ui/miscdlgs/dataproviderdlg.cxx  |  310 +---
 sc/source/ui/miscdlgs/datatableview.cxx|2 
 sc/uiconfig/scalc/ui/aggregatefunctionentry.ui |  184 ++-
 sc/uiconfig/scalc/ui/dataproviderdlg.ui|  412 -
 sc/uiconfig/scalc/ui/dataproviderentry.ui  |  108 
 sc/uiconfig/scalc/ui/datetimetransformationentry.ui|  212 +++-
 sc/uiconfig/scalc/ui/deletecolumnentry.ui  |  123 +
 sc/uiconfig/scalc/ui/mergecolumnentry.ui   |  159 ++
 sc/uiconfig/scalc/ui/numbertransformationentry.ui  |  202 +++-
 sc/uiconfig/scalc/ui/replacenulltransformationentry.ui |  171 ++-
 sc/uiconfig/scalc/ui/sorttransformationentry.ui|  144 ++---
 sc/uiconfig/scalc/ui/splitcolumnentry.ui   |  160 ++
 sc/uiconfig/scalc/ui/texttransformationentry.ui|  165 ++
 solenv/sanitizers/ui/modules/scalc.suppr   |   23 
 16 files changed, 1041 insertions(+), 1374 deletions(-)

New commits:
commit 7b4169c9d54c6e90e860141a6ced51464cf102d8
Author: tushar 
AuthorDate: Wed Jun 9 01:56:48 2021 +0530
Commit: Markus Mohrhard 
CommitDate: Sat Jul 3 20:51:04 2021 +0200

Implement Interface for Data Providers.

Change-Id: I83ec43511d4fd9a91d7ec34e2281f80b19b4d562
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116870
Tested-by: Heiko Tietze 
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 
Reviewed-by: Markus Mohrhard 

diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 3d11cfdbf18c..705aee221cbf 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -113,7 +113,6 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/dataformfragment \
sc/uiconfig/scalc/ui/datastreams \
sc/uiconfig/scalc/ui/dataproviderdlg \
-   sc/uiconfig/scalc/ui/dataproviderentry \
sc/uiconfig/scalc/ui/definedatabaserangedialog \
sc/uiconfig/scalc/ui/definename \
sc/uiconfig/scalc/ui/deletecells \
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx 
b/sc/source/ui/inc/dataproviderdlg.hxx
index d056fa386006..582df71e5c22 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -9,6 +9,8 @@
 
 #pragma once
 
+#include 
+
 #include 
 
 #include 
@@ -18,7 +20,6 @@
 #include 
 
 class ScDocument;
-class ScDataProviderBaseControl;
 class ScDataTransformationBaseControl;
 class ScDBData;
 
@@ -26,15 +27,25 @@ class ScDataProviderDlg : public 
weld::GenericDialogController
 {
 private:
 std::shared_ptr mxDoc;
-std::unique_ptr mxStartMenu;
-std::unique_ptr mxColumnMenu;
 std::unique_ptr mxBox;
 css::uno::Reference m_xTableParent;
 VclPtr mxTable;
-std::unique_ptr mxScroll;
 std::unique_ptr mxList;
-std::unique_ptr mxDataProviderCtrl;
 std::unique_ptr mxDBRanges;
+std::unique_ptr mxOKBtn;
+std::unique_ptr mxCancelBtn;
+std::unique_ptr mxAddTransformationBtn;
+std::unique_ptr mxScroll;
+std::unique_ptr mxTransformationList;
+std::unique_ptr mxTransformationBox;
+std::unique_ptr mxProviderList;
+std::unique_ptr mxEditURL;
+std::unique_ptr mxEditID;
+std::unique_ptr mxApplyBtn;
+std::unique_ptr mxBrowseBtn;
+
+OUString msApplyTooltip;
+OUString msAddTransformationToolTip;
 
 std::vector> maControls;
 
@@ -43,12 +54,18 @@ private:
 sal_uInt32 mnIndex;
 ScDBData* pDBData;
 
-void InitMenu();
-
 DECL_LINK(StartMenuHdl, const OString&, void);
-DECL_LINK(ColumnMenuHdl, const OString&, void);
-DECL_LINK(ImportHdl, ScDataProviderBaseControl*, void);
+DECL_LINK(ColumnMenuHdl, const weld::ComboBox&, void);
 DECL_LINK(ScrollToEnd, Timer*, void);
+DECL_LINK(ApplyQuitHdl, weld::Button&, void);
+DECL_LINK(CancelQuitHdl, weld::Button&, void);
+DECL_LINK(TransformationListHdl, weld::Button&, void);
+DECL_LINK(ProviderSelectHdl, weld::ComboBox&, void);
+DECL_LINK(TransformationSelectHdl, weld::ComboBox&, void);
+DECL_LINK(IDEditHdl, weld::Entry&, void);
+DECL_LINK(URLEditHdl, weld::Entry&, void);
+DECL_LINK(ApplyBtnHdl, weld::Button&, void);
+DECL_LINK(BrowseBtnHdl, weld::Button&, void);
 
 public:
 ScDataProviderDlg(weld::Window* pWindow, std::shared_ptr pDoc,
@@ -68,6 +85,10 @@ public:
 void deletefromList(sal_uInt32 nIndex);
 void replaceNullTransformation();
 void dateTimeTransformation();
+void updateApplyBtn(bool bValidConfig);
+void isValid();
+
+sc::ExternalDataSource getDataSource(ScDocument* pDoc);
 
 void import(ScDocument& rDoc, bool bInternal = false);
 };
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx 
b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index d41c3842488c..757ea7634778 100644
--- a/sc/source/ui/miscdl

[Libreoffice-commits] core.git: sc/source

2021-05-27 Thread tushar (via logerrit)
 sc/source/ui/miscdlgs/datatableview.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 0643e5a3accc01e0ee7a2359ec283ced8d0cf0ab
Author: tushar 
AuthorDate: Sat May 15 12:04:13 2021 +0530
Commit: Mike Kaganski 
CommitDate: Thu May 27 15:47:39 2021 +0200

tdf#135332 Return MAXROW/MAXCOL for rows/columns out of range.

*Also change the number of rows to MAXROW in Row Header Control.

Change-Id: Ie34361442a0944f62abbc9bb273a9efe72773c57
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115642
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/source/ui/miscdlgs/datatableview.cxx 
b/sc/source/ui/miscdlgs/datatableview.cxx
index 2541688a6677..3c88ac65b290 100644
--- a/sc/source/ui/miscdlgs/datatableview.cxx
+++ b/sc/source/ui/miscdlgs/datatableview.cxx
@@ -90,7 +90,7 @@ void ScDataTableColView::HideEntries(SCCOLROW nPos, SCCOLROW 
nEndPos)
 
 
 ScDataTableRowView::ScDataTableRowView(vcl::Window* pParent, SelectionEngine* 
pSelectionEngine):
-ScHeaderControl(pParent, pSelectionEngine, 1024, true, nullptr),
+ScHeaderControl(pParent, pSelectionEngine, 1048576, true, nullptr),
 mpDoc(nullptr),
 mnRow(0)
 {
@@ -218,7 +218,7 @@ SCCOL findColFromPos(sal_uInt16 nPixelPos, const 
ScDocument* pDoc, SCCOL nStartC
 }
 
 SAL_WARN("sc", "Could not find the corresponding column");
-return -1;
+return MAXCOL;
 }
 
 SCROW findRowFromPos(sal_uInt16 nPixelPos, const ScDocument* pDoc, SCROW 
nStartRow = 0)
@@ -238,7 +238,7 @@ SCROW findRowFromPos(sal_uInt16 nPixelPos, const 
ScDocument* pDoc, SCROW nStartR
 }
 
 SAL_WARN("sc", "Could not find the corresponding row");
-return -1;
+return MAXROW;
 }
 
 }
@@ -321,13 +321,13 @@ IMPL_LINK(ScDataTableView, ScrollHdl, ScrollBar*, 
pScrollBar, void)
 if (pScrollBar == mpVScroll.get())
 {
 mnFirstVisibleRow = pScrollBar->GetThumbPos();
-pScrollBar->SetRangeMax(mnFirstVisibleRow + 100);
+pScrollBar->SetRangeMax(std::min( 
MAXROW,static_cast(mnFirstVisibleRow + 100 )));
 mpRowView->SetPos(mnFirstVisibleRow);
 }
 else
 {
 mnFirstVisibleCol = pScrollBar->GetThumbPos();
-pScrollBar->SetRangeMax(mnFirstVisibleCol + 50);
+pScrollBar->SetRangeMax(std::min( 
MAXCOL,static_cast(mnFirstVisibleCol + 50 )));
 mpColView->SetPos(mnFirstVisibleCol);
 }
 Invalidate();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2021-05-01 Thread tushar (via logerrit)
 basic/qa/vba_tests/strconv.vb|   28 +++-
 basic/source/runtime/methods.cxx |   14 +++---
 2 files changed, 30 insertions(+), 12 deletions(-)

New commits:
commit 6fecdeac5d81a60a479195a62cdc174b919f763b
Author: tushar 
AuthorDate: Mon Mar 15 22:17:46 2021 +0530
Commit: Mike Kaganski 
CommitDate: Sat May 1 13:12:22 2021 +0200

tdf#124184 Fixing StrConv VBA Function

* vbUnicode/vbFromUnicode considers optional third LCID argument.
* LCID is also used for other conversions.
* The encoding is decided based on the language defined in LCID,
  or on program locale when LCID is omitted, using MS default
  ACP mapping for languages.
* Unit testis for vbWide / vbNarrow are changed and enabled.
* Unit tests for vbKatakana / vbHiragana are changed and enabled.
* Unit test for vbFromUnicode / vbUnicode is changed to rely on
  en-US locale used in testing, and is enabled.

Change-Id: Iabd4153db311cd02c3f3e7247f9fc71ad9f5f682
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112539
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/vba_tests/strconv.vb b/basic/qa/vba_tests/strconv.vb
index 9bb6f9649a1d..b0295df428b2 100644
--- a/basic/qa/vba_tests/strconv.vb
+++ b/basic/qa/vba_tests/strconv.vb
@@ -23,21 +23,31 @@ Sub verify_testStrConv()
 TestUtil.AssertEqual(StrConv("abc EFG hij", vbProperCase), "Abc Efg Hij", 
"StrConv(""abc EFG hij"", vbProperCase)")
 
 ' Converts narrow (single-byte) characters in string to wide
-'TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥­¥å©`", vbWide), 
"£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", "StrConv(""ABCDEVB¥ì¥¹¥­¥å©`"", vbWide)")
+TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥­¥å©", vbWide), 
"ABCDEVB¥ì¥¹¥­¥å©", "StrConv(""ABCDEVB¥ì¥¹¥­¥å©"", vbWide)")
 
 ' Converts wide (double-byte) characters in string to narrow (single-byte) 
characters
-'TestUtil.AssertEqual(StrConv("£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", vbNarrow), 
"ABCDEVB¥ì¥¹¥­¥å©`", "StrConv(""£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`"", vbNarrow)")
+TestUtil.AssertEqual(StrConv("ABCD@$%23'?EG", vbNarrow), "ABCD@$%23'?EG", 
"StrConv(""ABCD@$%23'?EG"", vbNarrow)")
 
 ' Converts Hiragana characters in string to Katakana characters
-'TestUtil.AssertEqual(StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana), "¥Ï¥Ê¥Á¥ã¥ó", 
"StrConv(""¤Ï¤Ê¤Á¤ã¤ó"", vbKatakana)")
+TestUtil.AssertEqual(StrConv("かたかな", vbKatakana), "カタカナ", 
"StrConv(""かたかな"", vbKatakana)")
 
 ' Converts Katakana characters in string to Hiragana characters
-'TestUtil.AssertEqual(StrConv("¥Ï¥Ê¥Á¥ã¥ó", vbHiragana), "¤Ï¤Ê¤Á¤ã¤ó", 
"StrConv(""¥Ï¥Ê¥Á¥ã¥ó"", vbHiragana)")
-
-'Dim x() As Byte
-'x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
-'TestUtil.AssertEqual(UBound(x), 8, "UBound(x)")
-'TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, 
vbUnicode)")
+TestUtil.AssertEqual(StrConv("カタカナ", vbHiragana), "かたかな", 
"StrConv(""カタカナ"", vbHiragana)")
+
+' Assumes CP-1252 encoding associated with en-US locale used in unit tests.
+Dim x() As Byte
+x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
+TestUtil.AssertEqual(UBound(x), 8, "UBound(x)")
+TestUtil.AssertEqual(x(0), 201, "x(0)")
+TestUtil.AssertEqual(x(1), 207, "x(1)")
+TestUtil.AssertEqual(x(2), 186, "x(2)")
+TestUtil.AssertEqual(x(3), 163, "x(3)")
+TestUtil.AssertEqual(x(4), 202, "x(4)")
+TestUtil.AssertEqual(x(5), 208, "x(5)")
+TestUtil.AssertEqual(x(6), 65, "x(6)")
+TestUtil.AssertEqual(x(7), 66, "x(7)")
+TestUtil.AssertEqual(x(8), 67, "x(8)")
+TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, 
vbUnicode)")
 
 Exit Sub
 errorHandler:
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 910b95f084fa..843c85b4860f 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4106,6 +4107,14 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
 
 OUString aOldStr = rPar.Get(1)->GetOUString();
 sal_Int32 nConversion = rPar.Get(2)->GetLong();
+LanguageType nLanguage = LANGUAGE_SYSTEM;
+if (nArgCount == 3)
+{
+sal_Int32 lcid = rPar.Get(3)->GetLong();
+nLanguage = LanguageType(lcid);
+}
+OUString sLanguage = LanguageTag(nLanguage).getLanguage();
+rtl_TextEncoding encodingVal = 
utl_getWinTextEncodingFromLangStr(sLanguage);
 
 sal_Int32 nOldLen = aOldStr.getLength();
 if( nOldLen == 0 )
@@ -4151,7 +4160,6 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
 uno::Reference< uno::XComponentContext > xContext = 
getProcessComponentContext();
 ::utl::TransliterationWrapper aTransliterationWrapper( xContext, nType 
);
 uno::Sequence aOffsets;
-LanguageType nLanguage = LANGUAGE_SYSTEM;
 aTransliterationWrapper.loadModuleIfNeeded( nLanguage );
 aNewStr = aTransliterationW

[Libreoffice-commits] core.git: sc/source

2021-04-28 Thread tushar (via logerrit)
 sc/source/ui/view/hdrcont.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6e66b30d9287b418bed35400c77b257b97cf26ec
Author: tushar 
AuthorDate: Mon Apr 26 14:27:02 2021 +0530
Commit: Markus Mohrhard 
CommitDate: Wed Apr 28 20:44:54 2021 +0200

tdf#141904 Blue row number for autofilter only when pTab is not NULL.

Change-Id: Ibdf1efbff34bc58912a5a776d47ccfd784d3111e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114647
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard 

diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index 34ebc328eb82..e322394d2025 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -394,7 +394,7 @@ void ScHeaderControl::Paint( vcl::RenderContext& 
/*rRenderContext*/, const tools
 
 // tdf#89841 Use blue row numbers when Autofilter selected
 std::vector aSpans;
-if (bVertical)
+if (bVertical && pTabView)
 {
 SCTAB nTab = pTabView->GetViewData().GetTabNo();
 ScDocument& rDoc = pTabView->GetViewData().GetDocument();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sc/qa scripting/source

2021-01-22 Thread tushar (via logerrit)
 sc/qa/extras/macros-test.cxx |   33 +++
 sc/qa/extras/testdocuments/tdf133889.ods |binary
 scripting/source/basprov/basscript.cxx   |   15 ++
 3 files changed, 48 insertions(+)

New commits:
commit 61d2014254a6bf1da68e2f13d3de2c099fcb8883
Author: tushar 
AuthorDate: Fri Jan 22 02:33:21 2021 +0530
Commit: Mike Kaganski 
CommitDate: Fri Jan 22 19:05:49 2021 +0100

tdf#133889 Upcasting the type of actual parameter.

Type of actual parameter is made same as formal parameter.This is done to 
undo the conversions made in sbxToUnoValueImpl.

Change-Id: I8c7a880503d927eb43ad38eac4bf01451442834b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109773
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 00c8474a38b6..7efa20e5f60f 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -53,6 +53,7 @@ public:
 void testTdf71271();
 void testTdf43003();
 void testTdf133887();
+void testTdf133889();
 
 CPPUNIT_TEST_SUITE(ScMacrosTest);
 CPPUNIT_TEST(testStarBasic);
@@ -72,6 +73,7 @@ public:
 CPPUNIT_TEST(testTdf71271);
 CPPUNIT_TEST(testTdf43003);
 CPPUNIT_TEST(testTdf133887);
+CPPUNIT_TEST(testTdf133889);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -897,6 +899,37 @@ void ScMacrosTest::testTdf133887()
 xCloseable->close(true);
 }
 
+void ScMacrosTest::testTdf133889()
+{
+OUString aFileName;
+createFileURL(u"tdf133889.ods", aFileName);
+auto xComponent = loadFromDesktop(aFileName, 
"com.sun.star.sheet.SpreadsheetDocument");
+
+CPPUNIT_ASSERT_MESSAGE("Failed to load the doc", xComponent.is());
+
+css::uno::Any aRet;
+css::uno::Sequence aOutParamIndex;
+css::uno::Sequence aOutParam;
+css::uno::Sequence aParams{ css::uno::Any(sal_Int32(0)) };
+
+SfxObjectShell::CallXScript(
+xComponent,
+
"vnd.sun.Star.script:Standard.Module1.TestInvoke?language=Basic&location=document",
 aParams,
+aRet, aOutParamIndex, aOutParam);
+
+sal_Int32 aReturnValue;
+aOutParam[0] >>= aReturnValue;
+
+// Without the fix in place, this test would have failed with
+// - Expected: 10
+// - Actual  : 0
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aReturnValue);
+
+css::uno::Reference xCloseable(xComponent, 
css::uno::UNO_QUERY_THROW);
+xCloseable->close(true);
+}
+
 ScMacrosTest::ScMacrosTest()
   : UnoApiTest("/sc/qa/extras/testdocuments")
 {
diff --git a/sc/qa/extras/testdocuments/tdf133889.ods 
b/sc/qa/extras/testdocuments/tdf133889.ods
new file mode 100644
index ..db87da6129a7
Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf133889.ods differ
diff --git a/scripting/source/basprov/basscript.cxx 
b/scripting/source/basprov/basscript.cxx
index 16ffeb9dc9ee..4d6f2477ed92 100644
--- a/scripting/source/basprov/basscript.cxx
+++ b/scripting/source/basprov/basscript.cxx
@@ -210,6 +210,21 @@ namespace basprov
 if (auto* p = 
pInfo->GetParam(static_cast(i) + 1))
 {
 SbxDataType t = static_cast(p->eType 
& 0x0FFF);
+// tdf#133889 Revert the downcasting performed in 
sbxToUnoValueImpl
+// to allow passing by reference.
+SbxDataType a = xSbxVar->GetType();
+if (t == SbxSINGLE && (a == SbxINTEGER || a == 
SbxLONG))
+{
+sal_Int32 val = xSbxVar->GetLong();
+if (val >= -16777216 && val <= 16777215)
+xSbxVar->SetType(t);
+}
+else if (t == SbxDOUBLE && (a == SbxINTEGER || a 
== SbxLONG))
+xSbxVar->SetType(t);
+else if (t == SbxLONG && a == SbxINTEGER)
+xSbxVar->SetType(t);
+else if (t == SbxULONG && a == SbxUSHORT)
+xSbxVar->SetType(t);
 // Enable passing by ref
 if (t != SbxVARIANT)
 xSbxVar->SetFlag(SbxFlagBits::Fixed);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sc/qa scripting/source

2021-01-18 Thread tushar (via logerrit)
 sc/qa/extras/macros-test.cxx |   33 +++
 sc/qa/extras/testdocuments/tdf133887.ods |binary
 scripting/source/basprov/basscript.cxx   |   15 ++
 3 files changed, 44 insertions(+), 4 deletions(-)

New commits:
commit 3b3591d3c127c306f4d5f6bbb34118b03c3124c0
Author: tushar 
AuthorDate: Sun Jan 10 21:22:11 2021 +0530
Commit: Mike Kaganski 
CommitDate: Mon Jan 18 12:44:05 2021 +0100

tdf#133887 Set flag of variable when formal parameter is not expecting 
variant.

If there is no param info for formal paramter then type of formal parameter 
and actual parameter will be same
and there is no need to set the flag in that case.

Change-Id: I12af64f82fc5b2d6d7fb920bde1cb96f8c7bd51b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109070
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index b5a48353b4e4..00c8474a38b6 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -52,6 +52,7 @@ public:
 void testTdf128218();
 void testTdf71271();
 void testTdf43003();
+void testTdf133887();
 
 CPPUNIT_TEST_SUITE(ScMacrosTest);
 CPPUNIT_TEST(testStarBasic);
@@ -70,6 +71,7 @@ public:
 CPPUNIT_TEST(testTdf128218);
 CPPUNIT_TEST(testTdf71271);
 CPPUNIT_TEST(testTdf43003);
+CPPUNIT_TEST(testTdf133887);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -864,6 +866,37 @@ void ScMacrosTest::testTdf43003()
 xCloseable->close(true);
 }
 
+void ScMacrosTest::testTdf133887()
+{
+OUString aFileName;
+createFileURL(u"tdf133887.ods", aFileName);
+auto xComponent = loadFromDesktop(aFileName, 
"com.sun.star.sheet.SpreadsheetDocument");
+
+CPPUNIT_ASSERT_MESSAGE("Failed to load the doc", xComponent.is());
+
+css::uno::Any aRet;
+css::uno::Sequence aOutParamIndex;
+css::uno::Sequence aOutParam;
+css::uno::Sequence aParams{ css::uno::Any(sal_Int16(0)) };
+
+SfxObjectShell::CallXScript(
+xComponent,
+
"vnd.sun.Star.script:Standard.Module1.TestInvoke?language=Basic&location=document",
 aParams,
+aRet, aOutParamIndex, aOutParam);
+
+double aReturnValue;
+aOutParam[0] >>= aReturnValue;
+
+// Without the fix in place, this test would have failed with
+// - Expected: 6.75
+// - Actual  : 7
+
+CPPUNIT_ASSERT_EQUAL(6.75, aReturnValue);
+
+css::uno::Reference xCloseable(xComponent, 
css::uno::UNO_QUERY_THROW);
+xCloseable->close(true);
+}
+
 ScMacrosTest::ScMacrosTest()
   : UnoApiTest("/sc/qa/extras/testdocuments")
 {
diff --git a/sc/qa/extras/testdocuments/tdf133887.ods 
b/sc/qa/extras/testdocuments/tdf133887.ods
new file mode 100644
index ..92d135f5834a
Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf133887.ods differ
diff --git a/scripting/source/basprov/basscript.cxx 
b/scripting/source/basprov/basscript.cxx
index 216e2fa99bd6..16ffeb9dc9ee 100644
--- a/scripting/source/basprov/basscript.cxx
+++ b/scripting/source/basprov/basscript.cxx
@@ -205,10 +205,17 @@ namespace basprov
 unoToSbxValue( xSbxVar.get(), pParams[i] );
 xSbxParams->Put32( xSbxVar.get(), static_cast< sal_uInt32 
>( i ) + 1 );
 
-// Enable passing by ref
-if ( xSbxVar->GetType() != SbxVARIANT )
-xSbxVar->SetFlag( SbxFlagBits::Fixed );
- }
+if (pInfo)
+{
+if (auto* p = 
pInfo->GetParam(static_cast(i) + 1))
+{
+SbxDataType t = static_cast(p->eType 
& 0x0FFF);
+// Enable passing by ref
+if (t != SbxVARIANT)
+xSbxVar->SetFlag(SbxFlagBits::Fixed);
+}
+}
+}
 }
 if ( xSbxParams.is() )
 m_xMethod->SetParameters( xSbxParams.get() );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits