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

2018-07-01 Thread Vikas
 sc/source/filter/xml/XMLExportDatabaseRanges.cxx |  140 +++
 sc/source/filter/xml/XMLExportDatabaseRanges.hxx |4 
 2 files changed, 73 insertions(+), 71 deletions(-)

New commits:
commit b30b4e9c7c492542e1ae726e2e45627ee33f7cd5
Author: Vikas 
Date:   Fri Jun 29 12:19:58 2018 +0530

Move writesort() method from WriteDatabaseRange to free function

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

diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx 
b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index a11a796a7e3d..187d63383723 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -52,6 +52,71 @@
 using namespace com::sun::star;
 using namespace xmloff::token;
 
+void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const 
ScRange& aRange, const ScDocument* mpDoc)
+{
+// Count sort items first.
+size_t nSortCount = 0;
+for (; nSortCount < aParam.GetSortKeyCount(); ++nSortCount)
+{
+if (!aParam.maKeyState[nSortCount].bDoSort)
+break;
+}
+
+if (!nSortCount)
+// Nothing to export.
+return;
+
+ScAddress aOutPos(aParam.nDestCol, aParam.nDestRow, aParam.nDestTab);
+
+if (!aParam.bIncludePattern)
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_BIND_STYLES_TO_CONTENT, 
XML_FALSE);
+
+if (!aParam.bInplace)
+{
+OUString aStr;
+ScRangeStringConverter::GetStringFromAddress(
+aStr, aOutPos, mpDoc, ::formula::FormulaGrammar::CONV_OOO);
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TARGET_RANGE_ADDRESS, 
aStr);
+}
+
+if (aParam.bCaseSens)
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, 
XML_TRUE);
+
+mrExport.AddLanguageTagAttributes( XML_NAMESPACE_TABLE, 
XML_NAMESPACE_TABLE, aParam.aCollatorLocale, false);
+if (!aParam.aCollatorAlgorithm.isEmpty())
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ALGORITHM, 
aParam.aCollatorAlgorithm);
+
+SvXMLElementExport aElemS(mrExport, XML_NAMESPACE_TABLE, XML_SORT, true, 
true);
+
+SCCOLROW nFieldStart = aParam.bByRow ? aRange.aStart.Col() : 
aRange.aStart.Row();
+
+for (size_t i = 0; i < nSortCount; ++i)
+{
+// Convert field value from absolute to relative.
+SCCOLROW nField = aParam.maKeyState[i].nField - nFieldStart;
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, 
OUString::number(nField));
+
+if (!aParam.maKeyState[i].bAscending)
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORDER, 
XML_DESCENDING);
+
+if (aParam.bUserDef)
+{
+OUStringBuffer aBuf;
+aBuf.append(SC_USERLIST);
+aBuf.append(static_cast(aParam.nUserIndex));
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, 
aBuf.makeStringAndClear());
+}
+else
+{
+// Right now we only support automatic field type.  In the
+// future we may support numeric or alphanumeric field type.
+mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, 
XML_AUTOMATIC);
+}
+
+SvXMLElementExport aElemSb(mrExport, XML_NAMESPACE_TABLE, XML_SORT_BY, 
true, true);
+}
+}
+
 ScXMLExportDatabaseRanges::ScXMLExportDatabaseRanges(ScXMLExport& rTempExport)
 : rExport(rTempExport),
 pDoc( nullptr )
@@ -207,9 +272,12 @@ private:
 
 SvXMLElementExport aElemDR(mrExport, XML_NAMESPACE_TABLE, 
XML_DATABASE_RANGE, true, true);
 
+ScSortParam aParam;
+rData.GetSortParam(aParam);
+
 writeImport(rData);
 writeFilter(rData);
-writeSort(rData);
+writeSort(mrExport, aParam, aRange, mpDoc);
 writeSubtotals(rData);
 }
 
@@ -294,76 +362,6 @@ private:
 }
 }
 
-void writeSort(const ScDBData& rData)
-{
-ScSortParam aParam;
-rData.GetSortParam(aParam);
-
-// Count sort items first.
-size_t nSortCount = 0;
-for (; nSortCount < aParam.GetSortKeyCount(); ++nSortCount)
-{
-if (!aParam.maKeyState[nSortCount].bDoSort)
-break;
-}
-
-if (!nSortCount)
-// Nothing to export.
-return;
-
-ScAddress aOutPos(aParam.nDestCol, aParam.nDestRow, aParam.nDestTab);
-
-if (!aParam.bIncludePattern)
-mrExport.AddAttribute(XML_NAMESPACE_TABLE, 
XML_BIND_STYLES_TO_CONTENT, XML_FALSE);
-
-if (!aParam.bInplace)
-{
-OUString aStr;
-ScRangeStringConverter::GetStringFromAddress(
-aStr, aOutPos, mpDoc, ::formula::FormulaGrammar::CONV_OOO);
-mrExport.AddAttribute(XML_NAMESPACE_TABLE, 
XML_TARGET_RANGE_ADDRESS, aStr);
-}
-

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

2018-07-02 Thread Vikas
 include/xmloff/xmltoken.hxx  |8 ++
 sc/source/filter/xml/xmlexprt.cxx|   81 +++
 sc/source/filter/xml/xmlexprt.hxx|3 
 sc/source/ui/dataprovider/datatransformation.cxx |   50 ++
 sc/source/ui/inc/datatransformation.hxx  |   22 +-
 xmloff/source/core/xmltoken.cxx  |7 +
 xmloff/source/token/tokens.txt   |7 +
 7 files changed, 176 insertions(+), 2 deletions(-)

New commits:
commit cb875f3ef1aa14b931131c4c0ddc595e3841273d
Author: Vikas 
Date:   Fri Jun 29 13:52:02 2018 +0530

Export data transformations to odf

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

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 5a1cd6157887..862741d0a0eb 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3278,6 +3278,14 @@ namespace xmloff { namespace token {
 XML_DATA_MAPPINGS,
 XML_DATA_MAPPING,
 XML_DATA_FREQUENCY,
+XML_DATA_TRANSFORMATIONS,
+XML_COLUMN_REMOVE_TRANSFORMATION,
+XML_COLUMN_SPLIT_TRANSFORMATION,
+XML_COLUMN_MERGE_TRANSFORMATION,
+XML_COLUMN_SORT_TRANSFORMATION,
+XML_SORT_PARAM,
+XML_MERGE_STRING,
+//Already defined XML_SEPARATOR,
 
 // regina, ODF1.2 additional symbols in charts
 XML_STAR,
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index bcfe73fe22d8..58d0e197b975 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -159,6 +159,8 @@
 #include 
 #include 
 
+
+
 //! not found in unonames.hxx
 #define SC_LAYERID "LayerID"
 
@@ -4061,6 +4063,7 @@ void ScXMLExport::WriteExternalDataMapping()
 
 sc::ExternalDataMapper& rDataMapper = pDoc->GetExternalDataMapper();
 auto& rDataSources = rDataMapper.getDataSources();
+
 if (!rDataSources.empty())
 {
 SvXMLElementExport aMappings(*this, XML_NAMESPACE_CALC_EXT, 
XML_DATA_MAPPINGS, true, true);
@@ -4071,11 +4074,89 @@ void ScXMLExport::WriteExternalDataMapping()
 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_DATA_FREQUENCY, 
OUString::number(itr.getUpdateFrequency()));
 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_ID, itr.getID());
 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_DATABASE_NAME, 
itr.getDBName());
+
+// Add the data transformations
+WriteExternalDataTransformations(itr.getDataTransformation());
+
 SvXMLElementExport aMapping(*this, XML_NAMESPACE_CALC_EXT, 
XML_DATA_MAPPING, true, true);
 }
 }
 }
 
+void ScXMLExport::WriteExternalDataTransformations(const 
std::vector>& aDataTransformations)
+{
+SvXMLElementExport aTransformations(*this, XML_NAMESPACE_CALC_EXT, 
XML_DATA_TRANSFORMATIONS, true, true);
+for (auto& itr : aDataTransformations)
+{
+sc::TransformationType aTransformationType = 
itr->getTransformationType();
+
+switch(aTransformationType)
+{
+case sc::TransformationType::DELETE_TRANSFORMATION:
+{
+// Delete Columns Transformation
+std::shared_ptr 
aDeleteTransformation = 
std::dynamic_pointer_cast(itr);
+std::set aColumns = aDeleteTransformation->getColumns();
+SvXMLElementExport aTransformation(*this, 
XML_NAMESPACE_CALC_EXT, XML_COLUMN_REMOVE_TRANSFORMATION, true, true);
+for(auto& col : aColumns)
+{
+// Add Columns
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLUMN, 
OUString::number(col));
+SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, 
XML_COLUMN, true, true);
+}
+}
+break;
+case sc::TransformationType::SPLIT_TRANSFORMATION:
+{
+std::shared_ptr 
aSplitTransformation = 
std::dynamic_pointer_cast(itr);
+
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLUMN, 
OUString::number(aSplitTransformation->getColumn()));
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_SEPARATOR, 
OUString::number(aSplitTransformation->getSeparator()));
+SvXMLElementExport aTransformation(*this, 
XML_NAMESPACE_CALC_EXT, XML_COLUMN_SPLIT_TRANSFORMATION, true, true);
+}
+break;
+case sc::TransformationType::MERGE_TRANSFORMATION:
+{
+// Merge Transformation
+std::shared_ptr 
aMergeTransformation = 
std::dynamic_pointer_cast(itr);
+std::set aColumns = aMergeTransformation->getColumns();
+
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_MERGE_STRING, 
aMergeTransformation->getMergeString()

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

2018-07-08 Thread Vikas
 sc/qa/unit/datatransformation_test.cxx   |  213 
 sc/source/ui/dataprovider/datatransformation.cxx |  236 +++
 sc/source/ui/inc/datatransformation.hxx  |   19 +
 3 files changed, 467 insertions(+), 1 deletion(-)

New commits:
commit 510073cf047101cf6297fcec2ad8296f9e63c486
Author: Vikas 
Date:   Tue Jul 3 11:47:14 2018 +0530

Added number transformations for external data

 - Round allows you to round the numbers in the column up to a given number 
of decimal places
 - Round Up rounds the numbers in the column up to the nearest whole number
 - Round Down rounds the numbers in the column down to the nearest whole 
number
 - Absolute Value returns the absolute value of the numbers in the column
 - Logarithm
- Natural returns the natural logarithm
- Base-10 returns the base-10 logarithm
 - Cube returns the cube of the numbers
 - Square returns the square of the numbers
 - Square Root returns the square root of the numbers
 - Is Even returns TRUE if the values in the column are eve
 - Is Odd returns TRUE if the values in the column are odd
 - Sign returns 1 if the values in the column are positive, -1 if they are 
negative, and 0 otherwise.

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

diff --git a/sc/qa/unit/datatransformation_test.cxx 
b/sc/qa/unit/datatransformation_test.cxx
index c011941a6cb7..3546104fdbee 100644
--- a/sc/qa/unit/datatransformation_test.cxx
+++ b/sc/qa/unit/datatransformation_test.cxx
@@ -39,6 +39,18 @@ public:
 void testAggregateAverage();
 void testAggregateMin();
 void testAggregateMax();
+void testNumberRound();
+void testNumberRoundUp();
+void testNumberRoundDown();
+void testNumberAbsolute();
+void testNumberLogE();
+void testNumberLog10();
+void testNumberCube();
+void testNumberSquare();
+void testNumberSquareRoot();
+void testNumberEven();
+void testNumberOdd();
+void testNumberSign();
 
 CPPUNIT_TEST_SUITE(ScDataTransformationTest);
 CPPUNIT_TEST(testColumnRemove);
@@ -52,6 +64,18 @@ public:
 CPPUNIT_TEST(testAggregateAverage);
 CPPUNIT_TEST(testAggregateMin);
 CPPUNIT_TEST(testAggregateMax);
+CPPUNIT_TEST(testNumberRound);
+CPPUNIT_TEST(testNumberRoundUp);
+CPPUNIT_TEST(testNumberRoundDown);
+CPPUNIT_TEST(testNumberAbsolute);
+CPPUNIT_TEST(testNumberLogE);
+CPPUNIT_TEST(testNumberLog10);
+CPPUNIT_TEST(testNumberCube);
+CPPUNIT_TEST(testNumberSquare);
+CPPUNIT_TEST(testNumberSquareRoot);
+CPPUNIT_TEST(testNumberEven);
+CPPUNIT_TEST(testNumberOdd);
+CPPUNIT_TEST(testNumberSign);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -272,6 +296,195 @@ void ScDataTransformationTest::testAggregateMax()
 CPPUNIT_ASSERT_DOUBLES_EQUAL(2034, m_pDoc->GetValue(3, 4, 0), 1e-10);
 }
 
+void ScDataTransformationTest::testNumberRound()
+{
+m_pDoc->SetValue(2, 0, 0, 2034.342453456);
+m_pDoc->SetValue(2, 1, 0, 2342.252678567542);
+m_pDoc->SetValue(2, 2, 0, 57453.651345687654345676);
+m_pDoc->SetValue(2, 3, 0, -453.22234567543);
+
+sc::NumberTransformation aTransform(2, sc::NUMBER_TRANSFORM_TYPE::ROUND, 
4);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_EQUAL(2034.3425, m_pDoc->GetValue(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(2342.2527, m_pDoc->GetValue(2, 1, 0));
+CPPUNIT_ASSERT_EQUAL(57453.6513, m_pDoc->GetValue(2, 2, 0));
+CPPUNIT_ASSERT_EQUAL(-453.2223, m_pDoc->GetValue(2, 3, 0));
+}
+
+void ScDataTransformationTest::testNumberRoundUp()
+{
+m_pDoc->SetValue(2, 0, 0, 2034.34);
+m_pDoc->SetValue(2, 1, 0, 2342.22);
+m_pDoc->SetValue(2, 2, 0, 57453.65);
+m_pDoc->SetValue(2, 3, 0, -453.22);
+
+sc::NumberTransformation aTransform(2, 
sc::NUMBER_TRANSFORM_TYPE::ROUND_UP);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_EQUAL(2035.0, m_pDoc->GetValue(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(2343.0, m_pDoc->GetValue(2, 1, 0));
+CPPUNIT_ASSERT_EQUAL(57454.0, m_pDoc->GetValue(2, 2, 0));
+CPPUNIT_ASSERT_EQUAL(-453.0, m_pDoc->GetValue(2, 3, 0));
+}
+
+void ScDataTransformationTest::testNumberRoundDown()
+{
+m_pDoc->SetValue(2, 0, 0, 2034.34);
+m_pDoc->SetValue(2, 1, 0, 2342.22);
+m_pDoc->SetValue(2, 2, 0, 57453.65);
+m_pDoc->SetValue(2, 3, 0, -453.22);
+
+sc::NumberTransformation aTransform(2, 
sc::NUMBER_TRANSFORM_TYPE::ROUND_DOWN);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_EQUAL(2034.0, m_pDoc->GetValue(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(2342.0, m_pDoc->GetValue(2, 1, 0));
+CPPUNIT_ASSERT_EQUAL(57453.0, m_pDoc->GetValue(2, 2, 0));
+CPPUNIT_ASSERT_EQUAL(-454.0, m_pDoc->GetValue(2, 3, 0));
+}
+
+void ScDataTransformationTest::testNumberA

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

2018-07-06 Thread Vikas
 sc/qa/unit/datatransformation_test.cxx   |   80 ++
 sc/source/ui/dataprovider/datatransformation.cxx |   98 +++
 sc/source/ui/inc/datatransformation.hxx  |   16 +++
 3 files changed, 193 insertions(+), 1 deletion(-)

New commits:
commit 8981adda6a24a172245b8cd0dd60e31644e23c75
Author: Vikas 
Date:   Tue Jul 3 17:05:36 2018 +0530

Added aggregate functions for external data

- Sum, which returns the sum of values in the column.
- Average, which returns the average of values in the column.
- Min, which returns the minimum of the values in the column.
- Max, which returns the maximum of the values in the column.

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

diff --git a/sc/qa/unit/datatransformation_test.cxx 
b/sc/qa/unit/datatransformation_test.cxx
index 8cec163eeb43..c011941a6cb7 100644
--- a/sc/qa/unit/datatransformation_test.cxx
+++ b/sc/qa/unit/datatransformation_test.cxx
@@ -35,6 +35,10 @@ public:
 void testTextToUpper();
 void testTextCapitalize();
 void testTextTrim();
+void testAggregateSum();
+void testAggregateAverage();
+void testAggregateMin();
+void testAggregateMax();
 
 CPPUNIT_TEST_SUITE(ScDataTransformationTest);
 CPPUNIT_TEST(testColumnRemove);
@@ -44,6 +48,10 @@ public:
 CPPUNIT_TEST(testTextToUpper);
 CPPUNIT_TEST(testTextCapitalize);
 CPPUNIT_TEST(testTextTrim);
+CPPUNIT_TEST(testAggregateSum);
+CPPUNIT_TEST(testAggregateAverage);
+CPPUNIT_TEST(testAggregateMin);
+CPPUNIT_TEST(testAggregateMax);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -193,6 +201,78 @@ void ScDataTransformationTest::testTextTrim()
 CPPUNIT_ASSERT_EQUAL(OUString("Paris"), m_pDoc->GetString(2, 2, 0));
 }
 
+void ScDataTransformationTest::testAggregateSum()
+{
+m_pDoc->SetValue(2, 0, 0, 2034);
+m_pDoc->SetValue(2, 1, 0, 2342);
+m_pDoc->SetValue(2, 2, 0, 57452);
+
+m_pDoc->SetValue(4, 0, 0, 4829.98);
+m_pDoc->SetValue(4, 1, 0, 53781.3);
+m_pDoc->SetValue(4, 2, 0, 9876.4);
+m_pDoc->SetValue(4, 3, 0, 0);
+
+sc::AggregateFunction aTransform({2, 4}, sc::AGGREGATE_FUNCTION::SUM);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(61828, m_pDoc->GetValue(2, 4, 0), 1e-10);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(68487.68, m_pDoc->GetValue(4, 4, 0), 1e-10);
+}
+
+void ScDataTransformationTest::testAggregateAverage()
+{
+m_pDoc->SetValue(2, 0, 0, 2034);
+m_pDoc->SetValue(2, 1, 0, 2342);
+m_pDoc->SetValue(2, 2, 0, 57453);
+
+m_pDoc->SetValue(3, 0, 0, 4);
+m_pDoc->SetValue(3, 1, 0, 4);
+m_pDoc->SetValue(3, 2, 0, 4);
+
+sc::AggregateFunction aTransform({2, 3}, sc::AGGREGATE_FUNCTION::AVERAGE);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(20609.67, m_pDoc->GetValue(2, 3, 0), 
1e-10);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(4, m_pDoc->GetValue(3, 3, 0), 1e-10);
+}
+
+void ScDataTransformationTest::testAggregateMin()
+{
+m_pDoc->SetValue(2, 0, 0, 2034);
+m_pDoc->SetValue(2, 1, 0, 2342);
+m_pDoc->SetValue(2, 2, 0, 57453);
+
+m_pDoc->SetValue(3, 0, 0, 2034);
+m_pDoc->SetValue(3, 1, 0, -2342);
+m_pDoc->SetValue(3, 2, 0, 57453);
+
+sc::AggregateFunction aTransform({2, 3}, sc::AGGREGATE_FUNCTION::MIN);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(2034, m_pDoc->GetValue(2, 3, 0), 1e-10);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(-2342, m_pDoc->GetValue(3, 3, 0), 1e-10);
+}
+
+void ScDataTransformationTest::testAggregateMax()
+{
+m_pDoc->SetValue(2, 0, 0, 2034);
+m_pDoc->SetValue(2, 1, 0, 2342);
+m_pDoc->SetValue(2, 2, 0, 57453);
+m_pDoc->SetValue(2, 3, 0, -453);
+
+m_pDoc->SetValue(3, 0, 0, 2034);
+m_pDoc->SetValue(3, 1, 0, -2342);
+m_pDoc->SetValue(3, 2, 0, -57453);
+m_pDoc->SetValue(3, 3, 0, -453);
+
+sc::AggregateFunction aTransform({2, 3}, sc::AGGREGATE_FUNCTION::MAX);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(57453, m_pDoc->GetValue(2, 4, 0), 1e-10);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(2034, m_pDoc->GetValue(3, 4, 0), 1e-10);
+}
+
+
 ScDataTransformationTest::ScDataTransformationTest() :
 ScBootstrapFixture( "sc/qa/unit/data/dataprovider" ),
 m_pDoc(nullptr)
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx 
b/sc/source/ui/dataprovider/datatransformation.cxx
index 84df313aacdc..fd779bf6587a 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -10,6 +10,7 @@
 #include 
 
 #include 
+#include 
 
 namespace sc {
 
@@ -268,6 +269,103 @@ TransformationType 
TextTransformation::getTransformationType() const
 return TransformationType::TEXT_TRANS

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

2018-07-06 Thread Vikas
 sc/qa/unit/datatransformation_test.cxx   |   70 
 sc/source/ui/dataprovider/datatransformation.cxx |   95 +++
 sc/source/ui/inc/datatransformation.hxx  |   16 +++
 3 files changed, 180 insertions(+), 1 deletion(-)

New commits:
commit 483ca6e6bb9c920cc96212c7042e13fbbb5fa767
Author: Vikas 
Date:   Mon Jul 2 01:29:09 2018 +0530

Added text transformations for external data

 - Uppercase, which sets all text in the selected columns to upper case.
 - Lowercase, which sets all text in the selected columns to lower case.
 - Capitalize Each Word, which makes all words in the selected column start 
with a capital letter and sets all subsequent letters in a word to lower case.
 - Trim, which removes any leading or trailing whitespace characters from 
text.

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

diff --git a/sc/qa/unit/datatransformation_test.cxx 
b/sc/qa/unit/datatransformation_test.cxx
index d4c0e11a2642..8cec163eeb43 100644
--- a/sc/qa/unit/datatransformation_test.cxx
+++ b/sc/qa/unit/datatransformation_test.cxx
@@ -31,11 +31,19 @@ public:
 void testColumnRemove();
 void testColumnSplit();
 void testColumnMerge();
+void testTextToLower();
+void testTextToUpper();
+void testTextCapitalize();
+void testTextTrim();
 
 CPPUNIT_TEST_SUITE(ScDataTransformationTest);
 CPPUNIT_TEST(testColumnRemove);
 CPPUNIT_TEST(testColumnSplit);
 CPPUNIT_TEST(testColumnMerge);
+CPPUNIT_TEST(testTextToLower);
+CPPUNIT_TEST(testTextToUpper);
+CPPUNIT_TEST(testTextCapitalize);
+CPPUNIT_TEST(testTextTrim);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -123,6 +131,68 @@ void ScDataTransformationTest::testColumnMerge()
 }
 }
 
+void ScDataTransformationTest::testTextToLower()
+{
+m_pDoc->SetString(2, 0, 0, "Berlin");
+m_pDoc->SetString(2, 1, 0, "Brussels");
+m_pDoc->SetString(2, 2, 0, "Paris");
+m_pDoc->SetString(2, 3, 0, "Peking");
+
+sc::TextTransformation aTransform(2, sc::TEXT_TRANSFORM_TYPE::TO_LOWER);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_EQUAL(OUString("berlin"), m_pDoc->GetString(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("brussels"), m_pDoc->GetString(2, 1, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("paris"), m_pDoc->GetString(2, 2, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("peking"), m_pDoc->GetString(2, 3, 0));
+}
+
+void ScDataTransformationTest::testTextToUpper()
+{
+m_pDoc->SetString(2, 0, 0, "Berlin");
+m_pDoc->SetString(2, 1, 0, "Brussels");
+m_pDoc->SetString(2, 2, 0, "Paris");
+m_pDoc->SetString(2, 3, 0, "Peking");
+
+sc::TextTransformation aTransform(2, sc::TEXT_TRANSFORM_TYPE::TO_UPPER);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_EQUAL(OUString("BERLIN"), m_pDoc->GetString(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("BRUSSELS"), m_pDoc->GetString(2, 1, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("PARIS"), m_pDoc->GetString(2, 2, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("PEKING"), m_pDoc->GetString(2, 3, 0));
+}
+
+void ScDataTransformationTest::testTextCapitalize()
+{
+m_pDoc->SetString(2, 0, 0, "hello woRlD");
+m_pDoc->SetString(2, 1, 0, "qUe vA");
+m_pDoc->SetString(2, 2, 0, "si tu la ves");
+m_pDoc->SetString(2, 3, 0, "cUaNdO mE EnAmOro");
+
+sc::TextTransformation aTransform(2, sc::TEXT_TRANSFORM_TYPE::CAPITALIZE);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), m_pDoc->GetString(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Que Va"), m_pDoc->GetString(2, 1, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Si Tu La Ves"), m_pDoc->GetString(2, 2, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Cuando Me Enamoro"), m_pDoc->GetString(2, 
3, 0));
+}
+
+void ScDataTransformationTest::testTextTrim()
+{
+m_pDoc->SetString(2, 0, 0, " Berlin");
+m_pDoc->SetString(2, 1, 0, "Brussels ");
+m_pDoc->SetString(2, 2, 0, " Paris ");
+
+sc::TextTransformation aTransform(2, sc::TEXT_TRANSFORM_TYPE::TRIM);
+aTransform.Transform(*m_pDoc);
+
+CPPUNIT_ASSERT_EQUAL(OUString("Berlin"), m_pDoc->GetString(2, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Brussels"), m_pDoc->GetString(2, 1, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("Paris"), m_pDoc->GetString(2, 2, 0));
+}
+
 ScDataTransformationTest::ScDataTransformationTest() :
 ScBootstrapFixture( "sc/qa/unit/data/dataprovider" ),
 m_pDoc(nullptr)
diff --git a/sc/source/ui/

External Data providersin Calc - GSoC project

2018-05-15 Thread Vikas Mahato
Hi all,

I looked into how to make UNO components for calc and referred to
Solver.idl and XSolver.idl in  offapi module for more understanding.

I am thinking of moving the existing implementation of dataproviders and
datatransformations (located at sc/source/ui/dataproviders) to two UNO
components.

This would mean creating 4 new files in offapi/com/sun/star/sheet namely

ExternalDataProvider.idl
XExternalDataProvider.idl
DataTransformations.idl
XDataTransformations.idl

ExternalDataProvider will host the following methods:
1. void Import()
2. OUString& GetURL()
3. map<OUString, OUString> getDataSourcesForURL(const OUString& rURL)
4. unique_ptr FetchStreamFromURL(const OUString&, OStringBuffer&
rBuffer)


DataTransformation will host all the methods defined in
datatransformation.hxx

I want to convert the existing implementations to UNO so that external
application developers can make use of the functionality as well.

Looking for suggestions and feedback.

Kind Regards,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


GSoC weekly update - Vikas Mahato

2018-05-24 Thread Vikas Mahato
Hello everyone,

This is my weekly status  update

*14 May*
After discussing with my Metors on IRC, we decided that I should begin
working on building an UNO interface for external data providers

*15 to 16 **May*
I spent the day trying to figure out how to build UNO components and
reading documentation and code.

*17 May*
Pushed a WIP commit to gerrit https://gerrit.libreoffice.org/#/c/54481/

*18 to 20 May*
Trying to figure out a way to connect UNO interface code with internal code

*23 May *
Learnt how to test UNO interface from Calc using Macros and worked on
insertByIndex() method

Regards,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


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

2018-06-24 Thread Vikas Mahato
 external/liborcus/0001-add-xml-path.patch |  119 ++
 sc/source/filter/inc/orcusinterface.hxx   |4 -
 sc/source/filter/orcus/interface.cxx  |8 +-
 sc/source/filter/orcus/xmlcontext.cxx |2 
 4 files changed, 126 insertions(+), 7 deletions(-)

New commits:
commit 9313dcc624e3898d2b10f8b0d6efba403a190c88
Author: Vikas Mahato 
Date:   Sun Jun 24 20:38:12 2018 +0530

Changes to orcus for implementing XML data provider

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

diff --git a/external/liborcus/0001-add-xml-path.patch 
b/external/liborcus/0001-add-xml-path.patch
new file mode 100644
index ..3f9a16bb880f
--- /dev/null
+++ b/external/liborcus/0001-add-xml-path.patch
@@ -0,0 +1,119 @@
+diff --git a/include/orcus/xml_structure_tree.hpp 
b/include/orcus/xml_structure_tree.hpp
+index 
58cabfd116fa24e35ff27cf8d7512b6e73df33f4..c88808d24bd74c175fa4017328d3e54b4c588c5e
 100644
+--- a/include/orcus/xml_structure_tree.hpp
 b/include/orcus/xml_structure_tree.hpp
+@@ -127,6 +127,20 @@ public:
+ size_t get_xmlns_index(xmlns_id_t ns) const;
+
+ std::string get_xmlns_short_name(xmlns_id_t ns) const;
++
++/**
++ * Get a XPath like ID for the element inside of the XML tree.
++ *
++ */
++std::string get_path() const;
++
++/**
++ * Select an element by a path expression. The path expression may be
++ * generated by xml_structure_tree::walker::get_path.
++ *
++ * @param path a simple XPath like expression
++ */
++element select_by_path(const std::string& path);
+ };
+
+ xml_structure_tree(xmlns_context& xmlns_cxt);
+diff --git a/src/liborcus/xml_structure_tree.cpp 
b/src/liborcus/xml_structure_tree.cpp
+index 
2778bc05f32841a9441bf471913872e119256895..6622bc57cd2595f12bba80d4bbdb5c24cd6e7bc6
 100644
+--- a/src/liborcus/xml_structure_tree.cpp
 b/src/liborcus/xml_structure_tree.cpp
+@@ -12,6 +12,7 @@
+ #include "orcus/exception.hpp"
+
+ #include "orcus/string_pool.hpp"
++#include "string_helper.hpp"
+
+ #include 
+ #include 
+@@ -275,6 +276,15 @@ struct xml_structure_tree_impl
+ {
+ delete mp_root;
+ }
++
++std::string get_element_str(const xml_structure_tree::entity_name& name) 
const
++{
++ostringstream ss;
++if (m_xmlns_cxt.get_index(name.ns) != index_not_found)
++ss << m_xmlns_cxt.get_short_name(name.ns) << ":";
++ss << name.name;
++return ss.str();
++}
+ };
+
+ struct xml_structure_tree::walker_impl
+@@ -423,6 +433,66 @@ string 
xml_structure_tree::walker::get_xmlns_short_name(xmlns_id_t ns) const
+ return mp_impl->m_parent_impl.m_xmlns_cxt.get_short_name(ns);
+ }
+
++string xml_structure_tree::walker::get_path() const
++{
++ostringstream ss;
++for (auto& element : mp_impl->m_scopes)
++{
++ss << "/" << mp_impl->m_parent_impl.get_element_str(element.name);
++}
++
++return ss.str();
++}
++
++xml_structure_tree::element xml_structure_tree::walker::select_by_path(const 
std::string& path)
++{
++pstring p(path);
++std::vector parts = string_helper::split_string(p, '/');
++if (parts.empty())
++throw general_error("invalid format for path");
++
++// string_helper::split_string will create an empty first element due to 
leading '/'
++if (parts[0] != "")
++{
++throw general_error("invalid format for path");
++}
++else
++{
++parts.erase(parts.begin());
++}
++
++if (parts.empty())
++throw general_error("invalid format for path");
++
++element_ref root_ref(mp_impl->mp_root->name, _impl->mp_root->prop);
++if (pstring(mp_impl->m_parent_impl.get_element_str(root_ref.name)) != 
parts[0])
++throw general_error("path does not match any element");
++
++std::vector scopes;
++scopes.push_back(root_ref);
++
++for (size_t i = 1; i < parts.size(); ++i)
++{
++const elem_prop& prop = *scopes.back().prop;
++bool found = false;
++for (auto& child : prop.child_elements)
++{
++if (pstring(mp_impl->m_parent_impl.get_element_str(child.first)) 
== parts[i])
++{
++scopes.emplace_back(child.first, child.second);
++found = true;
++break;
++}
++}
++if (!found)
++throw general_error("path does not match any element");
++}
++
++std::swap(mp_impl->m_scopes, scopes);
++const element_ref& ref = mp_impl->m_scopes.back();
++return element(ref.name, ref.prop->repeat);
++}
++
+ xml_stru

GSoC Introduction - Vikas Mahato

2018-05-02 Thread Vikas Mahato
Hello Developers,

I am Vikas Prasad Mahato and I have been selected for GSoC to work on Calc
Data Import project where I'll be working on features to enable importing
data to Calc from external data sources (like HTML and CSV).

So far, I have set up my development environment, configured vim and did a
fresh build of libreoffice.

I am now reading though docs and tweaking bits of code to understand more
on how Calc works.

I feel really good being part of this community and am looking forward to
an exciting and code filled summer.

Regards,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Vikas Mahato license statement

2017-12-31 Thread Vikas Mahato
All of my past & future contributions to LibreOffice may be licensed
under the MPLv2/LGPLv3+ dual license.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Equivalent of std::mktime in LO

2018-07-29 Thread Vikas Mahato
Hello All,

I have a patch here, https://gerrit.libreoffice.org/#/c/58152/ and I am
trying to replace

std::tm getDateTime(double nDateTime)
{
long nDays = std::trunc(nDateTime);
std::tm aDate = {};
aDate.tm_year = 0;
aDate.tm_mon  = 0;
aDate.tm_mday = 0;
aDate.tm_sec = getSecond(nDateTime);
aDate.tm_min = getMinute(nDateTime);
aDate.tm_hour = getHour(nDateTime);
aDate.tm_wday = 0;
aDate.tm_yday = 0;
// Add number of days
aDate.tm_mday += nDays;
std::mktime();
return aDate;
}

with css::util:DateTIme. I am  having trouble finding out what is the
equivalent for std::mktime in LO.

Thanks,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Generate encryption key

2018-07-23 Thread Vikas Mahato
Hello all,

I wanted to know how can we generate the encryption key for using wit
include/oox/crypto/CryptTools.hxx classes?

Thanks,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Generate encryption key

2018-07-24 Thread Vikas Mahato
Thanks,
I'll have a look at css::task::XPasswordContainer2 interface and get back
to you.

On Tue, 24 Jul 2018, 16:22 Eike Rathke,  wrote:

> Hi Vikas,
>
> On Tuesday, 2018-07-24 11:44:27 +0200, Tomaž Vajngerl wrote:
>
> > On Tue, Jul 24, 2018 at 10:11 AM, Vikas Mahato 
> wrote:
> > >
> > > I am trying to implement credentials for external data source as part
> of my
> > > GSoC project. I want to encrypt the credentials and store them to a
> file.
> > > moggi ( my mentor) asked me to implement it using CryptTools but I am
> not
> > > sure how to proceed.
>
> So that suggests it is not OOXML related, but the credentials are to be
> stored (in the configuration) somehow. We already have the "Passwords
> for Web Connections" under Tools -> Options -> LibreOffice -> Security,
> which sounds like it should do what is requested.
>
> Look for use of the css::task::XPasswordContainer2 interface, or the
> css::task::PaswordContainer service, specifically
> PasswordContainer::create(...) calls where dialogs use it.
>
>   Eike
>
> --
> LibreOffice Calc developer. Number formatter stricken i18n
> transpositionizer.
> GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563
> 2D3A
>
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


Calc cell type

2018-07-24 Thread Vikas Mahato
Hello all,

I am trying to write some datatransformations related to date-time for calc.

Is there any way to determine whether a column stores date or time value? I
was only able to find CELLTYPE_STRING, CELLTYPE_NONE, CELLTYPE_VALUE etc in
global.hxx but none related to date or time.

Regards,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


[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_pD

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

2018-07-11 Thread Vikas Mahato
 include/xmloff/xmltoken.hxx  |   12 ++
 sc/source/filter/xml/xmlexprt.cxx|  127 ++-
 sc/source/filter/xml/xmlmappingi.cxx |2 
 sc/source/ui/dataprovider/datatransformation.cxx |   34 ++
 sc/source/ui/inc/datatransformation.hxx  |7 +
 xmloff/source/core/xmltoken.cxx  |   13 ++
 xmloff/source/token/tokens.txt   |   12 ++
 7 files changed, 205 insertions(+), 2 deletions(-)

New commits:
commit 376011df10f20c9a5ee033f11789c579910cf206
Author: Vikas Mahato 
Date:   Mon Jul 9 08:06:59 2018 +0530

ODF export data transformations -follow-up

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

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 862741d0a0eb..1c388e5e3193 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3283,8 +3283,20 @@ namespace xmloff { namespace token {
 XML_COLUMN_SPLIT_TRANSFORMATION,
 XML_COLUMN_MERGE_TRANSFORMATION,
 XML_COLUMN_SORT_TRANSFORMATION,
+XML_COLUMN_TEXT_TRANSFORMATION,
+XML_COLUMN_AGGREGATE_TRANSFORMATION,
+XML_COLUMN_NUMBER_TRANSFORMATION,
 XML_SORT_PARAM,
 XML_MERGE_STRING,
+XML_TRIM,
+XML_ROUND_UP,
+XML_ROUND_DOWN,
+XML_LOG_10,
+XML_SQUARE,
+XML_SQUARE_ROOT,
+XML_EVEN,
+XML_ODD,
+XML_SIGN,
 //Already defined XML_SEPARATOR,
 
 // regina, ODF1.2 additional symbols in charts
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 58d0e197b975..63ec4abc9302 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -4075,10 +4075,9 @@ void ScXMLExport::WriteExternalDataMapping()
 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_ID, itr.getID());
 AddAttribute(XML_NAMESPACE_CALC_EXT, XML_DATABASE_NAME, 
itr.getDBName());
 
+SvXMLElementExport aMapping(*this, XML_NAMESPACE_CALC_EXT, 
XML_DATA_MAPPING, true, true);
 // Add the data transformations
 WriteExternalDataTransformations(itr.getDataTransformation());
-
-SvXMLElementExport aMapping(*this, XML_NAMESPACE_CALC_EXT, 
XML_DATA_MAPPING, true, true);
 }
 }
 }
@@ -4151,6 +4150,130 @@ void 
ScXMLExport::WriteExternalDataTransformations(const std::vector aTextTransformation = 
std::dynamic_pointer_cast(itr);
+
+sc::TEXT_TRANSFORM_TYPE aTextTransformType = 
aTextTransformation->getTextTransformationType();
+
+switch ( aTextTransformType )
+{
+case sc::TEXT_TRANSFORM_TYPE::TO_LOWER:
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, 
XML_CASEMAP_LOWERCASE);
+break;
+case sc::TEXT_TRANSFORM_TYPE::TO_UPPER:
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, 
XML_CASEMAP_UPPERCASE);
+break;
+case sc::TEXT_TRANSFORM_TYPE::CAPITALIZE:
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, 
XML_CASEMAP_CAPITALIZE);
+break;
+case sc::TEXT_TRANSFORM_TYPE::TRIM:
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, 
XML_TRIM);
+break;
+}
+
+std::set aColumns = aTextTransformation->getColumns();
+
+SvXMLElementExport aTransformation(*this, 
XML_NAMESPACE_CALC_EXT, XML_COLUMN_TEXT_TRANSFORMATION, true, true);
+
+for(auto& col : aColumns)
+{
+// Columns
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_COLUMN, 
OUString::number(col));
+SvXMLElementExport aCol(*this, XML_NAMESPACE_CALC_EXT, 
XML_COLUMN, true, true);
+}
+}
+break;
+case sc::TransformationType::AGGREGATE_FUNCTION:
+{
+// Aggregate Transformation
+std::shared_ptr aAggregateFunction = 
std::dynamic_pointer_cast(itr);
+std::set aColumns = aAggregateFunction->getColumns();
+
+sc::AGGREGATE_FUNCTION aAggregateType = 
aAggregateFunction->getAggregateType();
+
+switch (aAggregateType)
+{
+case sc::AGGREGATE_FUNCTION::SUM:
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, 
XML_SUM);
+break;
+case sc::AGGREGATE_FUNCTION::AVERAGE:
+AddAttribute(XML_NAMESPACE_CALC_EXT, XML_TYPE, 
XML_AVERAGE);
+break;
+case sc::AGGREGATE_FUNCTION::MIN:
+AddAttribute(XML_NA

File Handling in Calc

2018-03-18 Thread Vikas Mahato
Hello Developers,

Can you please provide me a link to documentation or code snippets
regarding file handling (opening, saving and closing files in ODS format)
in Calc?

Thanks,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


willing to contribute

2020-11-07 Thread Vikas Bhagath
Hello There        I Am Vikasbhagath A student parsuring Bachelor of Engineering And I have pretty good experience with Android Application Development With skill Android Studio,Java,Firebase,Node.js,Mongo Db And more I wanted To Use Get Some Industry Experience And Realtime work Experience So Would You Able To Give A Chance To Contributing In Your Organization Thank YouRegrad”sVikas Bhagath
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


UX for data transformations for Calc

2021-03-18 Thread Vikas Mahato
Hi,

I had implemented a bunch of Data transformations for Calc as part of Gsoc
2018 a complete list of which can be found in this blog post along with the
gerrit links.

http://gettingstartedwithlibreoffice.blogspot.com/2018/08/added-data-tranformations.html

I had a discussion with Markus about trying to make it available to users
of Libreoffice and so we want to make all transformations accessible from
the UI through a shared menu entry.

Any input from the UX team on how this can be done would be greatly helpful.

Regards,
Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice


External Data Source in Calc

2021-03-08 Thread Vikas Mahato
Hi,

I wanted to continue with working on External data source in calc (I worked
on it in 2018 as part of Gsoc). It seems the UI has changed quite a bit.
The dropdown for selecting the data source (CSV,HTML, etc) is not longer
there. Reader thread in sc/source/ui/docshell/datastream.cxx launches the
CSVHandler only. What did I miss?


Regards,

Vikas Mahato
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice