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

2014-02-17 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |   64 ++
 sc/source/ui/undo/undoblk.cxx |5 ++-
 2 files changed, 57 insertions(+), 12 deletions(-)

New commits:
commit 9e49b6abe7cedd2ac7137170f76ec5d7e14bd295
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Feb 17 12:20:57 2014 -0500

fdo#75032: Skip notes when copying values from undo document.

Notes undo redo are handled separately by the drawing layer.

Change-Id: Iae37ac86889d7a25f25e6dd0b69f724107c6798a

diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 2b30fed..694e171 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -414,8 +414,11 @@ void ScUndoDeleteCells::DoChange( const sal_Bool bUndo )
 // if Undo, restore references
 for( i=0; inCount  bUndo; i++ )
 {
+// Cell note objects are handled separately.  Ignore them here.
+sal_uInt16 nFlags = IDF_ALL;
+nFlags = ~IDF_NOTE;
 pRefUndoDoc-CopyToDocument( aEffRange.aStart.Col(), 
aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Col(), aEffRange.aEnd.Row(), 
pTabs[i]+pScenarios[i],
-IDF_ALL | IDF_NOCAPTIONS, false, pDoc );
+nFlags, false, pDoc );
 }
 
 ScRange aWorkRange( aEffRange );
commit 6a5df6427913af1df99e770ea68daaa02e7c
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Feb 17 11:38:35 2014 -0500

fdo#75032: Add a test case to reproduce the crash.

Change-Id: I1bb980e9872515a8684014a0e0be9fd4c717f9fd

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a8ec5e2..67c6e8a 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4885,30 +4885,72 @@ void Test::testNoteBasic()
 
 void Test::testNoteDeleteRow()
 {
-ScDocument* pDoc = getDocShell().GetDocument();
 OUString aSheet1(Sheet1);
-pDoc-InsertTab(0, aSheet1);
+m_pDoc-InsertTab(0, aSheet1);
+
+// We need a drawing layer in order to create caption objects.
+m_pDoc-InitDrawLayer(getDocShell());
 
 OUString aHello(Hello);
 OUString aJimBob(Jim Bob);
-ScAddress rAddr(1, 1, 0);
-ScPostIt* pNote = m_pDoc-GetOrCreateNote(rAddr);
-pNote-SetText(rAddr, aHello);
+ScAddress aPos(1, 1, 0);
+ScPostIt* pNote = m_pDoc-GetOrCreateNote(aPos);
+pNote-SetText(aPos, aHello);
 pNote-SetAuthor(aJimBob);
 
-CPPUNIT_ASSERT_MESSAGE(there should be a note, pDoc-HasNote(1, 1, 0));
+CPPUNIT_ASSERT_MESSAGE(there should be a note, m_pDoc-HasNote(1, 1, 0));
 
 // test with IsBlockEmpty
 bool bIgnoreNotes = true;
-CPPUNIT_ASSERT_MESSAGE(The Block should be detected as empty (no Notes), 
pDoc-IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
+CPPUNIT_ASSERT_MESSAGE(The Block should be detected as empty (no Notes), 
m_pDoc-IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
 bIgnoreNotes = false;
-CPPUNIT_ASSERT_MESSAGE(The Block should NOT be detected as empty, 
!pDoc-IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
+CPPUNIT_ASSERT_MESSAGE(The Block should NOT be detected as empty, 
!m_pDoc-IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
 
-pDoc-DeleteRow(0, 0, MAXCOL, 0, 1, 1);
+m_pDoc-DeleteRow(0, 0, MAXCOL, 0, 1, 1);
 
-CPPUNIT_ASSERT_MESSAGE(there should be no more note, !pDoc-HasNote(1, 
1, 0));
+CPPUNIT_ASSERT_MESSAGE(there should be no more note, !m_pDoc-HasNote(1, 
1, 0));
 
-pDoc-DeleteTab(0);
+// Set values and notes into B3:B4.
+aPos = ScAddress(1,2,0); // B3
+m_pDoc-SetString(aPos, First);
+ScNoteUtil::CreateNoteFromString(*m_pDoc, aPos, First Note, false, 
false);
+
+aPos = ScAddress(1,3,0); // B4
+m_pDoc-SetString(aPos, Second);
+ScNoteUtil::CreateNoteFromString(*m_pDoc, aPos, Second Note, false, 
false);
+
+ScDocFunc rDocFunc = getDocShell().GetDocFunc();
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+rDocFunc.DeleteCells(ScRange(0,1,0,MAXCOL,1,0), aMark, DEL_CELLSUP, true, 
true);
+
+// Check to make sure the notes have shifted upward.
+pNote = m_pDoc-GetNote(ScAddress(1,1,0));
+CPPUNIT_ASSERT_MESSAGE(B2 should have a note., pNote);
+CPPUNIT_ASSERT_EQUAL(OUString(First Note), pNote-GetText());
+pNote = m_pDoc-GetNote(ScAddress(1,2,0));
+CPPUNIT_ASSERT_MESSAGE(B3 should have a note., pNote);
+CPPUNIT_ASSERT_EQUAL(OUString(Second Note), pNote-GetText());
+pNote = m_pDoc-GetNote(ScAddress(1,3,0));
+CPPUNIT_ASSERT_MESSAGE(B4 should NOT have a note., !pNote);
+
+// Undo.
+
+SfxUndoManager* pUndoMgr = m_pDoc-GetUndoManager();
+CPPUNIT_ASSERT_MESSAGE(Failed to get undo manager., pUndoMgr);
+m_pDoc-CreateAllNoteCaptions(); // to make sure that all notes have their 
corresponding caption objects...
+
+pUndoMgr-Undo();
+pNote = m_pDoc-GetNote(ScAddress(1,1,0));
+CPPUNIT_ASSERT_MESSAGE(B2 should NOT have a note., !pNote);
+pNote = m_pDoc-GetNote(ScAddress(1,2,0));
+CPPUNIT_ASSERT_MESSAGE(B3 should have a note., 

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

2014-02-17 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|  161 +++-
 sc/source/core/data/column3.cxx |2 
 2 files changed, 142 insertions(+), 21 deletions(-)

New commits:
commit 2f55cee39379a76920f3a4fb14e6c2774093bfcd
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Feb 17 19:45:06 2014 -0500

fdo#74573: Skip removing of cell notes on empty cells if the flag is set.

Change-Id: I0d9cb5b48c5fdf51cf290cd838f5d6d7cb572e8b

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 7da6860..5bc149b 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -736,7 +736,7 @@ public:
 
 if (node.type == sc::element_type_empty)
 {
-if (bCopyCellNotes)
+if (bCopyCellNotes  !mrCxt.isSkipAttrForEmptyCells())
 {
 bool bCloneCaption = (nFlags  IDF_NOCAPTIONS) == 0;
 duplicateNotes(nSrcRow1, nDataSize, bCloneCaption );
commit d2a80bcd494039bcb54693a8461d1645e51d1c1b
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Feb 17 16:01:48 2014 -0500

fdo#74573: Test pasting of cell attributes as well.

Change-Id: Ib38ac054b40ac21dd4b6088fafca33566d2fc436

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 67c6e8a..14dffd9 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -57,6 +57,8 @@
 #include impex.hxx
 #include columnspanset.hxx
 #include docoptio.hxx
+#include patattr.hxx
+#include docpool.hxx
 
 #include formula/IFunctionDescription.hxx
 
@@ -3688,7 +3690,75 @@ void Test::testCopyPasteTranspose()
 
 void Test::testCopyPasteSkipEmpty()
 {
+struct Check
+{
+const char* mpStr;
+Color maColor;
+bool mbHasNote;
+};
+
+struct Test
+{
+ScDocument* mpDoc;
+
+Test( ScDocument* pDoc ) : mpDoc(pDoc) {}
+
+bool checkRange( const ScAddress rPos, const Check* p, const Check* 
pEnd )
+{
+ScAddress aPos(rPos);
+OUString aPosStr = aPos.Format(SCA_VALID);
+for (; p != pEnd; ++p, aPos.IncRow())
+{
+if (!mpDoc-GetString(aPos).equalsAscii(p-mpStr))
+{
+cerr  aPosStr  : incorrect string value: expected=' 
 p-mpStr  ' actual='  mpDoc-GetString(aPos)  endl;
+return false;
+}
+
+const SvxBrushItem* pBrush =
+dynamic_castconst SvxBrushItem*(mpDoc-GetAttr(aPos, 
ATTR_BACKGROUND));
+
+if (!pBrush)
+{
+cerr  aPosStr  : failed to get brush item from the 
cell.  endl;
+return false;
+}
+
+if (pBrush-GetColor() != p-maColor)
+{
+Color aExpected = p-maColor;
+Color aActual = pBrush-GetColor();
+cerr  aPosStr  : incorrect cell background color: 
expected=(
+ static_castint(aExpected.GetRed())  ,
+ static_castint(aExpected.GetGreen())  ,
+ static_castint(aExpected.GetBlue())  ), 
actual=(
+ static_castint(aActual.GetRed())  ,
+ static_castint(aActual.GetGreen())  ,
+ static_castint(aActual.GetBlue())  )  endl;
+
+return false;
+}
+
+bool bHasNote = mpDoc-HasNote(aPos);
+if (bHasNote != p-mbHasNote)
+{
+cerr  aPosStr  : ;
+if (p-mbHasNote)
+cerr  this cell should have a cell note, but 
doesn't.  endl;
+else
+cerr  this cell should NOT have a cell note, but 
one is found.  endl;
+
+return false;
+}
+}
+
+return true;
+}
+
+} aTest(m_pDoc);
+
 m_pDoc-InsertTab(0, Test);
+m_pDoc-InitDrawLayer(getDocShell()); // for cell note objects.
 
 ScRange aSrcRange(0,0,0,0,4,0);
 ScRange aDestRange(1,0,0,1,4,0);
@@ -3696,13 +3766,25 @@ void Test::testCopyPasteSkipEmpty()
 ScMarkData aMark;
 aMark.SetMarkArea(aDestRange);
 
-// Put some texts in A1:A5.
+// Put some texts in B1:B5.
 m_pDoc-SetString(ScAddress(1,0,0), A);
 m_pDoc-SetString(ScAddress(1,1,0), B);
 m_pDoc-SetString(ScAddress(1,2,0), C);
 m_pDoc-SetString(ScAddress(1,3,0), D);
 m_pDoc-SetString(ScAddress(1,4,0), E);
 
+// Set the background color of B1:B5 to blue.
+ScPatternAttr aCellBackColor(m_pDoc-GetPool());
+aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
+m_pDoc-ApplyPatternAreaTab(1, 0, 1, 4, 0, aCellBackColor);
+
+// Insert notes to B1:B5.
+m_pDoc-GetOrCreateNote(ScAddress(1,0,0));
+m_pDoc-GetOrCreateNote(ScAddress(1,1,0));
+

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

2014-02-14 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |   28 
 sc/qa/unit/ucalc.hxx  |3 +++
 sc/source/core/tool/token.cxx |3 +++
 3 files changed, 34 insertions(+)

New commits:
commit 9bf907a8278cecd816368db7b8c4ab745a914a59
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 14 20:39:18 2014 -0500

fdo#72691: Allow overwriting of string value with numeric one.

This can legitimately happen when you have a matrix with a reference to
another cell inside, and the referenced cell originally contained a
string value then later overwritten by a numeric value.

Example.  Put a Text in A1, and in B1 put a 1x1 matrix {=A1}.  It
displays Text in B1.  Then put 11 in A1.  Prior to this change, B1
would become blank.  With this change, B1 will display 11.

Change-Id: I3feba3a8658e1a5ebf6f9e5ac34de2d579464ddb

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6bb060b..769b886 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1146,6 +1146,9 @@ void ScMatrixFormulaCellToken::SetUpperLeftDouble( double 
f )
 case svDouble:
 
const_castFormulaToken*(xUpperLeft.get())-GetDoubleAsReference() = f;
 break;
+case svString:
+xUpperLeft = new FormulaDoubleToken( f);
+break;
 case svUnknown:
 if (!xUpperLeft)
 {
commit 1ffec457c86df0906b358ac431ffdb5d1d47de8c
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 14 15:15:45 2014 -0500

fdo#72691: Write unit test for this.

One tricky bit was that in order to reproduce the bug in the unit test,
formula cell's bChanged flag needed to be cleared after each update,
because that's what happens when you display updated formula on screen.  
Each
time an updated formula cell gets drawn, the UI code clears this flag.  That
same flag was used to control the code path during interpretation...

Change-Id: I2eedea3c9294f4f545422b8611840c81f8c2304f

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c06f82d..7176312 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1360,6 +1360,34 @@ void Test::testFormulaDepTracking2()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFormulaDepTrackingMatrix()
+{
+m_pDoc-InsertTab(0, Test);
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+// Set a numeric value to A1.
+m_pDoc-SetValue(ScAddress(0,0,0), 11.0);
+
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc-InsertMatrixFormula(1, 0, 1, 0, aMark, =A1, NULL);
+CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc-GetValue(ScAddress(1,0,0)));
+ScFormulaCell* pFC = m_pDoc-GetFormulaCell(ScAddress(1,0,0));
+CPPUNIT_ASSERT_MESSAGE(Failed to get formula cell., pFC);
+pFC-SetChanged(false); // Clear this flag to simulate displaying of 
formula cell value on screen.
+
+m_pDoc-SetString(ScAddress(0,0,0), ABC);
+CPPUNIT_ASSERT_EQUAL(OUString(ABC), m_pDoc-GetString(ScAddress(1,0,0)));
+pFC-SetChanged(false);
+
+// Put a new value into A1. The formula should update.
+m_pDoc-SetValue(ScAddress(0,0,0), 13.0);
+CPPUNIT_ASSERT_EQUAL(13.0, m_pDoc-GetValue(ScAddress(1,0,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 namespace {
 
 bool broadcasterShifted(const ScDocument rDoc, const ScAddress rFrom, const 
ScAddress rTo)
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f94ac91..9f6dc32 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -150,6 +150,8 @@ public:
  */
 void testFormulaDepTracking2();
 
+void testFormulaDepTrackingMatrix();
+
 /**
  * More direct test for cell broadcaster management, used to track formula
  * dependencies.
@@ -370,6 +372,7 @@ public:
 CPPUNIT_TEST(testValueIterator);
 CPPUNIT_TEST(testFormulaDepTracking);
 CPPUNIT_TEST(testFormulaDepTracking2);
+CPPUNIT_TEST(testFormulaDepTrackingMatrix);
 CPPUNIT_TEST(testCellBroadcaster);
 CPPUNIT_TEST(testFuncParam);
 CPPUNIT_TEST(testNamedRange);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   46 -
 sc/qa/unit/ucalc.hxx   |2 +
 sc/source/ui/undo/undoblk3.cxx |1 
 3 files changed, 48 insertions(+), 1 deletion(-)

New commits:
commit 182ac74065d8724bf74003cb72928b2cfa7388e9
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Feb 11 01:08:15 2014 -0500

fdo#74014: Broadcast here

Change-Id: Ib3c1e6b18af2c96c8c38237ab65f868ffec5f139

diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 95949b8..5c44dd8 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -142,6 +142,7 @@ void ScUndoDeleteContents::DoChange( const sal_Bool bUndo )
 aCopyRange.aEnd.SetTab(nTabCount-1);
 
 pUndoDoc-CopyToDocument( aCopyRange, nUndoFlags, bMulti, pDoc, 
aMarkData );
+BroadcastChanges(aCopyRange);
 
 DoSdrUndoAction( pDrawUndo, pDoc );
 
commit aa03bdcb5216ff82de22fc02ffa0746902f64972
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Tue Feb 11 01:07:00 2014 -0500

fdo#74014: Additional test.

Though this one passes in unit test, but fails in real life session.  No
idea why.

Change-Id: I657ed5aa8b1aa0046458d26badf3cb22e3778d41

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index fc539d9..c06f82d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5422,7 +5422,7 @@ void Test::testImportStream()
 
 m_pDoc-InsertTab(0, Test);
 
-m_pDoc-SetString(ScAddress(0,1,0), =SUM(A1:C1));
+m_pDoc-SetString(ScAddress(0,1,0), =SUM(A1:C1)); // A2
 
 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc-GetValue(ScAddress(0,1,0)));
 
@@ -5430,6 +5430,7 @@ void Test::testImportStream()
 ScAsciiOptions aOpt;
 aOpt.SetFieldSeps(,);
 
+// Import values to A1:C1.
 ScImportExport aObj(m_pDoc, ScAddress(0,0,0));
 aObj.SetImportBroadcast(true);
 aObj.SetExtOptions(aOpt);
@@ -5463,6 +5464,49 @@ void Test::testImportStream()
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc-GetValue(ScAddress(0,1,0))); // formula
 
 pUndoMgr-Clear();
+
+m_pDoc-DeleteTab(0);
+}
+
+void Test::testDeleteContents()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+sc::UndoSwitch aUndoSwitch(*m_pDoc, true); // enable undo.
+
+m_pDoc-InsertTab(0, Test);
+
+m_pDoc-SetValue(ScAddress(3,1,0), 1.0);
+m_pDoc-SetValue(ScAddress(3,2,0), 1.0);
+m_pDoc-SetValue(ScAddress(3,3,0), 1.0);
+m_pDoc-SetValue(ScAddress(3,4,0), 1.0);
+m_pDoc-SetValue(ScAddress(3,5,0), 1.0);
+m_pDoc-SetValue(ScAddress(3,6,0), 1.0);
+m_pDoc-SetValue(ScAddress(3,7,0), 1.0);
+m_pDoc-SetValue(ScAddress(3,8,0), 1.0);
+m_pDoc-SetString(ScAddress(3,15,0), =SUM(D2:D15));
+
+CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc-GetValue(ScAddress(3,15,0))); // formula
+
+// Delete D2:D6.
+ScRange aRange(3,1,0,3,5,0);
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+aMark.SetMarkArea(aRange);
+
+ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+pUndoDoc-InitUndo(m_pDoc, 0, 0);
+m_pDoc-CopyToDocument(aRange, IDF_CONTENTS, false, pUndoDoc, aMark);
+ScUndoDeleteContents aUndo(getDocShell(), aMark, aRange, pUndoDoc, false, 
IDF_CONTENTS, true);
+
+clearRange(m_pDoc, aRange);
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc-GetValue(ScAddress(3,15,0))); // formula
+
+aUndo.Undo();
+CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc-GetValue(ScAddress(3,15,0))); // formula
+
+aUndo.Redo();
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc-GetValue(ScAddress(3,15,0))); // formula
+
 m_pDoc-DeleteTab(0);
 }
 
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 64fde25..f94ac91 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -316,6 +316,7 @@ public:
 void testCondCopyPaste();
 
 void testImportStream();
+void testDeleteContents();
 void testTransliterateText();
 
 void testColumnFindEditCells();
@@ -448,6 +449,7 @@ public:
 CPPUNIT_TEST(testCondFormatInsertCol);
 CPPUNIT_TEST(testCondCopyPaste);
 CPPUNIT_TEST(testImportStream);
+CPPUNIT_TEST(testDeleteContents);
 CPPUNIT_TEST(testTransliterateText);
 CPPUNIT_TEST(testColumnFindEditCells);
 CPPUNIT_TEST_SUITE_END();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   25 +
 sc/source/core/tool/scmatrix.cxx |   11 ++-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 295869ce95c00a0e0b192ea6bf62753f91badaf2
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Feb 9 11:34:11 2014 -0500

fdo#74479: Treat empty cells as if they have a value of 0.

Change-Id: I3701848016c230138e8791f683a2c8b97219198d

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 74f7fa3..090cada 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1612,7 +1612,16 @@ public:
 }
 break;
 case mdds::mtm::element_empty:
-std::advance(miPos, node.size);
+{
+// Empty element is equivalent of having a numeric value of 
0.0.
+for (size_t i = 0; i  node.size; ++i, ++miPos)
+{
+if (rtl::math::isNan(*miPos))
+continue;
+
+*miPos = op(*miPos, 0.0);
+}
+}
 default:
 ;
 }
commit 71fe47cfe652829ff7dc09ae49b1c6c22d9b6a6d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Feb 9 11:10:34 2014 -0500

fdo#74479: Test case for SUMPRODUCT.

Change-Id: I2e8669c1cd6c824751d557c7c9ee735d580f17e9

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 053e607..a32b048 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -115,6 +115,7 @@ public:
 void testFuncROW();
 void testFuncSUM();
 void testFuncPRODUCT();
+void testFuncSUMPRODUCT();
 void testFuncN();
 void testFuncCOUNTIF();
 void testFuncNUMBERVALUE();
@@ -347,6 +348,7 @@ public:
 CPPUNIT_TEST(testFuncROW);
 CPPUNIT_TEST(testFuncSUM);
 CPPUNIT_TEST(testFuncPRODUCT);
+CPPUNIT_TEST(testFuncSUMPRODUCT);
 CPPUNIT_TEST(testFuncN);
 CPPUNIT_TEST(testFuncCOUNTIF);
 CPPUNIT_TEST(testFuncNUMBERVALUE);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 05ff6b6..a4b6289 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1790,6 +1790,31 @@ void Test::testFuncPRODUCT()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testFuncSUMPRODUCT()
+{
+m_pDoc-InsertTab(0, Test);
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
+
+ScAddress aPos(0,0,0);
+m_pDoc-SetString(aPos, =SUMPRODUCT(B1:B3;C1:C3));
+CPPUNIT_ASSERT_EQUAL(0.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(2,0,0),  1.0); // C1
+CPPUNIT_ASSERT_EQUAL(0.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(1,0,0),  1.0); // B1
+CPPUNIT_ASSERT_EQUAL(1.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(1,1,0),  2.0); // B2
+CPPUNIT_ASSERT_EQUAL(1.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(2,1,0),  3.0); // C2
+CPPUNIT_ASSERT_EQUAL(7.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(2,2,0), -2.0); // C3
+CPPUNIT_ASSERT_EQUAL(7.0,  m_pDoc-GetValue(aPos));
+m_pDoc-SetValue(ScAddress(1,2,0),  5.0); // B3
+CPPUNIT_ASSERT_EQUAL(-3.0, m_pDoc-GetValue(aPos));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFuncN()
 {
 OUString aTabName(foo);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   25 +
 sc/qa/unit/ucalc.hxx   |2 ++
 sc/source/core/data/table1.cxx |2 +-
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit b6378a1651e7157063746d7001ef566545338bd0
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Feb 9 22:10:24 2014 -0500

fdo#74323: The end position is inclusive.

Change-Id: Ibd0ff19d7fd2de72a3b8d790a371da4b23df38c8

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 5291ad2..b3385a3 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1428,7 +1428,7 @@ bool ScTable::GetNextMarkedCell( SCCOL rCol, SCROW 
rRow, const ScMarkData rMa
 }
 }
 
-if (nTestRow  nEnd)
+if (nTestRow = nEnd)
 {
 // Cell found.
 rRow = nTestRow;
commit e041a1bfef98b54656cfaafcb0f586867a21edf1
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Feb 9 21:58:55 2014 -0500

fdo#74323: Add unit test for changing cases of text cells.

Change-Id: I858e18a03d97434275676e771d91bdf3209f63fb

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 83498b3..5ae240f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -80,6 +80,8 @@
 #include sstream
 #include vector
 
+#include com/sun/star/i18n/TransliterationModules.hpp
+
 struct TestImpl
 {
 ScDocShellRef m_xDocShell;
@@ -5464,6 +5466,29 @@ void Test::testImportStream()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testTransliterateText()
+{
+m_pDoc-InsertTab(0, Test);
+
+// Set texts to A1:A3.
+m_pDoc-SetString(ScAddress(0,0,0), Mike);
+m_pDoc-SetString(ScAddress(0,1,0), Noah);
+m_pDoc-SetString(ScAddress(0,2,0), Oscar);
+
+// Change them to uppercase.
+ScMarkData aMark;
+aMark.SetMarkArea(ScRange(0,0,0,0,2,0));
+ScDocFunc rFunc = getDocShell().GetDocFunc();
+rFunc.TransliterateText(
+aMark, i18n::TransliterationModules_LOWERCASE_UPPERCASE, true, true);
+
+CPPUNIT_ASSERT_EQUAL(OUString(MIKE), 
m_pDoc-GetString(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(OUString(NOAH), 
m_pDoc-GetString(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(OUString(OSCAR), 
m_pDoc-GetString(ScAddress(0,2,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testMixData()
 {
 m_pDoc-InsertTab(0, Test);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index a32b048..64fde25 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -316,6 +316,7 @@ public:
 void testCondCopyPaste();
 
 void testImportStream();
+void testTransliterateText();
 
 void testColumnFindEditCells();
 
@@ -447,6 +448,7 @@ public:
 CPPUNIT_TEST(testCondFormatInsertCol);
 CPPUNIT_TEST(testCondCopyPaste);
 CPPUNIT_TEST(testImportStream);
+CPPUNIT_TEST(testTransliterateText);
 CPPUNIT_TEST(testColumnFindEditCells);
 CPPUNIT_TEST_SUITE_END();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   33 +
 sc/source/core/data/column.cxx |2 +-
 2 files changed, 30 insertions(+), 5 deletions(-)

New commits:
commit 1e3ef350d730bc54a3e9c393c2df6fd1f839a3a8
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 09:42:46 2014 -0500

fdo#74414: No need to incremenet nRow here... It's just plain wrong.

Change-Id: Iecdbb3eba46ddf2f2bc4f2334c7d45a4e2d801c8

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 7d10c20..8e3d365 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1928,7 +1928,7 @@ public:
 
 std::vectorEditTextObject* aCloned;
 aCloned.reserve(nDataSize);
-for (; it != itEnd; ++it, ++nRow)
+for (; it != itEnd; ++it)
 aCloned.push_back(ScEditUtil::Clone(**it, 
mrDestCol.GetDoc()));
 
 maDestPos.miCellPos = mrDestCol.GetCellStore().set(
commit 22cdd528d26d9e332df72135394f8d57bf227d03
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 09:35:11 2014 -0500

fdo#74414: Add a bit more check in existing test to catch this.

Change-Id: I4ab844fe686e8c38968c34305936907380a1fe7b

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b91255e..83498b3 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2042,15 +2042,27 @@ void Test::testCellCopy()
 void Test::testSheetCopy()
 {
 m_pDoc-InsertTab(0, TestTab);
-m_pDoc-SetString(ScAddress(0,0,0), copy me);
 CPPUNIT_ASSERT_MESSAGE(document should have one sheet to begin with., 
m_pDoc-GetTableCount() == 1);
+
+// Insert text in A1.
+m_pDoc-SetString(ScAddress(0,0,0), copy me);
+
+// Insert edit cells in B1:B3.
+ScFieldEditEngine rEE = m_pDoc-GetEditEngine();
+rEE.SetText(Edit 1);
+m_pDoc-SetEditText(ScAddress(1,0,0), rEE.CreateTextObject());
+rEE.SetText(Edit 2);
+m_pDoc-SetEditText(ScAddress(1,1,0), rEE.CreateTextObject());
+rEE.SetText(Edit 3);
+m_pDoc-SetEditText(ScAddress(1,2,0), rEE.CreateTextObject());
+
 SCROW nRow1, nRow2;
 bool bHidden = m_pDoc-RowHidden(0, 0, nRow1, nRow2);
 CPPUNIT_ASSERT_MESSAGE(new sheet should have all rows visible, !bHidden 
 nRow1 == 0  nRow2 == MAXROW);
 
 // insert a note
-ScAddress aAdrA1 (0, 0, 0); // empty cell content
-OUString aHelloA1(Hello world in A1);
+ScAddress aAdrA1 (0,2,0); // empty cell content.
+OUString aHelloA1(Hello world in A3);
 ScPostIt *pNoteA1 = m_pDoc-GetOrCreateNote(aAdrA1);
 pNoteA1-SetText(aAdrA1, aHelloA1);
 
@@ -2059,7 +2071,20 @@ void Test::testSheetCopy()
 CPPUNIT_ASSERT_MESSAGE(document now should have two sheets., 
m_pDoc-GetTableCount() == 2);
 bHidden = m_pDoc-RowHidden(0, 1, nRow1, nRow2);
 CPPUNIT_ASSERT_MESSAGE(copied sheet should also have all rows visible as 
the original., !bHidden  nRow1 == 0  nRow2 == MAXROW);
-CPPUNIT_ASSERT_MESSAGE(There should be note on A1 in new sheet, 
m_pDoc-HasNote(ScAddress (0, 0, 1)));
+CPPUNIT_ASSERT_MESSAGE(There should be note on A3 in new sheet, 
m_pDoc-HasNote(ScAddress(0,2,1)));
+CPPUNIT_ASSERT_EQUAL(OUString(copy me), 
m_pDoc-GetString(ScAddress(0,0,1)));
+
+// Check the copied edit cells.
+const EditTextObject* pEditObj = m_pDoc-GetEditText(ScAddress(1,0,1));
+CPPUNIT_ASSERT_MESSAGE(There should be an edit cell in B1., pEditObj);
+CPPUNIT_ASSERT_EQUAL(OUString(Edit 1), pEditObj-GetText(0));
+pEditObj = m_pDoc-GetEditText(ScAddress(1,1,1));
+CPPUNIT_ASSERT_MESSAGE(There should be an edit cell in B2., pEditObj);
+CPPUNIT_ASSERT_EQUAL(OUString(Edit 2), pEditObj-GetText(0));
+pEditObj = m_pDoc-GetEditText(ScAddress(1,2,1));
+CPPUNIT_ASSERT_MESSAGE(There should be an edit cell in B3., pEditObj);
+CPPUNIT_ASSERT_EQUAL(OUString(Edit 3), pEditObj-GetText(0));
+
 m_pDoc-DeleteTab(1);
 
 m_pDoc-SetRowHidden(5, 10, 0, true);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/data/ods/notes-on-3-sheets.ods |binary
 sc/qa/unit/subsequent_export-test.cxx |   45 ++
 sc/source/filter/excel/excdoc.cxx |5 +++
 3 files changed, 50 insertions(+)

New commits:
commit 771b9d2718f28beedbc1a913e8965cdd1fc75a88
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 11:37:46 2014 -0500

fdo#74521: Only pick cell notes for that sheet, and skip the rest.

Change-Id: I06a069e835eb7f2f90d34f4fcdfd935aff0234de

diff --git a/sc/source/filter/excel/excdoc.cxx 
b/sc/source/filter/excel/excdoc.cxx
index a8bfbf7..9cf433d 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -421,7 +421,12 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
 rDoc.GetAllNoteEntries(aNotes);
 std::vectorsc::NoteEntry::const_iterator it = aNotes.begin(), itEnd = 
aNotes.end();
 for (; it != itEnd; ++it)
+{
+if (it-maPos.Tab() != mnScTab)
+continue;
+
 mxNoteList-AppendNewRecord(new XclExpNote(GetRoot(), it-maPos, 
it-mpNote, OUString()));
+}
 
 if( GetOutput() != EXC_OUTPUT_BINARY )
 {
commit 7d71fd489c39f348c43477cafdc1bc150bf1ff68
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 10:46:47 2014 -0500

fdo#74521: Write unit test for this first.

Change-Id: I1815464e25703f1b0181211ac74341edb41793be

diff --git a/sc/qa/unit/data/ods/notes-on-3-sheets.ods 
b/sc/qa/unit/data/ods/notes-on-3-sheets.ods
new file mode 100644
index 000..e7b6399
Binary files /dev/null and b/sc/qa/unit/data/ods/notes-on-3-sheets.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 47278e0..2db6307 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -70,6 +70,7 @@ public:
 
 void testCellValuesExportODS();
 void testCellNoteExportODS();
+void testCellNoteExportXLS();
 void testFormatExportODS();
 
 void testInlineArrayXLS();
@@ -91,6 +92,7 @@ public:
 CPPUNIT_TEST(testRichTextExportODS);
 CPPUNIT_TEST(testCellValuesExportODS);
 CPPUNIT_TEST(testCellNoteExportODS);
+CPPUNIT_TEST(testCellNoteExportXLS);
 CPPUNIT_TEST(testFormatExportODS);
 CPPUNIT_TEST(testInlineArrayXLS);
 CPPUNIT_TEST(testEmbeddedChartXLS);
@@ -775,6 +777,49 @@ void ScExportTest::testCellNoteExportODS()
 xNewDocSh-DoClose();
 }
 
+void ScExportTest::testCellNoteExportXLS()
+{
+// Start with an empty document.s
+ScDocShellRef xOrigDocSh = loadDoc(notes-on-3-sheets., ODS);
+ScDocument* pDoc = xOrigDocSh-GetDocument();
+CPPUNIT_ASSERT_MESSAGE(This document should have 3 sheets., 
pDoc-GetTableCount() == 3);
+
+// Check note's presence.
+CPPUNIT_ASSERT( pDoc-HasNote(ScAddress(0,0,0)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,1,0)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,2,0)));
+
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,0,1)));
+CPPUNIT_ASSERT( pDoc-HasNote(ScAddress(0,1,1)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,2,1)));
+
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,0,2)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,1,2)));
+CPPUNIT_ASSERT( pDoc-HasNote(ScAddress(0,2,2)));
+
+// save and reload as XLS.
+ScDocShellRef xNewDocSh = saveAndReload(xOrigDocSh, XLS);
+xOrigDocSh-DoClose();
+CPPUNIT_ASSERT(xNewDocSh.Is());
+pDoc = xNewDocSh-GetDocument();
+CPPUNIT_ASSERT_MESSAGE(This document should have 3 sheets., 
pDoc-GetTableCount() == 3);
+
+// Check note's presence again.
+CPPUNIT_ASSERT( pDoc-HasNote(ScAddress(0,0,0)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,1,0)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,2,0)));
+
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,0,1)));
+CPPUNIT_ASSERT( pDoc-HasNote(ScAddress(0,1,1)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,2,1)));
+
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,0,2)));
+CPPUNIT_ASSERT(!pDoc-HasNote(ScAddress(0,1,2)));
+CPPUNIT_ASSERT( pDoc-HasNote(ScAddress(0,2,2)));
+
+xNewDocSh-DoClose();
+}
+
 namespace {
 
 void checkMatrixRange(ScDocument rDoc, const ScRange rRange)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx|2 +
 sc/qa/unit/ucalc_sharedformula.cxx  |   39 
 sc/source/core/data/formulacell.cxx |8 +++
 3 files changed, 49 insertions(+)

New commits:
commit 1556dbc451f067d8744378fb9bac0eaa7ef8f5ac
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 15:13:18 2014 -0500

fdo#74453: Only adjust tokens for top formula cells of formula group.

Change-Id: Id04387dffac271b3d617da0fbc19c862c929d60a

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index a1e9ec1..88ca441 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3023,6 +3023,10 @@ void ScFormulaCell::UpdateInsertTabAbs(SCTAB nTable)
 if (pDocument-IsClipOrUndo())
 return;
 
+bool bAdjustCode = !mxGroup || mxGroup-mpTopCell == this;
+if (!bAdjustCode)
+return;
+
 pCode-Reset();
 ScToken* p = static_castScToken*(pCode-GetNextReferenceRPN());
 while (p)
@@ -3045,6 +3049,10 @@ bool ScFormulaCell::TestTabRefAbs(SCTAB nTable)
 if (pDocument-IsClipOrUndo())
 return false;
 
+bool bAdjustCode = !mxGroup || mxGroup-mpTopCell == this;
+if (!bAdjustCode)
+return false;
+
 bool bRet = false;
 pCode-Reset();
 ScToken* p = static_castScToken*(pCode-GetNextReferenceRPN());
commit ac5682aa3013550e3643026c571b5d851b9e7b67
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 14:42:31 2014 -0500

fdo#74453: Write unit test for this.

Change-Id: Ic8cbc650d6608ff7af5d1d58deeeba409bb81725

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f595467..053e607 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -252,6 +252,7 @@ public:
 void testSharedFormulasRefUpdateRange();
 void testSharedFormulasDeleteRows();
 void testSharedFormulasRefUpdateMoveSheets();
+void testSharedFormulasRefUpdateCopySheets();
 void testSharedFormulasCopyPaste();
 void testSharedFormulaInsertColumn();
 void testFormulaPosition();
@@ -414,6 +415,7 @@ public:
 CPPUNIT_TEST(testSharedFormulasRefUpdateRange);
 CPPUNIT_TEST(testSharedFormulasDeleteRows);
 CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets);
+CPPUNIT_TEST(testSharedFormulasRefUpdateCopySheets);
 CPPUNIT_TEST(testSharedFormulasCopyPaste);
 CPPUNIT_TEST(testSharedFormulaInsertColumn);
 CPPUNIT_TEST(testFormulaPosition);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index 04e917f..a64398b 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -600,6 +600,45 @@ void Test::testSharedFormulasRefUpdateMoveSheets()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testSharedFormulasRefUpdateCopySheets()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // make sure auto calc is on.
+
+m_pDoc-InsertTab(0, Sheet1);
+m_pDoc-InsertTab(1, Sheet2);
+
+m_pDoc-SetValue(ScAddress(0,0,1), 1.0); // A1 on Sheet2
+m_pDoc-SetValue(ScAddress(0,1,1), 2.0); // A2 on Sheet2
+
+// Reference values on Sheet2, but use absolute sheet references.
+m_pDoc-SetString(ScAddress(0,0,0), =$Sheet2.A1);
+m_pDoc-SetString(ScAddress(0,1,0), =$Sheet2.A2);
+
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+
+// Copy Sheet1 and insert the copied sheet before the current Sheet1 
position.
+m_pDoc-CopyTab(0, 0);
+
+if (!checkFormula(*m_pDoc, ScAddress(0,0,0), $Sheet2.A1))
+CPPUNIT_FAIL(Wrong formula);
+
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), $Sheet2.A2))
+CPPUNIT_FAIL(Wrong formula);
+
+// Check the values on the copied sheet.
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+
+// Check the values on the original sheet.
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue(ScAddress(0,0,1)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc-GetValue(ScAddress(0,1,1)));
+
+m_pDoc-DeleteTab(2);
+m_pDoc-DeleteTab(1);
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testSharedFormulasCopyPaste()
 {
 m_pDoc-InsertTab(0, Test);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx |   20 
 sc/source/core/tool/compiler.cxx |   28 
 2 files changed, 28 insertions(+), 20 deletions(-)

New commits:
commit 83cdcdb9f0fe11309939f5dca4fb46e426559896
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 18:19:42 2014 -0500

fdo#74512: Generate escaped sheet names after the grammer is set.

Otherwise the single quote characters wouldn't be properly doubled.

Change-Id: I864ca8912a35049905e52e002d92d648e1278015

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 8c6dee9..f8d00f1 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -238,6 +238,14 @@ void ScCompiler::SetGrammar( const FormulaGrammar::Grammar 
eGrammar )
 if (eMyGrammar != GetGrammar())
 SetGrammarAndRefConvention( eMyGrammar, eOldGrammar);
 }
+
+if (pDoc  maTabNames.empty())
+{
+maTabNames = pDoc-GetAllTableNames();
+std::vectorOUString::iterator it = maTabNames.begin(), itEnd = 
maTabNames.end();
+for (; it != itEnd; ++it)
+ScCompiler::CheckTabQuotes(*it, 
formula::FormulaGrammar::extractRefConvention(meGrammar));
+}
 }
 
 void ScCompiler::SetNumberFormatter( SvNumberFormatter* pFormatter )
@@ -1546,16 +1554,6 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const 
ScAddress rPos,ScTokenArra
 mbRewind( false )
 {
 nMaxTab = pDoc ? pDoc-GetTableCount() - 1 : 0;
-
-if (pDoc)
-{
-maTabNames = pDoc-GetAllTableNames();
-{
-std::vectorOUString::iterator it = maTabNames.begin(), itEnd = 
maTabNames.end();
-for (; it != itEnd; ++it)
-ScCompiler::CheckTabQuotes(*it, 
formula::FormulaGrammar::extractRefConvention(meGrammar));
-}
-}
 }
 
 ScCompiler::ScCompiler( sc::CompileFormulaContext rCxt, const ScAddress rPos 
) :
@@ -1589,16 +1587,6 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const 
ScAddress rPos)
 mbRewind( false )
 {
 nMaxTab = pDoc ? pDoc-GetTableCount() - 1 : 0;
-
-if (pDoc)
-{
-maTabNames = pDoc-GetAllTableNames();
-{
-std::vectorOUString::iterator it = maTabNames.begin(), itEnd = 
maTabNames.end();
-for (; it != itEnd; ++it)
-ScCompiler::CheckTabQuotes(*it, 
formula::FormulaGrammar::extractRefConvention(meGrammar));
-}
-}
 }
 
 ScCompiler::~ScCompiler()
commit c4987cd730be2d4aa7c76e69fad4e3195413fb0c
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sat Feb 8 18:01:08 2014 -0500

fdo#74512: Add test for this.

Change-Id: I472a91375c6408761d9c300b3575cfe101649fca

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 411ed9e..05ff6b6 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -217,6 +217,26 @@ void Test::testFormulaParseReference()
 m_pDoc-GetName(4, aTabName);
 CPPUNIT_ASSERT_EQUAL(aTab4, aTabName);
 
+// Make sure the formula input and output match.
+{
+const char* aChecks[] = {
+'90''s Music'.B12,
+'90''s and 70''s'.$AB$100,
+'All Others'.Z$100,
+NoQuote.$C111
+};
+
+for (size_t i = 0; i  SAL_N_ELEMENTS(aChecks); ++i)
+{
+// Use the 'Dummy' sheet for this.
+OUString aInput(=);
+aInput += OUString::createFromAscii(aChecks[i]);
+m_pDoc-SetString(ScAddress(0,0,0), aInput);
+if (!checkFormula(*m_pDoc, ScAddress(0,0,0), aChecks[i]))
+CPPUNIT_FAIL(Wrong formula);
+}
+}
+
 ScAddress aPos;
 ScAddress::ExternalInfo aExtInfo;
 sal_uInt16 nRes = aPos.Parse('90''s Music'.D10, m_pDoc, 
formula::FormulaGrammar::CONV_OOO, aExtInfo);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   37 +
 sc/qa/unit/ucalc.hxx|2 ++
 sc/source/core/data/dociter.cxx |2 +-
 3 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 738bd2cfd446debbc0e08fb554276fa28c7d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 7 11:52:16 2014 -0500

fdo#74507: Ensure that we have non-null pointer to ScColumn.

Else it would cause a null pointer dereferencing when precision as shown
option is set.

Change-Id: Ie8d2fdb916b575fff7e0217c45c18a2c799577cb

diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 188a3fc..5bb9236 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -170,7 +170,7 @@ bool ScValueIterator::GetThis(double rValue, sal_uInt16 
rErr)
 bNextColumn = true;
 }
 
-ScColumn* pCol = NULL;
+ScColumn* pCol = (pDoc-maTabs[mnTab])-aCol[mnCol];
 if (bNextColumn)
 {
 // Find the next available column.
commit 6437313bdba12836d9e472654ad402601af58077
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 7 11:45:07 2014 -0500

fdo#74507: Write test for this to induce the crash during unit test run.

Change-Id: Ib25136c203f7da17a9b7f086916d870225bc729b

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 596bd92..275e4a0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -56,6 +56,7 @@
 #include asciiopt.hxx
 #include impex.hxx
 #include columnspanset.hxx
+#include docoptio.hxx
 
 #include formula/IFunctionDescription.hxx
 
@@ -1189,6 +1190,42 @@ void Test::testHorizontalIterator()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testValueIterator()
+{
+m_pDoc-InsertTab(0, Test);
+
+// Turn on precision as shown option.
+ScDocOptions aOpt = m_pDoc-GetDocOptions();
+aOpt.SetCalcAsShown(true);
+m_pDoc-SetDocOptions(aOpt);
+
+// Purely horizontal data layout with numeric data.
+for (SCCOL i = 1; i = 3; ++i)
+m_pDoc-SetValue(ScAddress(i,2,0), i);
+
+double fVal;
+sal_uInt16 nErr;
+
+{
+const double aChecks[] = { 1.0, 2.0, 3.0 };
+size_t nCheckLen = SAL_N_ELEMENTS(aChecks);
+
+ScValueIterator aIter(m_pDoc, ScRange(1,2,0,3,2,0));
+bool bHas = false;
+
+size_t nCheckPos = 0;
+for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = 
aIter.GetNext(fVal, nErr), ++nCheckPos)
+{
+CPPUNIT_ASSERT_MESSAGE(Iteration longer than expected., 
nCheckPos  nCheckLen);
+CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos], fVal);
+CPPUNIT_ASSERT_EQUAL(static_castsal_uInt16(0), nErr);
+}
+}
+
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testFormulaDepTracking()
 {
 CPPUNIT_ASSERT_MESSAGE (failed to insert sheet, m_pDoc-InsertTab (0, 
foo));
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dfa3a4b..74b79a3 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -137,6 +137,7 @@ public:
 void testVolatileFunc();
 
 void testHorizontalIterator();
+void testValueIterator();
 
 /**
  * Basic test for formula dependency tracking.
@@ -361,6 +362,7 @@ public:
 CPPUNIT_TEST(testSheetsFunc);
 CPPUNIT_TEST(testVolatileFunc);
 CPPUNIT_TEST(testHorizontalIterator);
+CPPUNIT_TEST(testValueIterator);
 CPPUNIT_TEST(testFormulaDepTracking);
 CPPUNIT_TEST(testFormulaDepTracking2);
 CPPUNIT_TEST(testCellBroadcaster);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-07 Thread Kohei Yoshida
 sc/qa/unit/data/xlsx/hyperlinks.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx   |   14 ++
 sc/source/filter/oox/worksheethelper.cxx |1 +
 3 files changed, 15 insertions(+)

New commits:
commit 10da10ee6ba37f4861045d1f8db0022293433cec
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 7 14:39:42 2014 -0500

fdo#74535: Don't forget clear the edit engine before re-using it.

Else you'd get a very comical result.

Change-Id: Ie73145dee47a8583f2e9cdb7ddb4f2d66f361dc1

diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index 47b759d..0a560d1 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -1068,6 +1068,7 @@ void WorksheetGlobals::insertHyperlink( const 
CellAddress rAddress, const OUStr
 {
 OUString aStr = aCell.getString(rDoc.getDoc());
 ScFieldEditEngine rEE = rDoc.getDoc().GetEditEngine();
+rEE.Clear();
 
 SvxURLField aURLField(rUrl, aStr, SVXURLFORMAT_REPR);
 SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
commit 36e7fca5fa87fc72cdc9315438d9437fae9aa3da
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 7 14:23:24 2014 -0500

fdo#74535: Write unit test for importing hyperlinks from xlsx.

Change-Id: I64e053106cee396a09f2a4915c19fcb1d69e5e82

diff --git a/sc/qa/unit/data/xlsx/hyperlinks.xlsx 
b/sc/qa/unit/data/xlsx/hyperlinks.xlsx
new file mode 100644
index 000..5faea7d
Binary files /dev/null and b/sc/qa/unit/data/xlsx/hyperlinks.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 448a9fa..83841b3 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -89,6 +89,7 @@ public:
 void testBasicCellContentODS();
 void testRangeNameXLS();
 void testRangeNameXLSX();
+void testHyperlinksXLSX();
 void testHardRecalcODS();
 void testFunctionsODS();
 void testFunctionsExcel2010();
@@ -164,6 +165,7 @@ public:
 CPPUNIT_TEST(testBasicCellContentODS);
 CPPUNIT_TEST(testRangeNameXLS);
 CPPUNIT_TEST(testRangeNameXLSX);
+CPPUNIT_TEST(testHyperlinksXLSX);
 CPPUNIT_TEST(testHardRecalcODS);
 CPPUNIT_TEST(testFunctionsODS);
 CPPUNIT_TEST(testFunctionsExcel2010);
@@ -342,6 +344,18 @@ void ScFiltersTest::testRangeNameXLSX()
 xDocSh-DoClose();
 }
 
+void ScFiltersTest::testHyperlinksXLSX()
+{
+ScDocShellRef xDocSh = loadDoc(hyperlinks., XLSX);
+ScDocument* pDoc = xDocSh-GetDocument();
+
+CPPUNIT_ASSERT_EQUAL(OUString(10:ABC10), 
pDoc-GetString(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(OUString(10:ABC11), 
pDoc-GetString(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(OUString(10:ABC12), 
pDoc-GetString(ScAddress(0,3,0)));
+
+xDocSh-DoClose();
+}
+
 void ScFiltersTest::testHardRecalcODS()
 {
 ScDocShellRef xDocSh = loadDoc(hard-recalc., ODS);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   52 +++-
 sc/qa/unit/ucalc.hxx|2 -
 sc/source/core/data/column3.cxx |4 ---
 3 files changed, 31 insertions(+), 27 deletions(-)

New commits:
commit 8f60dd0223f8834224b196153f0d8601403d76dc
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 7 16:02:25 2014 -0500

fdo#74273: Let's not shift the note twice. Once is enough.

The notes already are shifted at the top of the function.  We don't
need this bottom one.

Change-Id: I10858d937674e236eecbc42ee08bf6eba197755a

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ccd62e9..7da6860 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -291,10 +291,6 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 maCellTextAttrs.erase(nStartRow, nEndRow);
 maCellTextAttrs.resize(MAXROWCOUNT);
 
-// Shift the cell notes array too (before the broadcast).
-maCellNotes.erase(nStartRow, nEndRow);
-maCellNotes.resize(MAXROWCOUNT);
-
 CellStorageModified();
 
 if (!bShiftCells)
commit 06c17598fb944aebcd0ef0783d2d4a81662208bb
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Fri Feb 7 16:00:08 2014 -0500

fdo#74273: Adopt existing test to catch this.

Apparently having a non-empty cell where the note is makes the note take
a slightly different code path.

Change-Id: I23decb83eeb34ee9e16b4f56816648815f102db8

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 275e4a0..b91255e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4763,59 +4763,67 @@ void Test::testNoteBasic()
 OUString aTabName2(Table2);
 m_pDoc-InsertTab(0, aTabName);
 
-ScAddress rAddr(2, 2, 0); // cell C3
-ScPostIt *pNote = m_pDoc-GetOrCreateNote(rAddr);
+ScAddress aAddr(2, 2, 0); // cell C3
+ScPostIt *pNote = m_pDoc-GetOrCreateNote(aAddr);
 
-pNote-SetText(rAddr, aHello);
+pNote-SetText(aAddr, aHello);
 pNote-SetAuthor(aJimBob);
 
-ScPostIt *pGetNote = m_pDoc-GetNote(rAddr);
-CPPUNIT_ASSERT_MESSAGE(note should be itself, pGetNote == pNote );
+ScPostIt *pGetNote = m_pDoc-GetNote(aAddr);
+CPPUNIT_ASSERT_MESSAGE(note should be itself, pGetNote == pNote);
 
 // Insert one row at row 1.
 bool bInsertRow = m_pDoc-InsertRow(0, 0, MAXCOL, 0, 1, 1);
 CPPUNIT_ASSERT_MESSAGE(failed to insert row, bInsertRow );
 
-CPPUNIT_ASSERT_MESSAGE(note hasn't moved, m_pDoc-GetNote(rAddr) == 
NULL);
-rAddr.IncRow(); // cell C4
-CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE(note hasn't moved, m_pDoc-GetNote(aAddr) == 
NULL);
+aAddr.IncRow(); // cell C4
+CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(aAddr) == pNote);
 
 // Insert column at column A.
 bool bInsertCol = m_pDoc-InsertCol(0, 0, MAXROW, 0, 1, 1);
 CPPUNIT_ASSERT_MESSAGE(failed to insert column, bInsertCol );
 
-CPPUNIT_ASSERT_MESSAGE(note hasn't moved, m_pDoc-GetNote(rAddr) == 
NULL);
-rAddr.IncCol(); // cell D4
-CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE(note hasn't moved, m_pDoc-GetNote(aAddr) == 
NULL);
+aAddr.IncCol(); // cell D4
+CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(aAddr) == pNote);
 
 // Insert a new sheet to shift the current sheet to the right.
 m_pDoc-InsertTab(0, aTabName2);
-CPPUNIT_ASSERT_MESSAGE(note hasn't moved, m_pDoc-GetNote(rAddr) == 
NULL);
-rAddr.IncTab(); // Move to the next sheet.
-CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE(note hasn't moved, m_pDoc-GetNote(aAddr) == 
NULL);
+aAddr.IncTab(); // Move to the next sheet.
+CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(aAddr) == pNote);
 
 m_pDoc-DeleteTab(0);
-rAddr.IncTab(-1);
-CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(rAddr) == pNote);
+aAddr.IncTab(-1);
+CPPUNIT_ASSERT_MESSAGE(note not there, m_pDoc-GetNote(aAddr) == pNote);
 
 // Insert cell at C4.  This should NOT shift the note position.
 bInsertRow = m_pDoc-InsertRow(2, 0, 2, 0, 3, 1);
 CPPUNIT_ASSERT_MESSAGE(Failed to insert cell at C4., bInsertRow);
-CPPUNIT_ASSERT_MESSAGE(Note shouldn't have moved but it has., 
m_pDoc-GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE(Note shouldn't have moved but it has., 
m_pDoc-GetNote(aAddr) == pNote);
 
 // Delete cell at C4.  Again, this should NOT shift the note position.
 m_pDoc-DeleteRow(2, 0, 2, 0, 3, 1);
-CPPUNIT_ASSERT_MESSAGE(Note shouldn't have moved but it has., 
m_pDoc-GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE(Note shouldn't have moved but it has., 
m_pDoc-GetNote(aAddr) == pNote);
 
 // Now, with the note at D4, delete cell D3. This should shift the note 
one cell up.
 m_pDoc-DeleteRow(3, 

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

2014-02-06 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |   75 +++
 sc/qa/unit/ucalc.hxx |2 +
 sc/source/core/data/column3.cxx  |1 
 sc/source/core/data/document.cxx |3 +
 sc/source/ui/view/viewfun3.cxx   |3 +
 5 files changed, 81 insertions(+), 3 deletions(-)

New commits:
commit 0c12aa670b83b76241077dfb8bc21f40a55b1667
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 6 14:11:43 2014 -0500

fdo#74573: Skip deletion of destination area when 'skip empty' is on.

Also, adjust handling of mix document aka paste functions with this
change.  When using paste function (add, subtract, etc), the behavior
between the 'skip empty' flag on and off makes no difference.  Let's
set the flag to off when paste function is used.

Change-Id: I67724ba923c9260b2c14464e4123b8445712dbaf

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index fb6518e..b97e396 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -731,7 +731,6 @@ public:
 
 void operator() (const sc::CellStoreType::value_type node, size_t 
nOffset, size_t nDataSize)
 {
-
 SCROW nSrcRow1 = node.position + nOffset;
 bool bCopyCellNotes = mrCxt.isCloneNotes();
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9f5b3bb..fdbb1fa 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2690,7 +2690,8 @@ void ScDocument::CopyFromClip( const ScRange rDestRange, 
const ScMarkData rMar
 SCCOL nCol2 = pRange-aEnd.Col();
 SCROW nRow2 = pRange-aEnd.Row();
 
-DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag);
+if (!bSkipAttrForEmpty)
+DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag);
 
 if (CopyOneCellFromClip(aCxt, nCol1, nRow1, nCol2, nRow2))
 continue;
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index e501458..fd16a60 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1188,8 +1188,9 @@ bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, 
ScDocument* pClipDoc,
 //
 
 ScDocument* pMixDoc = NULL;
-if ( bSkipEmpty || nFunction )
+if (nFunction)
 {
+bSkipEmpty = false;
 if ( nFlags  IDF_CONTENTS )
 {
 pMixDoc = new ScDocument( SCDOCMODE_UNDO );
commit 4f2482c6a82e2c32511cd9bd9adea863191f7199
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 6 14:11:02 2014 -0500

fdo#74573: Write test for pasting with empty cells skipped.

Change-Id: I8ede86b248a9b3a17d077442537e2ec37034f597

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3bab048..81e1902 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3594,6 +3594,81 @@ void Test::testCopyPasteTranspose()
 
 }
 
+void Test::testCopyPasteSkipEmpty()
+{
+m_pDoc-InsertTab(0, Test);
+
+ScRange aSrcRange(0,0,0,0,4,0);
+ScRange aDestRange(1,0,0,1,4,0);
+
+ScMarkData aMark;
+aMark.SetMarkArea(aDestRange);
+
+// Put some texts in A1:A5.
+m_pDoc-SetString(ScAddress(1,0,0), A);
+m_pDoc-SetString(ScAddress(1,1,0), B);
+m_pDoc-SetString(ScAddress(1,2,0), C);
+m_pDoc-SetString(ScAddress(1,3,0), D);
+m_pDoc-SetString(ScAddress(1,4,0), E);
+
+// Prepare a clipboard content interleaved with empty cells.
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, aMark);
+aClipDoc.SetClipParam(ScClipParam(aSrcRange, false));
+aClipDoc.SetString(ScAddress(0,0,0), Clip1);
+aClipDoc.SetString(ScAddress(0,2,0), Clip2);
+aClipDoc.SetString(ScAddress(0,4,0), Clip3);
+
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, 
aClipDoc.GetCellType(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE,   
aClipDoc.GetCellType(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, 
aClipDoc.GetCellType(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE,   
aClipDoc.GetCellType(ScAddress(0,3,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, 
aClipDoc.GetCellType(ScAddress(0,4,0)));
+
+// Create undo document.
+ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+pUndoDoc-InitUndo(m_pDoc, 0, 0);
+m_pDoc-CopyToDocument(aDestRange, IDF_CONTENTS, false, pUndoDoc, aMark);
+
+// Paste clipboard content onto A1:A5 but skip empty cells.
+bool bSkipEmpty = true;
+m_pDoc-CopyFromClip(aDestRange, aMark, IDF_CONTENTS, pUndoDoc, aClipDoc, 
true, false, false, bSkipEmpty);
+
+// Create redo document.
+ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
+pRedoDoc-InitUndo(m_pDoc, 0, 0);
+m_pDoc-CopyToDocument(aDestRange, IDF_CONTENTS, false, pRedoDoc, aMark);
+
+// Create an undo object for this.
+ScRefUndoData* pRefUndoData = new ScRefUndoData(m_pDoc);
+ScUndoPaste aUndo(getDocShell(), aDestRange, aMark, pUndoDoc, pRedoDoc, 
IDF_CONTENTS, 

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

2014-02-06 Thread Kohei Yoshida
 sc/qa/unit/data/xls/shared-formula/horizontal.xls |binary
 sc/qa/unit/subsequent_filters-test.cxx|   45 ++
 sc/source/filter/excel/excform.cxx|2 
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 16442998b8b6ac7e284ab2377013f36c28b2cb8c
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 6 18:08:03 2014 -0500

fdo#74553: Use the shared formula column position Excel tells you...

Because sometimes this may be correct.

Change-Id: Id2c47bb4ad3f91b366a25306169de58bb38c1e81

diff --git a/sc/source/filter/excel/excform.cxx 
b/sc/source/filter/excel/excform.cxx
index 6d925fb..cf44d3c 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -124,7 +124,7 @@ void ImportExcel::Formula(
 SCROW nSharedRow;
 if (pFormConv-ReadSharedFormulaPosition(maStrm, nSharedCol, 
nSharedRow))
 {
-ScAddress aRefPos(aScPos.Col(), nSharedRow, GetCurrScTab());
+ScAddress aRefPos(nSharedCol, nSharedRow, GetCurrScTab());
 const ScTokenArray* pSharedCode = 
pFormConv-GetSharedFormula(aRefPos);
 if (pSharedCode)
 {
commit 642d0c9abc30b5f9c06abe4d91b55fdf06427ce5
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Feb 6 18:05:50 2014 -0500

fdo#74553: Write unit test for this.

Change-Id: Ie33047dff35c7aa31aaed9ec6c8e1fe5f8f5b9d7

diff --git a/sc/qa/unit/data/xls/shared-formula/horizontal.xls 
b/sc/qa/unit/data/xls/shared-formula/horizontal.xls
new file mode 100644
index 000..318379f
Binary files /dev/null and b/sc/qa/unit/data/xls/shared-formula/horizontal.xls 
differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 003fdd0..448a9fa 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -158,6 +158,8 @@ public:
 
 void testColumnStyleXLSX();
 
+void testSharedFormulaHorizontalXLS();
+
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testBasicCellContentODS);
 CPPUNIT_TEST(testRangeNameXLS);
@@ -231,6 +233,7 @@ public:
 CPPUNIT_TEST(testPrintRangeODS);
 CPPUNIT_TEST(testOutlineODS);
 CPPUNIT_TEST(testColumnStyleXLSX);
+CPPUNIT_TEST(testSharedFormulaHorizontalXLS);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2443,6 +2446,48 @@ void ScFiltersTest::testColumnStyleXLSX()
 
 const ScProtectionAttr rAttrNew = static_castconst 
ScProtectionAttr(pPattern-GetItem(ATTR_PROTECTION));
 CPPUNIT_ASSERT(!rAttrNew.GetProtection());
+
+xDocSh-DoClose();
+}
+
+void ScFiltersTest::testSharedFormulaHorizontalXLS()
+{
+ScDocShellRef xDocSh = loadDoc(shared-formula/horizontal., XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh-GetDocument();
+
+// Make sure K2:S2 on the 2nd sheet are all formula cells.
+ScAddress aPos(0, 1, 1);
+for (SCCOL nCol = 10; nCol = 18; ++nCol)
+{
+aPos.SetCol(nCol);
+CPPUNIT_ASSERT_MESSAGE(Formula cell is expected here., 
pDoc-GetCellType(aPos) == CELLTYPE_FORMULA);
+}
+
+// Likewise, B3:J9 all should be formula cells.
+for (SCCOL nCol = 1; nCol = 9; ++nCol)
+{
+aPos.SetCol(nCol);
+for (SCROW nRow = 2; nRow = 8; ++nRow)
+{
+aPos.SetRow(nRow);
+CPPUNIT_ASSERT_MESSAGE(Formula cell is expected here., 
pDoc-GetCellType(aPos) == CELLTYPE_FORMULA);
+}
+}
+
+// B2:I2 too.
+aPos.SetRow(1);
+for (SCCOL nCol = 1; nCol = 8; ++nCol)
+{
+aPos.SetCol(nCol);
+CPPUNIT_ASSERT_MESSAGE(Formula cell is expected here., 
pDoc-GetCellType(aPos) == CELLTYPE_FORMULA);
+}
+
+// J2 has a string of MW.
+aPos.SetCol(9);
+CPPUNIT_ASSERT_EQUAL(OUString(MW), pDoc-GetString(aPos));
+
+xDocSh-DoClose();
 }
 
 ScFiltersTest::ScFiltersTest()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-01-23 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   21 +
 sc/qa/unit/ucalc.hxx|2 ++
 sc/source/core/data/column3.cxx |2 +-
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 228cd29a48374833bbe305a434f7149a0ef3ddd1
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Jan 23 14:07:25 2014 -0500

fdo#73986: Write unit test for document statistics.

Change-Id: I8ff51fda91627b365cf71be8849d07b92b447ba9

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 357f596..111b940 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -634,6 +634,27 @@ void Test::testInput()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testDocStatistics()
+{
+SCTAB nStartTabs = m_pDoc-GetTableCount();
+m_pDoc-InsertTab(0, Sheet1);
+CPPUNIT_ASSERT_MESSAGE(Failed to increment sheet count., 
m_pDoc-GetTableCount() == nStartTabs+1);
+m_pDoc-InsertTab(1, Sheet2);
+CPPUNIT_ASSERT_MESSAGE(Failed to increment sheet count., 
m_pDoc-GetTableCount() == nStartTabs+2);
+
+CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(0), m_pDoc-GetCellCount());
+m_pDoc-SetValue(ScAddress(0,0,0), 2.0);
+CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(1), m_pDoc-GetCellCount());
+m_pDoc-SetValue(ScAddress(2,2,0), 2.5);
+CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(2), m_pDoc-GetCellCount());
+m_pDoc-SetString(ScAddress(1,1,1), Test);
+CPPUNIT_ASSERT_EQUAL(static_castsal_uLong(3), m_pDoc-GetCellCount());
+
+m_pDoc-DeleteTab(1);
+CPPUNIT_ASSERT_MESSAGE(Failed to decrement sheet count., 
m_pDoc-GetTableCount() == nStartTabs+1);
+m_pDoc-DeleteTab(0); // This may fail in case there is only one sheet in 
the document.
+}
+
 void Test::testDataEntries()
 {
 m_pDoc-InsertTab(0, Test);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1dbfbbc..f6007ff 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -83,6 +83,7 @@ public:
 void testSharedStringPool();
 void testRangeList();
 void testInput();
+void testDocStatistics();
 
 /**
  * The 'data entries' data is a list of strings used for suggestions as
@@ -314,6 +315,7 @@ public:
 CPPUNIT_TEST(testSharedStringPool);
 CPPUNIT_TEST(testRangeList);
 CPPUNIT_TEST(testInput);
+CPPUNIT_TEST(testDocStatistics);
 CPPUNIT_TEST(testDataEntries);
 CPPUNIT_TEST(testSelectionFunction);
 CPPUNIT_TEST(testFormulaCreateStringFromTokens);
commit 9ce7ba209d28cd284ab5ea584bc130d7a081b0f9
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Jan 23 14:06:34 2014 -0500

fdo#73986: Don't forget to receive returned object from for_each.

Change-Id: Ia4ccb83c45ea3ce72a8e5c62a560ab1802bb2441

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 7675271..798d544 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2433,7 +2433,7 @@ public:
 SCSIZE ScColumn::GetCellCount() const
 {
 CellCounter aFunc;
-std::for_each(maCells.begin(), maCells.end(), aFunc);
+aFunc = std::for_each(maCells.begin(), maCells.end(), aFunc);
 return aFunc.getCount();
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-01-16 Thread Kohei Yoshida
 sc/qa/unit/helper/qahelper.cxx  |2 
 sc/qa/unit/ucalc.hxx|2 
 sc/qa/unit/ucalc_sharedformula.cxx  |   81 
 sc/source/core/data/formulacell.cxx |   17 +++
 4 files changed, 101 insertions(+), 1 deletion(-)

New commits:
commit 8c3b6b34cea6212f4f3f266cc92e76de97d0aa55
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Thu Jan 16 12:50:48 2014 -0500

fdo#73655: Write unit test for this.

Change-Id: I0409e3c482d8a833672f41b1398333e5181847af

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 7666c34..773b779 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -420,7 +420,7 @@ bool checkFormula(ScDocument rDoc, const ScAddress rPos, 
const char* pExpected
 return false;
 }
 
-OUString aFormula = toString(rDoc, rPos, *pCode);
+OUString aFormula = toString(rDoc, rPos, *pCode, rDoc.GetGrammar());
 if (aFormula != OUString::createFromAscii(pExpected))
 {
 cerr  Formula '  pExpected  ' expected, but '  aFormula  
' found  endl;
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1f6f202..1dbfbbc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -246,6 +246,7 @@ public:
 void testSharedFormulasRefUpdate();
 void testSharedFormulasRefUpdateRange();
 void testSharedFormulasDeleteRows();
+void testSharedFormulasRefUpdateMoveSheets();
 void testSharedFormulasCopyPaste();
 void testFormulaPosition();
 
@@ -396,6 +397,7 @@ public:
 CPPUNIT_TEST(testSharedFormulasRefUpdate);
 CPPUNIT_TEST(testSharedFormulasRefUpdateRange);
 CPPUNIT_TEST(testSharedFormulasDeleteRows);
+CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets);
 CPPUNIT_TEST(testSharedFormulasCopyPaste);
 CPPUNIT_TEST(testFormulaPosition);
 CPPUNIT_TEST(testJumpToPrecedentsDependents);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index b1bdea2..b4ce117 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -515,7 +515,88 @@ void Test::testSharedFormulasDeleteRows()
 CPPUNIT_ASSERT_MESSAGE(1,6 must be a shared formula cell., pFC  
pFC-IsShared());
 CPPUNIT_ASSERT_EQUAL(static_castSCROW(6), pFC-GetSharedTopRow());
 CPPUNIT_ASSERT_EQUAL(static_castSCROW(8), pFC-GetSharedLength());
+}
+
+void Test::testSharedFormulasRefUpdateMoveSheets()
+{
+m_pDoc-InsertTab(0, Sheet1);
+m_pDoc-InsertTab(1, Sheet2);
+m_pDoc-InsertTab(2, Sheet3);
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // make sure auto calc is on.
+
+// Switch to R1C1 for ease of repeated formula insertions.
+FormulaGrammarSwitch aFGSwitch(m_pDoc, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+
+// Fill numbers in A1:A8 on Sheet2.
+for (SCROW i = 0; i = 7; ++i)
+m_pDoc-SetValue(ScAddress(0,i,1), i+1);
+
+// Fill formula cells A1:A8 on Sheet1, to refer to the same cell address 
on Sheet2.
+for (SCROW i = 0; i = 7; ++i)
+m_pDoc-SetString(ScAddress(0,i,0), =Sheet2!RC);
+
+// Check the results.
+for (SCROW i = 0; i = 7; ++i)
+CPPUNIT_ASSERT_EQUAL(static_castdouble(i+1), 
m_pDoc-GetValue(ScAddress(0,i,0)));
+
+// Move Sheet3 to the leftmost position before Sheet1.
+m_pDoc-MoveTab(2, 0);
+
+// Check sheet names.
+std::vectorOUString aTabNames = m_pDoc-GetAllTableNames();
+CPPUNIT_ASSERT_MESSAGE(There should be at least 3 sheets., 
aTabNames.size() = 3);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet3), aTabNames[0]);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet1), aTabNames[1]);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet2), aTabNames[2]);
+
+// Check the results again on Sheet1.
+for (SCROW i = 0; i = 7; ++i)
+{
+CPPUNIT_ASSERT_EQUAL(static_castdouble(i+1), 
m_pDoc-GetValue(ScAddress(0,i,1)));
+if (!checkFormula(*m_pDoc, ScAddress(0,i,1), Sheet2!RC))
+CPPUNIT_FAIL(Wrong formula expression.);
+}
+
+// Insert a new sheet at the left end.
+m_pDoc-InsertTab(0, Sheet4);
+
+// Check sheet names.
+aTabNames = m_pDoc-GetAllTableNames();
+CPPUNIT_ASSERT_MESSAGE(There should be at least 4 sheets., 
aTabNames.size() = 4);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet4), aTabNames[0]);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet3), aTabNames[1]);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet1), aTabNames[2]);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet2), aTabNames[3]);
+
+// Check the results again on Sheet1.
+for (SCROW i = 0; i = 7; ++i)
+{
+CPPUNIT_ASSERT_EQUAL(static_castdouble(i+1), 
m_pDoc-GetValue(ScAddress(0,i,2)));
+if (!checkFormula(*m_pDoc, ScAddress(0,i,2), Sheet2!RC))
+CPPUNIT_FAIL(Wrong formula expression.);
+}
+
+// Delete Sheet4.
+m_pDoc-DeleteTab(0);
+
+// Check sheet names.
+aTabNames = m_pDoc-GetAllTableNames();
+CPPUNIT_ASSERT_MESSAGE(There should be at least 3 

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

2013-12-25 Thread Markus Mohrhard
 sc/qa/unit/data/contentCSV/statistical-functions.csv |1 +
 sc/qa/unit/data/ods/functions.ods|binary
 sc/qa/unit/subsequent_filters-test.cxx   |3 +++
 sc/source/core/tool/interpr6.cxx |2 +-
 4 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 68cd5c4fa1b6190907ef4a121bac5d5eff0c13ec
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Thu Dec 26 00:09:45 2013 +0100

add test case for fdo#72999

Change-Id: I256e0cb228edb85b402e6645fd40f24b7ccf234a

diff --git a/sc/qa/unit/data/contentCSV/statistical-functions.csv 
b/sc/qa/unit/data/contentCSV/statistical-functions.csv
new file mode 100644
index 000..e4e9574
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/statistical-functions.csv
@@ -0,0 +1 @@
+1,1,2,0,3,3
diff --git a/sc/qa/unit/data/ods/functions.ods 
b/sc/qa/unit/data/ods/functions.ods
index c3e2a34..9a1cb46 100644
Binary files a/sc/qa/unit/data/ods/functions.ods and 
b/sc/qa/unit/data/ods/functions.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index c036318..747fd66 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -373,6 +373,9 @@ void ScFiltersTest::testFunctionsODS()
 // text functions
 createCSVPath(OUString(text-functions.), aCSVFileName);
 testFile(aCSVFileName, pDoc, 4);
+// statistical functions
+createCSVPath(OUString(statistical-functions.), aCSVFileName);
+testFile(aCSVFileName, pDoc, 5);
 
 xDocSh-DoClose();
 }
commit 5bb8a2868316a644646857047be032c17787cac5
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Wed Dec 25 23:50:40 2013 +0100

fix handling of range parameters in COUNT, fdo#72999

Change-Id: I352c6b415f0990890702fa21175c196d7f4b12ee

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 8999e04..f404561 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -973,7 +973,7 @@ void ScInterpreter::ScCount()
 
 FuncCount aAction;
 aSet.executeColumnAction(*pDok, aAction);
-nCount = aAction.getCount();
+nCount += aAction.getCount();
 
 // Get the number format of the last iterated cell.
 nFuncFmtIndex = aAction.getNumberFormat();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2013-12-01 Thread Markus Mohrhard
 sc/qa/unit/ucalc.cxx   |   35 +++
 sc/qa/unit/ucalc.hxx   |1 +
 sc/source/core/data/table2.cxx |2 +-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit a14cfd3d77104aee3e3c3d981a135161295197df
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Dec 2 07:37:15 2013 +0100

add test for fdo#72149

Change-Id: I303bbfe14c258f45985a6ed7a4130d1d0fe2dcd8

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 809b4c6..2fc7702 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4678,6 +4678,41 @@ void Test::testCondFormatInsertRow()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testCondCopyPaste()
+{
+m_pDoc-InsertTab(0, Test);
+
+ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+ScRange aCondFormatRange(0,0,0,3,3,0);
+ScRangeList aRangeList(aCondFormatRange);
+pFormat-AddRange(aRangeList);
+
+ScCondFormatEntry* pEntry = new 
ScCondFormatEntry(SC_COND_DIRECT,=B2,,m_pDoc,ScAddress(0,0,0),ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+pFormat-AddEntry(pEntry);
+sal_uLong nIndex = m_pDoc-AddCondFormat(pFormat, 0);
+
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+copyToClip(m_pDoc, aCondFormatRange, aClipDoc);
+
+ScRange aTargetRange(4,4,0,7,7,0);
+pasteFromClip(m_pDoc, aTargetRange, aClipDoc);
+
+ScConditionalFormat* pPastedFormat = m_pDoc-GetCondFormat(7,7,0);
+CPPUNIT_ASSERT(pPastedFormat);
+
+CPPUNIT_ASSERT_EQUAL(ScRangeList(aTargetRange), pPastedFormat-GetRange());
+CPPUNIT_ASSERT( nIndex != pPastedFormat-GetKey());
+const SfxPoolItem* pItem = m_pDoc-GetAttr( 7, 7, 0, ATTR_CONDITIONAL );
+const ScCondFormatItem* pCondFormatItem = static_castconst 
ScCondFormatItem*(pItem);
+
+CPPUNIT_ASSERT(pCondFormatItem);
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
pCondFormatItem-GetCondFormatData().size());
+CPPUNIT_ASSERT( nIndex != pCondFormatItem-GetCondFormatData().at(0) );
+
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testMixData()
 {
 m_pDoc-InsertTab(0, Test);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1298e73..6538efc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -285,6 +285,7 @@ public:
 void testCondFormatINSDEL();
 void testCondFormatInsertRow();
 void testCondFormatInsertCol();
+void testCondCopyPaste();
 
 CPPUNIT_TEST_SUITE(Test);
 #if CALC_TEST_PERF
commit 7c2936757ca10ccb692b05e6564783313f3576d1
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Dec 2 06:05:19 2013 +0100

we want to delete anytime that attribs are overwritten, fdo#72149

Change-Id: I1ed50e6daf5b363c46e31d1a0efacf7728621b1a

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index d7fca4f..30771ab 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -662,7 +662,7 @@ void ScTable::CopyFromClip(
 for ( SCCOL i = nCol1; i = nCol2; i++)
 aCol[i].CopyFromClip(rCxt, nRow1, nRow2, nDy, pTable-aCol[i - 
nDx]); // notes are handles at column level
 
-if (rCxt.getInsertFlag() == IDF_ATTRIB)
+if (rCxt.getInsertFlag()  IDF_ATTRIB)
 {
 // make sure that there are no old references to the cond formats
 sal_uInt16 nWhichArray[2];
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2013-11-24 Thread Ray
 sc/qa/unit/data/xls/opencl/math/sumproductTest.xls |binary
 sc/qa/unit/opencl-test.cxx |   26 ++
 sc/source/core/opencl/formulagroupcl.cxx   |   52 ++---
 3 files changed, 72 insertions(+), 6 deletions(-)

New commits:
commit 01a977486f050bf61b2c8592426e26cfe4f8
Author: I-Jui (Ray) Sung r...@multicorewareinc.com
Date:   Mon Nov 25 01:10:04 2013 -0600

GPU Calc: a test case for unrolling SumOfProduct

AMLOEXT-245 BUG

Change-Id: Ia8756af26c765820a04137a87f6681447dd18efd

diff --git a/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls 
b/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls
new file mode 100644
index 000..28eaebf
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index faf2ddb..833d9c0 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -242,6 +242,7 @@ public:
 void testStatisticalFormulaCovar();
 void testLogicalFormulaAnd();
 void testMathFormulaSumProduct();
+void testMathFormulaSumProduct2();
 void testStatisticalParallelCountBug();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
@@ -416,6 +417,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaCovar);
 CPPUNIT_TEST(testLogicalFormulaAnd);
 CPPUNIT_TEST(testMathFormulaSumProduct);
+CPPUNIT_TEST(testMathFormulaSumProduct2);
 CPPUNIT_TEST(testStatisticalParallelCountBug);
 CPPUNIT_TEST_SUITE_END();
 
@@ -4792,6 +4794,30 @@ void ScOpenclTest::testMathFormulaSumProduct()
 xDocSh-DoClose();
 xDocShRes-DoClose();
 }
+//[AMLOEXT-245]
+void ScOpenclTest::testMathFormulaSumProduct2()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc(opencl/math/sumproductTest., XLS);
+ScDocument* pDoc = xDocSh-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc-CalcAll();
+ScDocShellRef xDocShRes = loadDoc(opencl/math/sumproductTest., XLS);
+ScDocument* pDocRes = xDocShRes-GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+// Check the results of formula cells in the shared formula range.
+for (SCROW i = 2; i = 12; ++i)
+{
+double fLibre = pDoc-GetValue(ScAddress(4,i,1));
+double fExcel = pDocRes-GetValue(ScAddress(4,i,1));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel,  fLibre, fabs(0.0001*fExcel));
+}
+xDocSh-DoClose();
+xDocShRes-DoClose();
+}
+
 //[AMLOEXT-217]
 void ScOpenclTest:: testLogicalFormulaAnd()
 {
commit 7e3d93e763770c7759555cfe7441573a97d276c1
Author: I-Jui (Ray) Sung r...@multicorewareinc.com
Date:   Mon Nov 25 01:13:44 2013 -0600

GPU Calc: fixed a SUMPRODUCT problem

ALMOEXT-245

Change-Id: Iedbbdc612232a939b2270e373313c872de831c20

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 3405459..bee159b 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1103,10 +1103,30 @@ public:
 ss  for(int outLoop=0; outLoop 
 nCurWindowSize/outLoopSize ; outLoop++){\n\t;
 for(int count=0; count  outLoopSize; count++){
-ss  i = outLoop*outLoopSize+count;\n\t;
+ss  i = outLoop*outLoopSize+count;\n;
 if(count==0){
-temp3  currentCount0 = i+gid0+1;\n\t;
-temp3  currentCount1 = i+1;\n\t;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+tmpCur = vSubArguments[i]-GetFormulaToken();
+if(ocPush==tmpCur-GetOpCode())
+{
+pCurDVR= dynamic_cast
+const formula::DoubleVectorRefToken *(tmpCur);
+if(!pCurDVR-IsStartFixed()  
!pCurDVR-IsEndFixed())
+{
+temp3  currentCount;
+temp3  i;
+temp3  =i+gid0+1;\n;
+}
+else
+{
+temp3  currentCount;
+temp3  i;
+temp3   =i+1;\n;
+}
+}
+}
+
 temp3  tmp = fsum(;
 for (unsigned i = 0; i  vSubArguments.size(); i++){
 if (i)
@@ -1149,10 +1169,30 @@ public:
 for(unsigned int count=nCurWindowSize/outLoopSize*outLoopSize;
 count  nCurWindowSize; count++)
 {
-ss  i = count;\n\t;
+ss  i = count;\n;
 if(count==nCurWindowSize/outLoopSize*outLoopSize){
-temp4  currentCount0 = 

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

2013-11-22 Thread Wei Wei
 sc/qa/unit/data/ods/opencl/compiler/nested.ods  |binary
 sc/source/core/opencl/formulagroupcl.cxx|   57 ++--
 sc/source/core/opencl/formulagroupcl_public.hxx |1 
 sc/source/core/opencl/opbase.cxx|6 ++
 sc/source/core/opencl/opbase.hxx|1 
 5 files changed, 42 insertions(+), 23 deletions(-)

New commits:
commit 8b7853cc3a1727d6b0a9f7050b26680678e98de0
Author: Wei Wei wei...@multicorewareinc.com
Date:   Fri Nov 22 17:16:49 2013 -0600

GPU Calc: Sum of product doesn't check out-of-bound accesses

AMLOEXT-244 FIX

Change-Id: I5f49f7acccaabd2a97d8ac4bfba4b973889278f1

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index b0bb011..3405459 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -444,13 +444,26 @@ public:
 }
 virtual void GenSlidingWindowFunction(std::stringstream ) {}
 
-virtual std::string GenSlidingWindowDeclRef(bool=false) const
+virtual std::string GenSlidingWindowDeclRef(bool nested=false) const
 {
+size_t nArrayLength = mpDVR-GetArrayLength();
 std::stringstream ss;
 if (!bIsStartFixed  !bIsEndFixed)
+{
+if (nested)
+ss  ((i+gid0)   nArrayLength ?;
 ss  Base::GetName()  [i + gid0];
+if (nested)
+ss  :NAN);
+}
 else
+{
+if (nested)
+ss  (i   nArrayLength ?;
 ss  Base::GetName()  [i];
+if (nested)
+ss  :NAN);
+}
 return ss.str();
 }
 /// Controls how the elements in the DoubleVectorRef are traversed
@@ -533,9 +546,9 @@ return nCurWindowSize;
 if(count==0){
 temp1  if(i + gid0   
mpDVR-GetArrayLength();
 temp1  ){\n\t\t;
-temp1  tmp = ;
+temp1  tmp = legalize(;
 temp1   
mpCodeGen-Gen2(GenSlidingWindowDeclRef(), tmp);
-temp1  ;\n\t\t\t;
+temp1  , tmp);\n\t\t\t;
 temp1  }\n\t;
 }
 ss  temp1.str();
@@ -548,9 +561,9 @@ return nCurWindowSize;
 if(count==nCurWindowSize/outLoopSize*outLoopSize){
 temp2  if(i + gid0mpDVR-GetArrayLength();
 temp2  ){\n\t\t;
-temp2  tmp = ;
+temp2  tmp = legalize(;
 temp2  mpCodeGen-Gen2(GenSlidingWindowDeclRef(), 
tmp);
-temp2  ;\n\t\t\t;
+temp2  , tmp);\n\t\t\t;
 temp2  }\n\t;
 }
 ss  temp2.str();
@@ -571,9 +584,9 @@ return nCurWindowSize;
 for(int count=0; count  outLoopSize; count++){
 ss  i = outLoop*outLoopSize+count;\n\t;
 if(count==0){
-temp1  tmp = ;
+temp1  tmp = legalize(;
 temp1  
mpCodeGen-Gen2(GenSlidingWindowDeclRef(), tmp);
-temp1  ;\n\t\t\t;
+temp1  , tmp);\n\t\t\t;
 }
 ss  temp1.str();
 }
@@ -583,9 +596,9 @@ return nCurWindowSize;
 for(unsigned int count=nCurWindowSize/outLoopSize*outLoopSize; 
count  nCurWindowSize; count++){
 ss  i = count;\n\t;
 if(count==nCurWindowSize/outLoopSize*outLoopSize){
-temp2  tmp = ;
+temp2  tmp = legalize(;
 temp2  mpCodeGen-Gen2(GenSlidingWindowDeclRef(), 
tmp);
-temp2  ;\n\t\t\t;
+temp2  , tmp);\n\t\t\t;
 }
 ss  temp2.str();
 }
@@ -673,13 +686,13 @@ public:
 ss  tmp =  mpCodeGen-GetBottom()  ;\n;
 ss  int loopOffset = l*512;\n;
 ss  if((loopOffset + lidx + offset + 256)  end) {\n;
-ss  tmp =   mpCodeGen-Gen2(
-A[loopOffset + lidx + offset], tmp) ;\n;
-ss  tmp =   mpCodeGen-Gen2(
-A[loopOffset + lidx + offset + 256], tmp)  ;\n;
+ss  tmp = legalize(  mpCodeGen-Gen2(
+A[loopOffset + lidx + offset], tmp) , tmp);\n;
+ss  tmp = legalize(  mpCodeGen-Gen2(
+A[loopOffset + lidx + offset + 256], tmp) , tmp);\n;
 ss  } else if ((loopOffset + lidx + offset)  end)\n;
-ss  tmp =   mpCodeGen-Gen2(
-A[loopOffset + lidx + offset], tmp) ;\n;
+ss  tmp = 

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

2013-11-17 Thread yiming ju
 sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls |binary
 sc/qa/unit/opencl-test.cxx|   38 +
 sc/source/core/opencl/formulagroupcl.cxx  |   57 +++---
 3 files changed, 86 insertions(+), 9 deletions(-)

New commits:
commit 59c0051b26c28a0b277a83177f7e7d5db012b6cf
Author: yiming ju yim...@multicorewareinc.com
Date:   Sun Nov 17 18:29:16 2013 +0800

GPU Calc: unit test cases for SUMPRODUCT WITH FIXED WINDOWS

AMLOEXT-214 BUG

Change-Id: Ib5adff235593b3a38f6aa7e63edf0196d31b8e82
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls 
b/sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls
new file mode 100644
index 000..09ff33e
Binary files /dev/null and 
b/sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 0cbf365..987fc40 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -240,6 +240,7 @@ public:
 void testStatisticalFormulaStDevP();
 void testStatisticalFormulaCovar();
 void testLogicalFormulaAnd();
+void testMathFormulaSumProduct();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -411,6 +412,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaStDevP);
 CPPUNIT_TEST(testStatisticalFormulaCovar);
 CPPUNIT_TEST(testLogicalFormulaAnd);
+CPPUNIT_TEST(testMathFormulaSumProduct);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4716,6 +4718,42 @@ void ScOpenclTest:: testArrayFormulaSumXMY2()
 xDocSh-DoClose();
 xDocShRes-DoClose();
 }
+//[AMLOEXT-214]
+void ScOpenclTest::testMathFormulaSumProduct()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc(opencl/math/sumproduct_mixSliding., XLS);
+ScDocument* pDoc = xDocSh-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc-CalcAll();
+ScDocShellRef xDocShRes = loadDoc(opencl/math/sumproduct_mixSliding., 
XLS);
+ScDocument* pDocRes = xDocShRes-GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+// Check the results of formula cells in the shared formula range.
+for (SCROW i = 0; i = 9; ++i)
+{
+double fLibre = pDoc-GetValue(ScAddress(2,i,0));
+double fExcel = pDocRes-GetValue(ScAddress(2,i,0));
+if ( i == 1 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(82,  fLibre, fabs(0.0001*fExcel));
+else if ( i == 2 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(113, fLibre, fabs(0.0001*fExcel));
+else if ( i == 4 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(175, fLibre, fabs(0.0001*fExcel));
+else if ( i == 5 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(206, fLibre, fabs(0.0001*fExcel));
+else if ( i == 6 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(237, fLibre, fabs(0.0001*fExcel));
+else if ( i == 7 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(268, fLibre, fabs(0.0001*fExcel));
+else
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh-DoClose();
+xDocShRes-DoClose();
+}
 //[AMLOEXT-217]
 void ScOpenclTest:: testLogicalFormulaAnd()
 {
commit 62f23965591ad3e2a3ee772e518d3fccd6b5ae9f
Author: yiming ju yim...@multicorewareinc.com
Date:   Sun Nov 17 18:58:23 2013 +0800

GPU Calc: implemented SUMPRODUCT WITH FIXED WINDOWS

AMLOEXT-214 FIX

Change-Id: Ifb2797899ec30f998a2387ce9c5752c8e8a03b79
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 85ebdf0..43aa30d 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -808,6 +808,8 @@ public:
 const std::string sSymName, SubArguments vSubArguments)
 {
 size_t nCurWindowSize = 0;
+FormulaToken *tmpCur = NULL;
+const formula::DoubleVectorRefToken *pCurDVR = NULL;
 ss  \ndouble   sSymName;
 ss  _ BinFuncName() (;
 for (unsigned i = 0; i  vSubArguments.size(); i++)
@@ -816,15 +818,50 @@ public:
 ss  ,;
 vSubArguments[i]-GenSlidingWindowDecl(ss);
 size_t nCurChildWindowSize = vSubArguments[i]-GetWindowSize();
-nCurWindowSize = (nCurWindowSize  nCurChildWindowSize) ?
+nCurWindowSize = (nCurWindowSize  nCurChildWindowSize)?
 nCurChildWindowSize:nCurWindowSize;
+tmpCur = vSubArguments[i]-GetFormulaToken();
+if (  ocPush==tmpCur-GetOpCode() )
+{
+
+pCurDVR = dynamic_cast
+const formula::DoubleVectorRefToken*(tmpCur);
+if ( !
+( (!pCurDVR-IsStartFixed()  

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

2013-11-12 Thread xinjiang
 sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls |binary
 sc/qa/unit/opencl-test.cxx|   25 +++
 sc/source/core/opencl/formulagroupcl.cxx  |6 +
 sc/source/core/opencl/op_financial.cxx|   60 ++
 sc/source/core/opencl/op_financial.hxx|   14 
 sc/source/core/opencl/opinlinefun_finacial.cxx|   32 +
 6 files changed, 136 insertions(+), 1 deletion(-)

New commits:
commit 20029a72b3bb9a119e99bff7974bf6bb20e17924
Author: xinjiang xinji...@multicorewareinc.com
Date:   Tue Nov 5 09:31:14 2013 +0800

GPU Calc: unit test cases for DURATION_ADD

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-121 BUG

Change-Id: Id78c89f77cdfe14d368831c22ff708b968e8fee2
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls 
b/sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls
new file mode 100644
index 000..18e5ddb
Binary files /dev/null and 
b/sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b593174..b040e32 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -131,6 +131,7 @@ public:
 void testStatisticalFormulaStandard();
 void testStatisticalFormulaWeibull();
 void testStatisticalFormulaMedian();
+void testFinancialDuration_ADDFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -193,6 +194,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaStandard);
 CPPUNIT_TEST(testStatisticalFormulaWeibull);
 CPPUNIT_TEST(testStatisticalFormulaMedian);
+CPPUNIT_TEST(testFinancialDuration_ADDFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1902,7 +1904,28 @@ void ScOpenclTest:: testFinacialPPMTFormula()
 xDocSh-DoClose();
 xDocShRes-DoClose();
 }
-
+//[AMLOEXT-121]
+void ScOpenclTest:: testFinancialDuration_ADDFormula()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc(opencl/financial/Duration_ADD., XLS);
+ScDocument* pDoc = xDocSh-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc-CalcAll();
+ScDocShellRef xDocShRes = loadDoc(opencl/financial/Duration_ADD., XLS);
+ScDocument* pDocRes = xDocShRes-GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; i = 9; ++i)
+{
+double fLibre = pDoc-GetValue(ScAddress(6, i, 0));
+double fExcel = pDocRes-GetValue(ScAddress(6, i, 0));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh-DoClose();
+xDocShRes-DoClose();
+}
 ScOpenclTest::ScOpenclTest()
   : ScBootstrapFixture( /sc/qa/unit/data )
 {
commit 9425b3a938faf2df4d58acdcaf4437dc52ebd23c
Author: xinjiang xinji...@multicorewareinc.com
Date:   Tue Nov 5 09:47:10 2013 +0800

GPU Calc: implement fix for DURATION_ADD

AMLOEXT-121 FIX

Change-Id: Ie6b10eacc4e5fc0b2dcfe816982836b8b244af05
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index c6ae8e8..6d613a4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1179,6 +1179,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts, ft-Children[i],
 new OpCoupnum));
 }
+else if ( !(pChild-GetExternal().compareTo(OUString(
+   com.sun.star.sheet.addin.Analysis.getDuration
+{
+mvSubArguments.push_back(
+SoPHelper(ts, ft-Children[i], new OpDuration_ADD));
+}
 break;
 default:
 throw UnhandledToken(pChild, unhandled opcode);
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index cb31cd1..1db9119 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -574,6 +574,66 @@ void 
OpDuration::GenSlidingWindowFunction(std::stringstream ss,
 ss  };
 }
 
+void OpDuration_ADD::BinInlineFun(std::setstd::string decls,
+std::setstd::string funs)
+{
+decls.insert(GetDurationDecl);decls.insert(lcl_GetcoupnumDecl);
+decls.insert(GetYearFracDecl);decls.insert(DaysToDateDecl);
+decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
+decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
+funs.insert(GetDuration);funs.insert(lcl_Getcoupnum);
+funs.insert(GetYearFrac);funs.insert(DaysToDate);
+

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

2013-11-12 Thread minwang
 sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls |binary
 sc/qa/unit/opencl-test.cxx |   24 ++
 sc/source/core/opencl/formulagroupcl.cxx   |6 
 sc/source/core/opencl/op_financial.cxx |  171 +
 sc/source/core/opencl/op_financial.hxx |   10 +
 5 files changed, 211 insertions(+)

New commits:
commit 4bad711ff532bfc1f64b584e8c5cf8fbef38e2ca
Author: minwang m...@multicorewareinc.com
Date:   Tue Nov 5 10:02:29 2013 +0800

GPU Calc: unit test cases for AMORDEGRC in GPU calc

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-98 BUG

Change-Id: I0867627c69eefdbc7127d19559af23fbd70b3ccc
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls 
b/sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls
new file mode 100644
index 000..7cb9e47
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b040e32..3c395c4 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -132,6 +132,7 @@ public:
 void testStatisticalFormulaWeibull();
 void testStatisticalFormulaMedian();
 void testFinancialDuration_ADDFormula();
+void testFinancialAmordegrcFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -195,6 +196,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaWeibull);
 CPPUNIT_TEST(testStatisticalFormulaMedian);
 CPPUNIT_TEST(testFinancialDuration_ADDFormula);
+CPPUNIT_TEST(testFinancialAmordegrcFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1514,6 +1516,28 @@ void ScOpenclTest::testFinacialXNPVFormula()
 xDocSh-DoClose();
 xDocShRes-DoClose();
 }
+//[AMLOEXT-98]
+void ScOpenclTest::testFinancialAmordegrcFormula()
+{
+   if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc(opencl/financial/Amordegrc., XLS);
+ScDocument* pDoc = xDocSh-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc-CalcAll();
+ScDocShellRef xDocShRes = loadDoc(opencl/financial/Amordegrc., XLS);
+ScDocument* pDocRes = xDocShRes-GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; i = 9; ++i)
+{
+double fLibre = pDoc-GetValue(ScAddress(7, i, 0));
+double fExcel = pDocRes-GetValue(ScAddress(7, i, 0));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh-DoClose();
+xDocShRes-DoClose();
+}
 //[AMLOEXT-99]
 void ScOpenclTest:: testFinancialISPMTFormula()
 {
commit 153bb4cc1e7009f2e2fa5fe277c397d5ad9a1730
Author: minwang m...@multicorewareinc.com
Date:   Tue Nov 5 10:16:40 2013 +0800

GPU Calc: implement fix for AMORDEGRC in GPU calc

AMLOEXT-98 FIX

Change-Id: I9f63d023161e5ad7981374dedffb6f00663a1c66
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 6d613a4..fe0b8f8 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1185,6 +1185,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(
 SoPHelper(ts, ft-Children[i], new OpDuration_ADD));
 }
+else if ( !(pChild-GetExternal().compareTo(OUString(
+   com.sun.star.sheet.addin.Analysis.getAmordegrc
+{
+mvSubArguments.push_back(SoPHelper(ts, ft-Children[i],
+new OpAmordegrc));
+}
 break;
 default:
 throw UnhandledToken(pChild, unhandled opcode);
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index 1db9119..5e2509a 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2892,6 +2892,177 @@ void 
OpCoupnum::GenSlidingWindowFunction(std::stringstream ss,
 ss  return tmp;\n;
 ss  };
 }
+void OpAmordegrc::BinInlineFun(std::setstd::string decls,
+std::setstd::string funs)
+{
+decls.insert(nKorrValDecl); decls.insert(RoundDecl);
+decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
+decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
+decls.insert(GetNullDateDecl); decls.insert(GetYearFracDecl);
+funs.insert(Round);
+funs.insert(IsLeapYear);funs.insert(DaysInMonth);
+funs.insert(DaysToDate);funs.insert(DateToDays);
+funs.insert(GetNullDate);funs.insert(GetYearFrac);
+}
+void OpAmordegrc::GenSlidingWindowFunction(std::stringstream ss,
+   

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

2013-11-12 Thread minwang
 sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls |binary
 sc/qa/unit/opencl-test.cxx|   24 +++
 sc/source/core/opencl/formulagroupcl.cxx  |6 
 sc/source/core/opencl/op_financial.cxx|  154 +-
 sc/source/core/opencl/op_financial.hxx|9 +
 5 files changed, 192 insertions(+), 1 deletion(-)

New commits:
commit 89ed6a0e150549fb5aa00f06216637ea71b04f30
Author: minwang m...@multicorewareinc.com
Date:   Tue Nov 5 10:28:57 2013 +0800

GPU Calc: unit test cases for AMORLINC in GPU calc

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-110 BUG

Change-Id: Ia6e1333e7d1c91ff9b8a916109a8aa60f4725e03
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls 
b/sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls
new file mode 100644
index 000..5962334
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 3c395c4..bc26113 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -133,6 +133,7 @@ public:
 void testStatisticalFormulaMedian();
 void testFinancialDuration_ADDFormula();
 void testFinancialAmordegrcFormula();
+void testFinancialAmorlincFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -197,6 +198,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaMedian);
 CPPUNIT_TEST(testFinancialDuration_ADDFormula);
 CPPUNIT_TEST(testFinancialAmordegrcFormula);
+CPPUNIT_TEST(testFinancialAmorlincFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1583,6 +1585,28 @@ void ScOpenclTest::testStatisticalFormulaMedian()
 xDocSh-DoClose();
 xDocShRes-DoClose();
 }
+//[AMLOEXT-110]
+void ScOpenclTest::testFinancialAmorlincFormula()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc(opencl/financial/Amorlinc., XLS);
+ScDocument *pDoc = xDocSh-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc-CalcAll();
+ScDocShellRef xDocShRes = loadDoc(opencl/financial/Amorlinc., XLS);
+ScDocument *pDocRes = xDocShRes-GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; i = 9; ++i)
+{
+double fLibre = pDoc-GetValue(ScAddress(7, i, 0));
+double fExcel = pDocRes-GetValue(ScAddress(7, i, 0));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh-DoClose();
+xDocShRes-DoClose();
+}
 void ScOpenclTest::testFinacialPriceMatFormula()
 {
 if (!detectOpenCLDevice())
commit 7b33d0c12d487d953634fa1e06c6902124455e38
Author: minwang m...@multicorewareinc.com
Date:   Tue Nov 5 10:33:53 2013 +0800

GPU Calc: implement fix for AMORLINC in GPU calc

AMLOEXT-110 FIX

Change-Id: I068924cc83288261102ea03e29449e0faf8686f9
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index fe0b8f8..55d2f25 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1191,6 +1191,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts, ft-Children[i],
 new OpAmordegrc));
 }
+else if ( !(pChild-GetExternal().compareTo(OUString(
+   com.sun.star.sheet.addin.Analysis.getAmorlinc
+{
+mvSubArguments.push_back(SoPHelper(ts, ft-Children[i],
+new OpAmorlinc));
+}
 break;
 default:
 throw UnhandledToken(pChild, unhandled opcode);
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index 5e2509a..92a7f14 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3063,7 +3063,159 @@ void 
OpAmordegrc::GenSlidingWindowFunction(std::stringstream ss,
 ss return tmp;\n;
 ss };
 }
-
+void OpAmorlinc::BinInlineFun(std::setstd::string decls,
+std::setstd::string funs)
+{
+decls.insert(nKorrValDecl); decls.insert(RoundDecl);
+decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
+decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
+decls.insert(GetNullDateDecl); decls.insert(GetYearFracDecl);
+funs.insert(Round);
+funs.insert(IsLeapYear);funs.insert(DaysInMonth);
+funs.insert(DaysToDate);funs.insert(DateToDays);
+funs.insert(GetNullDate);funs.insert(GetYearFrac);
+}
+void 

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

2013-11-05 Thread yangzhang
 sc/qa/unit/data/ods/opencl/math/Abs.ods  |binary
 sc/qa/unit/opencl-test.cxx   |   28 +++
 sc/source/core/opencl/formulagroupcl.cxx |5 
 sc/source/core/opencl/op_math.cxx|   32 +++
 sc/source/core/opencl/op_math.hxx|8 +++
 sc/source/core/tool/token.cxx|1 
 6 files changed, 74 insertions(+)

New commits:
commit 01f6f620395a86abe1e7f503ae4b3b5f7124e144
Author: yangzhang yangzh...@multicorewareinc.com
Date:   Mon Nov 4 15:36:56 2013 +0800

GPU Calc: implement fix for ABS

AMLOEXT-47 FIX

Change-Id: I438ad01d717dbc34ea8bc45e8f6de4f7d0c2bf2c
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index f0fd68b..d3ad8bc 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1023,6 +1023,11 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 case ocSinHyp:
 mvSubArguments.push_back(SoPHelper(ts,
  ft-Children[i],new OpSinh));
+break;
+case ocAbs:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft-Children[i], new OpAbs));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index 32d2eb5..b3afda2 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -110,6 +110,38 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream 
ss,
 ss  };
 }
 
+void OpAbs::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  ) {\n;
+ss  int gid0   = get_global_id(0);\n;
+ss  double tmp =   GetBottom()  ;\n;
+#ifdef ISNAN
+FormulaToken *tmpCur0 = vSubArguments[0]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR0=
+dynamic_castconst formula::SingleVectorRefToken *(tmpCur0);
+ss  int buffer_len = ;
+ss  tmpCurDVR0-GetArrayLength();
+ss  ;\n;
+ss  if((gid0)=buffer_len || isNan(;
+ss  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss  ))\n;
+ss  tmp =   GetBottom()  ;\nelse \n;
+#endif
+ss  tmp = ;
+ss  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss  ;\n;
+ss  return fabs(tmp);\n;
+ss  };
+}
 
 }}
 
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index 7399a6a..1e59c41 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -38,6 +38,14 @@ public:
 const std::string sSymName, SubArguments vSubArguments);
 virtual std::string BinFuncName(void) const { return Sinh; }
 };
+
+class OpAbs:public Normal{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments);
+virtual std::string GetBottom(void) { return 0.0; }
+virtual std::string BinFuncName(void) const { return ScAbs; }
+};
 }}
 
 #endif
commit 73cde39d6314fcc426165d1fea204f78de847ffb
Author: yangzhang yangzh...@multicorewareinc.com
Date:   Mon Nov 4 14:58:13 2013 +0800

GPU Calc: unit test cases for ABS

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-47 BUG

Change-Id: Ie33b4e5fad47f58a33ecdb0405521e7df694148c
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/ods/opencl/math/Abs.ods 
b/sc/qa/unit/data/ods/opencl/math/Abs.ods
new file mode 100644
index 000..2e55c73
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/Abs.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 88232aa..90867ba 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -123,6 +123,7 @@ public:
 void testFinancialDurationFormula();
 void testFinancialCoupnumFormula();
 void testMathFormulaSinh();
+void testMathFormulaAbs();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -177,6 +178,7 @@ public:
 CPPUNIT_TEST(testFinancialDurationFormula);
 CPPUNIT_TEST(testFinancialCoupnumFormula);
 CPPUNIT_TEST(testMathFormulaSinh);
+CPPUNIT_TEST(testMathFormulaAbs);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ 

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

2013-11-05 Thread yiming ju
 sc/qa/unit/data/xls/opencl/financial/PV.xls |binary
 sc/qa/unit/opencl-test.cxx  |   24 
 sc/source/core/opencl/formulagroupcl.cxx|4 
 sc/source/core/opencl/op_financial.cxx  |  144 
 sc/source/core/opencl/op_financial.hxx  |8 +
 sc/source/core/tool/token.cxx   |1 
 6 files changed, 181 insertions(+)

New commits:
commit c1492fe9ea81eb7d6af3e636f022a23fb7874b9d
Author: yiming ju yim...@multicorewareinc.com
Date:   Mon Nov 4 15:54:15 2013 +0800

GPU Calc: implement fix for PV

AMLOEXT-73 FIX

Change-Id: I0b9014a5d78165adaaa41c7e6cc05e876981f37d
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index d3ad8bc..c8c07e4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1028,6 +1028,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft-Children[i], new OpAbs));
 break;
+case ocBW:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft-Children[i], new OpPV));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index d5853f6..cb31cd1 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3388,6 +3388,150 @@ void OpTbillyield::GenSlidingWindowFunction(
 ss  }\n;
 }
 
+void OpPV::GenSlidingWindowFunction(
+std::stringstream ss, const std::string sSymName, SubArguments 
+vSubArguments)
+{
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  ) {\n;
+ss  double result =  0;\n;
+ss  int gid0 = get_global_id(0);\n;
+ss  double zins;\n;
+ss  double zzr;\n;
+ss  double rmz;\n;
+ss  double zw;\n;
+ss  double flag;\n;
+
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]-GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_castconst
+ formula::SingleVectorRefToken *(tmpCur0);
+
+ FormulaToken *tmpCur1 = vSubArguments[1]-GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_castconst
+ formula::SingleVectorRefToken *(tmpCur1);
+
+ FormulaToken *tmpCur2 = vSubArguments[2]-GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_castconst
+ formula::SingleVectorRefToken *(tmpCur2);
+
+ const formula::SingleVectorRefToken*tmpCurDVR3;
+ const formula::SingleVectorRefToken*tmpCurDVR4;
+
+if(vSubArguments.size()3)
+{
+FormulaToken *tmpCur3 = vSubArguments[3]-GetFormulaToken();
+tmpCurDVR3= dynamic_castconst formula::SingleVectorRefToken *(
+tmpCur3);
+ss int buffer_zw_len = ;
+ss tmpCurDVR3-GetArrayLength();
+ss  ;\n;
+}
+
+if(vSubArguments.size()4)
+{
+FormulaToken *tmpCur4 = vSubArguments[4]-GetFormulaToken();
+tmpCurDVR4= dynamic_castconst formula::SingleVectorRefToken *(
+tmpCur4);
+ss int buffer_flag_len = ;
+ss tmpCurDVR4-GetArrayLength();
+ss  ;\n;
+}
+
+ss int buffer_zins_len = ;
+ss tmpCurDVR0-GetArrayLength();
+ss  ;\n;
+
+ss int buffer_zzr_len = ;
+ss tmpCurDVR1-GetArrayLength();
+ss  ;\n;
+
+ss int buffer_rmz_len = ;
+ss tmpCurDVR2-GetArrayLength();
+ss  ;\n;
+
+#endif
+
+#ifdef ISNAN
+ssif(gid0=buffer_zins_len || isNan(;
+ss  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss))\n;
+sszins = 0;\nelse \n;
+#endif
+sszins = ;
+ss  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss;\n;
+
+#ifdef ISNAN
+ssif(gid0=buffer_zzr_len || isNan(;
+ss  vSubArguments[1]-GenSlidingWindowDeclRef();
+ss))\n;
+sszzr = 0;\nelse \n;
+#endif
+sszzr = ;
+ss  vSubArguments[1]-GenSlidingWindowDeclRef();
+ss;\n;
+
+#ifdef ISNAN
+ssif(gid0=buffer_rmz_len || isNan(;
+ss  vSubArguments[2]-GenSlidingWindowDeclRef();
+ss))\n;
+ssrmz = 0;\nelse \n;
+#endif
+ssrmz = ;
+ss  vSubArguments[2]-GenSlidingWindowDeclRef();
+ss;\n;
+
+if(vSubArguments.size()3)
+{
+#ifdef ISNAN
+ssif(gid0=buffer_zw_len || isNan(;
+ss  vSubArguments[3]-GenSlidingWindowDeclRef();
+ss))\n;
+sszw = 0;\nelse \n;
+#endif
+ss

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

2013-11-05 Thread fengzeng
 sc/qa/unit/data/xls/opencl/math/sin.xls  |binary
 sc/qa/unit/opencl-test.cxx   |   24 
 sc/source/core/opencl/formulagroupcl.cxx |4 
 sc/source/core/opencl/op_math.cxx|   30 +-
 sc/source/core/opencl/op_math.hxx|8 +++-
 sc/source/core/tool/token.cxx|1 +
 6 files changed, 65 insertions(+), 2 deletions(-)

New commits:
commit 8d460457876bbe696d6a2101ee49f81dedddb382
Author: fengzeng fengz...@multicorewareinc.com
Date:   Mon Nov 4 16:25:48 2013 +0800

GPU Calc: implement fix for SIN

AMLOEXT-58 FIX

Change-Id: I68d23a66fd46b239911f8ba686b0492ca7783267
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index c8c07e4..a0a2d3a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1032,6 +1032,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft-Children[i], new OpPV));
 break;
+case ocSin:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft-Children[i], new OpSin));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index b3afda2..3d7d4c9 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -109,7 +109,35 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream 
ss,
 ss  return tmp;\n;
 ss  };
 }
-
+void OpSin::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+FormulaToken *tmpCur = vSubArguments[0]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR= dynamic_castconst
+  formula::SingleVectorRefToken *(tmpCur);
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  )\n;
+ss  {\n;
+ss  int gid0=get_global_id(0);\n;
+ss  double arg0 =  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss  ;\n;
+#ifdef ISNAN
+ss  if(isNan(arg0)||(gid0=;
+ss  tmpCurDVR-GetArrayLength();
+ss  ))\n;
+ss  arg0 = 0;\n;
+#endif
+ss  double tmp=sin(arg0);\n;
+ss  return tmp;\n;
+ss  };
+}
 void OpAbs::GenSlidingWindowFunction(std::stringstream ss,
 const std::string sSymName, SubArguments vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index 1e59c41..1dbfec9 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -38,7 +38,13 @@ public:
 const std::string sSymName, SubArguments vSubArguments);
 virtual std::string BinFuncName(void) const { return Sinh; }
 };
-
+class OpSin: public Normal
+{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments);
+virtual std::string BinFuncName(void) const { return Sin; }
+};
 class OpAbs:public Normal{
 public:
 virtual void GenSlidingWindowFunction(std::stringstream ss,
commit 041d7146412750ded74bfe7e59c14e7ffd9d35ac
Author: fengzeng fengz...@multicorewareinc.com
Date:   Mon Nov 4 16:20:25 2013 +0800

GPU Calc: unit test cases for SIN

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-58 BUG

Change-Id: I484b86650e3e7bb11aa59aad6ae01be152aa2cef
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/math/sin.xls 
b/sc/qa/unit/data/xls/opencl/math/sin.xls
new file mode 100644
index 000..71ea0d1
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sin.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index de5bd74..415b99c 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -125,6 +125,7 @@ public:
 void testMathFormulaSinh();
 void testMathFormulaAbs();
 void testFinacialPVFormula();
+void testMathFormulaSin();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -181,6 +182,7 @@ public:
 CPPUNIT_TEST(testMathFormulaSinh);
 CPPUNIT_TEST(testMathFormulaAbs);
 CPPUNIT_TEST(testFinacialPVFormula);
+CPPUNIT_TEST(testMathFormulaSin);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1173,6 

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

2013-11-05 Thread fengzeng
 sc/qa/unit/data/xls/opencl/math/tan.xls  |binary
 sc/qa/unit/opencl-test.cxx   |   24 
 sc/source/core/opencl/formulagroupcl.cxx |4 
 sc/source/core/opencl/op_math.cxx|   30 +-
 sc/source/core/opencl/op_math.hxx|8 
 sc/source/core/tool/token.cxx|1 +
 6 files changed, 66 insertions(+), 1 deletion(-)

New commits:
commit ecda5dc6203cfefdb075984fb9826d33fc214c43
Author: fengzeng fengz...@multicorewareinc.com
Date:   Mon Nov 4 16:36:26 2013 +0800

GPU Calc: implemented TAN

AMLOEXT-60 FIX

Change-Id: Ibdbc0f22e152f5b73191f3a16e9e5489c0007fc3
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index a0a2d3a..a710f22 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1036,6 +1036,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft-Children[i], new OpSin));
 break;
+case ocTan:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft-Children[i], new OpTan));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index 3d7d4c9..c5c213c 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -170,7 +170,35 @@ void OpAbs::GenSlidingWindowFunction(std::stringstream ss,
 ss  return fabs(tmp);\n;
 ss  };
 }
-
+void OpTan::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+FormulaToken *tmpCur = vSubArguments[0]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR= dynamic_castconst
+  formula::SingleVectorRefToken *(tmpCur);
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  )\n;
+ss  {\n;
+ss  int gid0=get_global_id(0);\n;
+ss  double arg0 =  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss  ;\n;
+#ifdef ISNAN
+ss  if(isNan(arg0)||(gid0=;
+ss  tmpCurDVR-GetArrayLength();
+ss  ))\n;
+ss  arg0 = 0;\n;
+#endif
+ss  double tmp=tan(arg0);\n;
+ss  return tmp;\n;
+ss  };
+}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index 1dbfec9..ed5a4e9 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -52,6 +52,14 @@ public:
 virtual std::string GetBottom(void) { return 0.0; }
 virtual std::string BinFuncName(void) const { return ScAbs; }
 };
+class OpTan: public Normal
+{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments);
+
+virtual std::string BinFuncName(void) const { return Tan; }
+};
 }}
 
 #endif
commit e7ff395a3f70573c0dbb4093e86ffe57e935fece
Author: fengzeng fengz...@multicorewareinc.com
Date:   Mon Nov 4 16:32:44 2013 +0800

GPU Calc: unit test cases for TAN

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-60 BUG

Change-Id: I29433afcc8403fd6938d39667b18e786f4e5b6fc
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/math/tan.xls 
b/sc/qa/unit/data/xls/opencl/math/tan.xls
new file mode 100644
index 000..2a73718
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/tan.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 415b99c..87c6bad 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -126,6 +126,7 @@ public:
 void testMathFormulaAbs();
 void testFinacialPVFormula();
 void testMathFormulaSin();
+void testMathFormulaTan();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -183,6 +184,7 @@ public:
 CPPUNIT_TEST(testMathFormulaAbs);
 CPPUNIT_TEST(testFinacialPVFormula);
 CPPUNIT_TEST(testMathFormulaSin);
+CPPUNIT_TEST(testMathFormulaTan);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1197,6 +1199,28 @@ void ScOpenclTest::testMathFormulaSin()
 xDocSh-DoClose();
 xDocShRes-DoClose();
 }
+//[AMLOEXT-60]
+void ScOpenclTest::testMathFormulaTan()
+{
+if 

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

2013-11-05 Thread fengzeng
 sc/qa/unit/data/xls/opencl/math/tanh.xls |binary
 sc/qa/unit/opencl-test.cxx   |   24 
 sc/source/core/opencl/formulagroupcl.cxx |4 
 sc/source/core/opencl/op_math.cxx|   31 +++
 sc/source/core/opencl/op_math.hxx|8 
 sc/source/core/tool/token.cxx|1 +
 6 files changed, 68 insertions(+)

New commits:
commit 6786d9b887f821160f7d77b9a5854bc0b019b38a
Author: fengzeng fengz...@multicorewareinc.com
Date:   Mon Nov 4 16:50:16 2013 +0800

GPU Calc: implemented TANH

AMLOEXT-61 FIX

Change-Id: I7c8dcc23d85aa809f134446dcab97e51405d58c2
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index a710f22..cd040d6 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1040,6 +1040,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft-Children[i], new OpTan));
 break;
+case ocTanHyp:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft-Children[i], new OpTanH));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index c5c213c..d7286be 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -199,6 +199,37 @@ void OpTan::GenSlidingWindowFunction(std::stringstream ss,
 ss  return tmp;\n;
 ss  };
 }
+void OpTanH::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+FormulaToken *tmpCur = vSubArguments[0]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR= dynamic_castconst
+  formula::SingleVectorRefToken *(tmpCur);
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  )\n;
+ss  {\n;
+ss  int gid0=get_global_id(0);\n;
+ss  double arg0 =  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss  ;\n;
+#ifdef ISNAN
+ss  if(isNan(arg0)||(gid0=;
+ss  tmpCurDVR-GetArrayLength();
+ss  ))\n;
+ss  arg0 = 0;\n;
+#endif
+ss  double tmp=tanh(arg0);\n;
+ss  return tmp;\n;
+ss  };
+}
+
+
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index ed5a4e9..d7ce226 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -60,6 +60,14 @@ public:
 
 virtual std::string BinFuncName(void) const { return Tan; }
 };
+class OpTanH: public Normal
+{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments);
+
+virtual std::string BinFuncName(void) const { return TanH; }
+};
 }}
 
 #endif
commit f69d6457840216a87093a503a648ee3c34a04e78
Author: fengzeng fengz...@multicorewareinc.com
Date:   Mon Nov 4 16:47:01 2013 +0800

GPU Calc: unit test cases for TANH

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-61 BUG

Change-Id: I1db0693cdacdf437c413e56e3c97f0ff4d913211
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/math/tanh.xls 
b/sc/qa/unit/data/xls/opencl/math/tanh.xls
new file mode 100644
index 000..a19efd3
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/tanh.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 87c6bad..87414c0 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -127,6 +127,7 @@ public:
 void testFinacialPVFormula();
 void testMathFormulaSin();
 void testMathFormulaTan();
+void testMathFormulaTanH();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -185,6 +186,7 @@ public:
 CPPUNIT_TEST(testFinacialPVFormula);
 CPPUNIT_TEST(testMathFormulaSin);
 CPPUNIT_TEST(testMathFormulaTan);
+CPPUNIT_TEST(testMathFormulaTanH);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1221,6 +1223,28 @@ void ScOpenclTest::testMathFormulaTan()
 xDocSh-DoClose();
 xDocShRes-DoClose();
 }
+//[AMLOEXT-61]
+void ScOpenclTest::testMathFormulaTanH()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef 

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

2013-11-05 Thread shiming zhang
 sc/qa/unit/data/xls/opencl/statistical/Standard.xls |binary
 sc/qa/unit/opencl-test.cxx  |   27 +
 sc/source/core/opencl/formulagroupcl.cxx|4 
 sc/source/core/opencl/op_statistical.cxx|  107 
 sc/source/core/opencl/op_statistical.hxx|8 +
 sc/source/core/tool/token.cxx   |1 
 6 files changed, 147 insertions(+)

New commits:
commit f1d75291e3e04c636b4dc2c44827d85b0263c46b
Author: shiming zhang shim...@multicorewareinc.com
Date:   Mon Nov 4 17:05:54 2013 +0800

GPU Calc: implemented STANDARDIZE

AMLOEXT-77 FIX

Change-Id: I5f91d497417e87a489728949a4436f33ed3da235
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index cd040d6..a68188c 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1044,6 +1044,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft-Children[i], new OpTanH));
 break;
+case ocStandard:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft-Children[i], new OpStandard));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_statistical.cxx 
b/sc/source/core/opencl/op_statistical.cxx
index 134a0ca..4128507 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -22,6 +22,113 @@ using namespace formula;
 
 namespace sc { namespace opencl {
 
+void OpStandard::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+ss  \ndouble   sSymName;
+ss  _  BinFuncName()  (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  ) {\n;
+ss  double tmp = 0;\n;
+ss  int gid0 = get_global_id(0);\n;
+ss  double x,mu,sigma;\n;
+if(vSubArguments.size() != 3)
+{
+ss  return DBL_MAX;\n  }\n;
+return ;
+}
+FormulaToken *tmpCur0 = vSubArguments[0]-GetFormulaToken();
+assert(tmpCur0);
+if(tmpCur0-GetType() == formula::svSingleVectorRef)
+{
+const formula::SingleVectorRefToken*tmpCurDVR0 =
+dynamic_castconst formula::SingleVectorRefToken *(tmpCur0);
+#ifdef ISNAN
+ss  int buffer_x_len = ;
+ss  tmpCurDVR0-GetArrayLength()  ;\n;
+ss  if(gid0=buffer_x_len || isNan(;
+ss  vSubArguments[0]-GenSlidingWindowDeclRef()  ))\n;
+ss  x = 0.0;\n;
+ss  else\n;
+#endif
+ss  x = ;
+ss  vSubArguments[0]-GenSlidingWindowDeclRef()  ;\n;
+}
+else if(tmpCur0-GetType() == formula::svDouble)
+{
+ss  x= tmpCur0-GetDouble()  ;\n;
+}
+else
+{
+ss  return DBL_MAX;\n  }\n;
+return ;
+}
+FormulaToken *tmpCur1 = vSubArguments[1]-GetFormulaToken();
+assert(tmpCur1);
+if(tmpCur1-GetType() == formula::svSingleVectorRef)
+{
+const formula::SingleVectorRefToken*tmpCurDVR1 =
+dynamic_castconst formula::SingleVectorRefToken *(tmpCur1);
+#ifdef ISNAN
+ss  int buffer_mu_len = ;
+ss  tmpCurDVR1-GetArrayLength()  ;\n;
+ss  if(gid0=buffer_mu_len || isNan(;
+ss  vSubArguments[1]-GenSlidingWindowDeclRef()  ))\n;
+ss  mu = 0.0;\n;
+ss  else\n;
+#endif
+ss  mu = ;
+ss  vSubArguments[1]-GenSlidingWindowDeclRef()  ;\n;
+}
+else if(tmpCur1-GetType() == formula::svDouble)
+{
+ss  mu= tmpCur1-GetDouble()  ;\n;
+}
+else
+{
+ss  return DBL_MAX;\n  }\n;
+return ;
+}
+
+FormulaToken *tmpCur2 = vSubArguments[2]-GetFormulaToken();
+assert(tmpCur2);
+if(tmpCur2-GetType() == formula::svSingleVectorRef)
+{
+const formula::SingleVectorRefToken*tmpCurDVR2 =
+dynamic_castconst formula::SingleVectorRefToken *(tmpCur2);
+#ifdef ISNAN
+ss  int buffer_sigma_len = ;
+ss  tmpCurDVR2-GetArrayLength()  ;\n;
+ss  if(gid0=buffer_sigma_len || isNan(;
+ss  vSubArguments[2]-GenSlidingWindowDeclRef()  ))\n;
+ss  sigma = 0.0;\n;
+ss  else\n;
+#endif
+ss  sigma = ;
+ss  vSubArguments[2]-GenSlidingWindowDeclRef()  ;\n;
+}
+else if(tmpCur2-GetType() == formula::svDouble)
+{
+ss  sigma= tmpCur2-GetDouble()  ;\n;
+}
+else
+  

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

2013-11-03 Thread xinjiang
 sc/qa/unit/data/xls/opencl/financial/ISPMT.xls |binary
 sc/qa/unit/opencl-test.cxx |   24 +
 sc/source/core/opencl/formulagroupcl.cxx   |3 +
 sc/source/core/opencl/op_financial.cxx |   45 +
 sc/source/core/opencl/op_financial.hxx |   11 ++
 sc/source/core/tool/token.cxx  |1 
 6 files changed, 84 insertions(+)

New commits:
commit 1c239f51064e30713ac87abd3697d73bc5e5bcc1
Author: xinjiang xinji...@multicorewareinc.com
Date:   Mon Nov 4 10:40:51 2013 +0800

GPU Calc: implemented ISPMT in GPU calc

AMLOEXT-99 FIX

Change-Id: I8cd9f130c190e6925873a00579cb7c334201f418
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index d4dada6..9610a4a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1013,6 +1013,9 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 case ocCosecant:
 mvSubArguments.push_back(SoPHelper(ts, ft-Children[i], new 
OpCsc));
 break;
+case ocISPMT:
+mvSubArguments.push_back(SoPHelper(ts, ft-Children[i], new 
OpISPMT));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index 329dd77..503087b 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -487,6 +487,51 @@ void OpINTRATE::GenSlidingWindowFunction(
 ss  };
 }
 
+void OpISPMT::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  ) {\n;
+ss  double tmp =   GetBottom()  ;\n;
+ss  int gid0 = get_global_id(0);\n;
+ss  double arg0 =   GetBottom()  ;\n;
+ss  double arg1 =   GetBottom()  ;\n;
+ss  double arg2 =   GetBottom()  ;\n;
+ss  double arg3 =   GetBottom()  ;\n;
+unsigned i = vSubArguments.size();
+while (i--)
+{
+FormulaToken* pCur = vSubArguments[i]-GetFormulaToken();
+assert(pCur);
+if(pCur-GetType() == formula::svSingleVectorRef)
+{
+#ifdef  ISNAN
+const formula::SingleVectorRefToken* pSVR =
+dynamic_cast const formula::SingleVectorRefToken* (pCur);
+ss  if(gid0 =   pSVR-GetArrayLength()   || isNan(;
+ss  vSubArguments[i]-GenSlidingWindowDeclRef();
+ss  ))\n;
+ss  arg  i   =  GetBottom()  ;\n;
+ss  else\n;
+#endif
+ss  arg  i   = ;
+ss  vSubArguments[i]-GenSlidingWindowDeclRef();
+ss  ;\n;
+}
+}
+ss  tmp = arg3 * arg0 * ( arg1 / arg2 - 1.0);\n;
+ss  return tmp;\n;
+ss  };
+}
+
+
 void Fvschedule::GenSlidingWindowFunction(
 std::stringstream ss, const std::string sSymName, SubArguments 
vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_financial.hxx 
b/sc/source/core/opencl/op_financial.hxx
index 7a79dde..6add67f 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -86,6 +86,17 @@ public:
 virtual std::string BinFuncName(void) const { return INTRATE; }
 };
 
+class OpISPMT: public Normal
+{
+public:
+virtual std::string GetBottom(void) { return 0; }
+
+virtual void GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments);
+
+virtual std::string BinFuncName(void) const { return ISPMT; }
+};
+
 class Fvschedule: public Normal
 {
 public:
commit 12a86d12e9be04b5ce3df946e6c7b5a065533cbd
Author: xinjiang xinji...@multicorewareinc.com
Date:   Mon Nov 4 10:36:28 2013 +0800

GPU Calc: unit test cases for ISPMT in GPU calc

AMLOEXT-99 BUG

Change-Id: I4388b184b23cf616dacfb20c61d2295765925ede
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/xls/opencl/financial/ISPMT.xls 
b/sc/qa/unit/data/xls/opencl/financial/ISPMT.xls
new file mode 100644
index 000..8759e7e
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/ISPMT.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index c8cf326..dd626cd 100644
--- 

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

2013-11-03 Thread xinjiang
 sc/qa/unit/data/ods/opencl/financial/Duration.ods |binary
 sc/qa/unit/opencl-test.cxx|   24 
 sc/source/core/opencl/formulagroupcl.cxx  |4 ++
 sc/source/core/opencl/op_financial.cxx|   42 ++
 sc/source/core/opencl/op_financial.hxx|   12 ++
 sc/source/core/tool/token.cxx |1 
 6 files changed, 83 insertions(+)

New commits:
commit 0644c59f1e2822c687ef0366f6c02b3b21a3f01a
Author: xinjiang xinji...@multicorewareinc.com
Date:   Mon Nov 4 11:18:04 2013 +0800

GPU Calc: implemented DURATION

AMLOEXT-111 FIX

Change-Id: I114e5b20326657f7fd3e0de7162a8ae190059b2a
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index ce3223e..24647bf 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1016,6 +1016,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 case ocISPMT:
 mvSubArguments.push_back(SoPHelper(ts, ft-Children[i], new 
OpISPMT));
 break;
+case ocLaufz:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft-Children[i], new OpDuration));
+break;
 case ocExternal:
 if ( !(pChild-GetExternal().compareTo(OUString(
 com.sun.star.sheet.addin.Analysis.getEffect
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index f9f1fa6..a40a113 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -531,6 +531,48 @@ void OpISPMT::GenSlidingWindowFunction(std::stringstream 
ss,
 ss  };
 }
 
+void OpDuration::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+if (i)
+ss  ,;
+vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  ) {\n;
+ss  double tmp =   GetBottom()  ;\n;
+ss  int gid0 = get_global_id(0);\n;
+ss  double arg0 =   GetBottom()  ;\n;
+ss  double arg1 =   GetBottom()  ;\n;
+ss  double arg2 =   GetBottom()  ;\n;
+unsigned i = vSubArguments.size();
+while (i--)
+{
+FormulaToken* pCur = vSubArguments[i]-GetFormulaToken();
+assert(pCur);
+if(pCur-GetType() == formula::svSingleVectorRef)
+{
+#ifdef  ISNAN
+const formula::SingleVectorRefToken* pSVR =
+dynamic_cast const formula::SingleVectorRefToken* (pCur);
+ss  if(gid0 =   pSVR-GetArrayLength()   || isNan(;
+ss  vSubArguments[i]-GenSlidingWindowDeclRef();
+ss  ))\n;
+ss  arg  i   =  GetBottom()  ;\n;
+ss  else\n;
+#endif
+ss  arg  i   = ;
+ss  vSubArguments[i]-GenSlidingWindowDeclRef();
+ss  ;\n;
+}
+}
+ss  tmp = log(arg2 / arg1) / log(arg0 + 1.0);\n;
+ss  return tmp;\n;
+ss  };
+}
 
 void Fvschedule::GenSlidingWindowFunction(
 std::stringstream ss, const std::string sSymName, SubArguments 
vSubArguments)
diff --git a/sc/source/core/opencl/op_financial.hxx 
b/sc/source/core/opencl/op_financial.hxx
index cd62f82..fc73076 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -97,6 +97,18 @@ public:
 virtual std::string BinFuncName(void) const { return ISPMT; }
 };
 
+class OpDuration: public Normal
+{
+public:
+virtual std::string GetBottom(void) { return 0; }
+
+virtual void GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments);
+
+virtual std::string BinFuncName(void) const { return Duration; }
+};
+
+
 class Fvschedule: public Normal
 {
 public:
commit d454a57acd6bada1cd6913a7c42f8bf3f0a39a70
Author: xinjiang xinji...@multicorewareinc.com
Date:   Mon Nov 4 11:12:17 2013 +0800

GPU Calc: unit test cases for DURATION

AMLOEXT-111 BUG

Change-Id: I1d206b0eda0dca8254f0491399d0a4679eb39ef8
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/qa/unit/data/ods/opencl/financial/Duration.ods 
b/sc/qa/unit/data/ods/opencl/financial/Duration.ods
new file mode 100644
index 000..d884dfe
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/financial/Duration.ods 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 7264c7e..0d228d5 100644

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

2013-11-03 Thread minwang
 sc/qa/unit/data/xls/opencl/financial/Coupnum.xls |binary
 sc/qa/unit/opencl-test.cxx   |   25 +
 sc/source/core/opencl/formulagroupcl.cxx |6 +
 sc/source/core/opencl/op_financial.cxx   |   97 ++-
 sc/source/core/opencl/op_financial.hxx   |9 ++
 5 files changed, 136 insertions(+), 1 deletion(-)

New commits:
commit 457b349edbaf6d9dc747f3a631fee70e0c035bae
Author: minwang m...@multicorewareinc.com
Date:   Mon Nov 4 11:32:43 2013 +0800

GPU Calc: implemented COUPNUM

AMLOEXT-74 FIX

Change-Id: Ic7f274f089f7f6cc6b767c4a07844014eeded61d
Signed-off-by: haochen haoc...@multicorewareinc.com
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 24647bf..1cc0b9f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1137,6 +1137,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
   ft-Children[i], new OpPrice));
 }
+else if ( !(pChild-GetExternal().compareTo(OUString(
+ com.sun.star.sheet.addin.Analysis.getCoupnum
+{
+mvSubArguments.push_back(SoPHelper(ts, ft-Children[i],
+new OpCoupnum));
+}
 break;
 default:
 throw UnhandledToken(pChild, unhandled opcode);
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index a40a113..b5b9a5c 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2740,7 +2740,102 @@ void OpCoupdaysnc::GenSlidingWindowFunction(
 ss  };
 }
 
- void OpReceived::BinInlineFun(std::setstd::string decls,
+void OpCoupnum::BinInlineFun(std::setstd::string decls,
+std::setstd::string funs)
+{
+decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
+decls.insert(DaysToDateDecl);decls.insert(DateToDaysDecl);
+decls.insert(GetNullDateDecl);decls.insert(lcl_GetcoupnumDecl);
+decls.insert(coupnumDecl);
+funs.insert(IsLeapYear);funs.insert(DaysInMonth);
+funs.insert(DaysToDate);funs.insert(DateToDays);
+funs.insert(GetNullDate);
+funs.insert(lcl_Getcoupnum);
+funs.insert(coupnum);
+}
+void OpCoupnum::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
+{
+ss  \ndouble   sSymName;
+ss  _ BinFuncName() (;
+for (unsigned i = 0; i  vSubArguments.size(); i++)
+{
+  if (i)
+  ss  ,;
+  vSubArguments[i]-GenSlidingWindowDecl(ss);
+}
+ss  ) {\n;
+ss  double tmp =   GetBottom() ;\n;
+ss  int gid0 = get_global_id(0);\n;
+ss  int nSettle,nMat,nFreq,nBase;\n;
+#ifdef ISNAN
+FormulaToken* tmpCur0 = vSubArguments[0]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_castconst
+formula::SingleVectorRefToken *(tmpCur0);
+FormulaToken* tmpCur1 = vSubArguments[1]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_castconst
+formula::SingleVectorRefToken *(tmpCur1);
+FormulaToken* tmpCur2 = vSubArguments[2]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_castconst
+formula::SingleVectorRefToken *(tmpCur2);
+FormulaToken* tmpCur3 = vSubArguments[3]-GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_castconst
+formula::SingleVectorRefToken *(tmpCur3);
+ss int buffer_nSettle_len = ;
+ss tmpCurDVR0-GetArrayLength();
+ss  ;\n;
+ss int buffer_nMat_len = ;
+ss tmpCurDVR1-GetArrayLength();
+ss  ;\n;
+ss int buffer_nFreq_len = ;
+ss tmpCurDVR2-GetArrayLength();
+ss  ;\n;
+ss int buffer_nBase_len = ;
+ss tmpCurDVR3-GetArrayLength();
+ss  ;\n;
+#endif
+#ifdef ISNAN
+ss if(gid0 = buffer_nSettle_len || isNan(;
+ss vSubArguments[0]-GenSlidingWindowDeclRef();
+ss ))\n;
+ss nSettle = 0;\nelse\n;
+#endif
+ss  nSettle=(int);
+ss  vSubArguments[0]-GenSlidingWindowDeclRef();
+ss ;\n;
+#ifdef ISNAN
+ss if(gid0 = buffer_nMat_len || isNan(;
+ss vSubArguments[1]-GenSlidingWindowDeclRef();
+ss ))\n;
+ss nMat = 0;\nelse\n;
+#endif
+ss  nMat=(int);
+ss  vSubArguments[1]-GenSlidingWindowDeclRef();
+ss  ;\n;
+#ifdef ISNAN
+ss if(gid0 = buffer_nFreq_len || isNan(;
+ss vSubArguments[2]-GenSlidingWindowDeclRef();
+ss ))\n;
+ss nFreq = 0;\nelse\n;
+#endif
+ss  nFreq=(int);
+ss  vSubArguments[2]-GenSlidingWindowDeclRef();
+ss ;\n;
+#ifdef ISNAN
+ss if(gid0 = buffer_nBase_len || isNan(;
+ss 

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

2013-11-01 Thread mulei
 sc/qa/unit/data/xls/opencl/financial/PMT.xls |binary
 sc/qa/unit/opencl-test.cxx   |   25 +
 sc/source/core/opencl/op_financial.cxx   |  130 +--
 3 files changed, 127 insertions(+), 28 deletions(-)

New commits:
commit 35f8d734dd54cafd1e9d07a1e67b63c366b93a9d
Author: mulei mu...@multicorewareinc.com
Date:   Fri Nov 1 12:02:35 2013 -0500

GPU Calc: implement NAN argument handling in PMT

Change-Id: I1288a20652b4ceb66d90314f7acddb73506dfb43
Signed-off-by: I-Jui (Ray) Sung r...@multicorewareinc.com
Signed-off-by: haochen haoc...@multicorewareinc.com

diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index da4845c..69f7d02 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -1837,44 +1837,118 @@ void OpYieldmat::GenSlidingWindowFunction(
 ss  };
 }
 
-void OpPMT::GenSlidingWindowFunction(
-std::stringstream ss, const std::string sSymName, SubArguments 
vSubArguments)
+void OpPMT::GenSlidingWindowFunction(std::stringstream ss,
+const std::string sSymName, SubArguments vSubArguments)
 {
 ss  \ndouble   sSymName;
 ss  _ BinFuncName() (;
 for (unsigned i = 0; i  vSubArguments.size(); i++)
 {
 if (i)
-ss  ,;
+ss  , ;
 vSubArguments[i]-GenSlidingWindowDecl(ss);
 }
-ss  ) {\n\t;
-ss  double tmp = 0;\n\t;
-ssdouble tFv=0,tType=0;\n\t;
-ss  int gid0 = get_global_id(0);\n\t;
- if(vSubArguments.size()==4)
-sstFv=vSubArguments[3]-GenSlidingWindowDeclRef();\n\t;
-else if(vSubArguments.size()==5)
+ss  ) {\n;
+ss  double tmp = 0;\n;
+ss  int gid0 = get_global_id(0);\n;
+ssdouble tmp0,tmp1,tmp2;\n;
+ssdouble tmp3=0,tmp4=0;\n;
+unsigned i = vSubArguments.size();
+size_t nItems = 0;
+ss \n;
+//while (i--  1)
+for (size_t i = 0; i  vSubArguments.size(); i++)
 {
-sstType=vSubArguments[4]-GenSlidingWindowDeclRef();
-ss;\n\t;
-sstFv=vSubArguments[3]-GenSlidingWindowDeclRef();
-ss;\n\t;
+FormulaToken *pCur = vSubArguments[i]-GetFormulaToken();
+assert(pCur);
+if (pCur-GetType() == formula::svDoubleVectorRef)
+{
+const formula::DoubleVectorRefToken* pDVR =
+dynamic_castconst formula::DoubleVectorRefToken *(pCur);
+size_t nCurWindowSize = pDVR-GetRefRowSize();
+ss  for (int i = ;
+if (!pDVR-IsStartFixed()  pDVR-IsEndFixed()) {
+#ifdef  ISNAN
+ss  gid0; ipDVR-GetArrayLength();
+ssinCurWindowSize   ; i++){\n;
+#else
+ss  gid0; i   nCurWindowSize  ; i++)\n;
+#endif
+} else if (pDVR-IsStartFixed()  !pDVR-IsEndFixed()) {
+#ifdef  ISNAN
+ss  0; ipDVR-GetArrayLength();
+ssi  gid0+ nCurWindowSize  ; i++){\n;
+#else
+ss  0; i  gid0+ nCurWindowSize  ; i++)\n;
+#endif
+} else if (!pDVR-IsStartFixed()  !pDVR-IsEndFixed()){
+#ifdef  ISNAN
+ss  0; i + gid0pDVR-GetArrayLength();
+ss i   nCurWindowSize  ; i++){\n;
+#else
+ss  0; i   nCurWindowSize  ; i++)\n;
+#endif
+}
+else {
+#ifdef  ISNAN
+ss  0; i   nCurWindowSize  ; i++){\n;
+#else
+ss  0; i   nCurWindowSize  ; i++)\n;
+#endif
+}
+nItems += nCurWindowSize;
+}
+else if (pCur-GetType() == formula::svSingleVectorRef)
+{
+#ifdef  ISNAN
+const formula::SingleVectorRefToken* pSVR =
+dynamic_cast const formula::SingleVectorRefToken* (pCur);
+ss  if (gid0pSVR-GetArrayLength()  ){\n;
+#else
+nItems += 1;
+#endif
+}
+else if (pCur-GetType() == formula::svDouble)
+{
+#ifdef  ISNAN
+ss  {\n;
+#endif
+nItems += 1;
+}
+else
+{
+#ifdef  ISNAN
+#endif
+nItems += 1;
+}
+#ifdef  ISNAN
+if(ocPush==vSubArguments[i]-GetFormulaToken()-GetOpCode())
+{
+ss  if (isNan(;
+ss  vSubArguments[i]-GenSlidingWindowDeclRef();
+ss  ))\n;
+ss  tmpi= 0;\n;
+ss  else\n;
+ss  tmpi=vSubArguments[i]-GenSlidingWindowDeclRef();
+ss  ;\n}\n;
+}
+else
+{
+ss  tmpi=vSubArguments[i]-GenSlidingWindowDeclRef();
+ss ;\n;
+}
+#else
+ss  tmpi=vSubArguments[i]-GenSlidingWindowDeclRef();
+ss ;\n;
+
+#endif
 }
-ssif(vSubArguments[0]-GenSlidingWindowDeclRef()==0.0)\n\t;
-ss\treturn (vSubArguments[2]-GenSlidingWindowDeclRef();
-ss+tFv)/;
-

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

2013-08-26 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |  183 --
 sc/source/filter/xml/xmlcelli.cxx |   16 +-
 sc/source/filter/xml/xmlcelli.hxx |2 
 3 files changed, 183 insertions(+), 18 deletions(-)

New commits:
commit 969d5a3b97903fe32b3a7da0c3de8bf86f323c17
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Aug 26 15:28:46 2013 -0400

fdo#68581: The first paragraph text can be legitimately empty.

Change-Id: I2309a0c6aebc8a111e67e2e3d591cbabfbbadfb4

diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 69f5a73..1f17009 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -600,10 +600,10 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 
nBegin, sal_Int32 nEnd, cons
 
 OUString ScXMLTableRowCellContext::GetFirstParagraph() const
 {
-if (maFirstParagraph.isEmpty())
+if (!maFirstParagraph)
 return mpEditEngine-GetText(0);
 
-return maFirstParagraph;
+return *maFirstParagraph;
 }
 
 void ScXMLTableRowCellContext::PushParagraphFieldDate(const OUString 
rStyleName)
@@ -635,12 +635,12 @@ void ScXMLTableRowCellContext::PushParagraphEnd()
 
 if (mbEditEngineHasText)
 {
-if (!maFirstParagraph.isEmpty())
+if (maFirstParagraph)
 {
 // Flush the cached first paragraph first.
 mpEditEngine-Clear();
-mpEditEngine-SetText(maFirstParagraph);
-maFirstParagraph = OUString();
+mpEditEngine-SetText(*maFirstParagraph);
+maFirstParagraph.reset();
 }
 mpEditEngine-InsertParagraph(mpEditEngine-GetParagraphCount(), 
maParagraph.makeStringAndClear());
 }
@@ -652,7 +652,7 @@ void ScXMLTableRowCellContext::PushParagraphEnd()
 }
 else if (mnCurParagraph == 0)
 {
-maFirstParagraph = maParagraph.makeStringAndClear();
+maFirstParagraph.reset(maParagraph.makeStringAndClear());
 mbEditEngineHasText = true;
 }
 
@@ -1089,10 +1089,10 @@ void ScXMLTableRowCellContext::PutTextCell( const 
ScAddress rCurrentPos,
 }
 else if (mbEditEngineHasText)
 {
-if (!maFirstParagraph.isEmpty())
+if (maFirstParagraph)
 {
 // This is a normal text without format runs.
-rDoc.setStringCell(rCurrentPos, maFirstParagraph);
+rDoc.setStringCell(rCurrentPos, *maFirstParagraph);
 }
 else
 {
diff --git a/sc/source/filter/xml/xmlcelli.hxx 
b/sc/source/filter/xml/xmlcelli.hxx
index e49e3a3..15c95fb 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -63,9 +63,9 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
 boost::optionalFormulaWithNamespace maFormula; /// table:formula 
attribute
 boost::optionalOUString maStringValue; /// office:string-value 
attribute
 boost::optionalOUString maContentValidationName;
+boost::optionalOUString maFirstParagraph; /// unformatted first 
paragraph, for better performance.
 
 ScEditEngineDefaulter* mpEditEngine;
-OUString maFirstParagraph; /// unformatted first paragraph, for better 
performance.
 OUStringBuffer maParagraph;
 sal_Int32 mnCurParagraph;
 
commit 70e582c8cd3f5f0eedfead6c9da8c771db34e49b
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Mon Aug 26 15:11:33 2013 -0400

Add more test cases for rich text cell export to ODS.

This currently fails due to a real bug.

Change-Id: Ia8a91f0794837cae2b6c3beab656f3377f3d0f6a

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 6ec6550..b805e4f 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -36,6 +36,8 @@
 #include editeng/postitem.hxx
 #include editeng/editdata.hxx
 #include editeng/eeitem.hxx
+#include editeng/editobj.hxx
+#include editeng/sectionattribute.hxx
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -343,10 +345,140 @@ void ScExportTest::testNamedRangeBugfdo62729()
 
 void ScExportTest::testRichTextExportODS()
 {
+struct
+{
+static bool isBold(const editeng::SectionAttribute rAttr)
+{
+if (rAttr.maAttributes.empty())
+return false;
+
+std::vectorconst SfxPoolItem*::const_iterator it = 
rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end();
+for (; it != itEnd; ++it)
+{
+const SfxPoolItem* p = *it;
+if (p-Which() != EE_CHAR_WEIGHT)
+continue;
+
+return static_castconst SvxWeightItem*(p)-GetWeight() == 
WEIGHT_BOLD;
+}
+return false;
+}
+
+static bool isItalic(const editeng::SectionAttribute rAttr)
+{
+if (rAttr.maAttributes.empty())
+return false;

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

2013-07-31 Thread Kohei Yoshida
 sc/qa/extras/macros-test.cxx  |2 --
 sc/qa/unit/ucalc_formula.cxx  |   18 ++
 sc/source/core/tool/token.cxx |   38 ++
 3 files changed, 52 insertions(+), 6 deletions(-)

New commits:
commit 3bade6b47973a228723b240b9410f15891487812
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Jul 31 21:10:50 2013 -0400

Fix reference update on range references in named expressions.

This fixes the macro test failure.

Change-Id: I8dd49d1faf36cc37212895c21023a4ab6135

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 9bc3a0f..023f627 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -198,12 +198,10 @@ void ScMacrosTest::testVba()
 OUString(Shapes.),
 
OUString(vnd.sun.Star.script:VBAProject.testMacros.test?language=Basiclocation=document)
 },
-#if 0 // TODO : fix this
 {
 OUString(Ranges.),
 
OUString(vnd.sun.Star.script:VBAProject.testMacros.test?language=Basiclocation=document)
 },
-#endif
 {
 OUString(CheckOptionToggleValue.),
 
OUString(vnd.sun.Star.script:VBAProject.testMacros.test?language=Basiclocation=document)
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 83094d2..4703cde 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2598,6 +2598,20 @@ bool adjustSingleRefInName(
 return bChanged;
 }
 
+bool adjustDoubleRefInName(
+ScComplexRefData rRef, const sc::RefUpdateContext rCxt, const ScAddress 
rPos )
+{
+bool bRefChanged = false;
+
+if (adjustSingleRefInName(rRef.Ref1, rCxt, rPos))
+bRefChanged = true;
+
+if (adjustSingleRefInName(rRef.Ref2, rCxt, rPos))
+bRefChanged = true;
+
+return bRefChanged;
+}
+
 }
 
 sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
@@ -2623,10 +2637,26 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
 {
 ScToken* pToken = static_castScToken*(*p);
 ScComplexRefData rRef = pToken-GetDoubleRef();
-if (adjustSingleRefInName(rRef.Ref1, rCxt, rPos))
-aRes.mbReferenceModified = true;
-if (adjustSingleRefInName(rRef.Ref2, rCxt, rPos))
-aRes.mbReferenceModified = true;
+ScRange aAbs = rRef.toAbs(rPos);
+if (rCxt.maRange.In(aAbs))
+{
+// This range is entirely within the shifted region.
+if (adjustDoubleRefInName(rRef, rCxt, rPos))
+aRes.mbReferenceModified = true;
+}
+else if (rCxt.maRange.Intersects(aAbs))
+{
+if (rCxt.mnColDelta  rCxt.maRange.aStart.Row() = 
aAbs.aStart.Row()  aAbs.aEnd.Row() = rCxt.maRange.aEnd.Row())
+{
+if (adjustDoubleRefInName(rRef, rCxt, rPos))
+aRes.mbReferenceModified = true;
+}
+if (rCxt.mnRowDelta  rCxt.maRange.aStart.Col() = 
aAbs.aStart.Col()  aAbs.aEnd.Col() = rCxt.maRange.aEnd.Col())
+{
+if (adjustDoubleRefInName(rRef, rCxt, rPos))
+aRes.mbReferenceModified = true;
+}
+}
 }
 break;
 default:
commit 10dfaebc6cc2191745d4d7323596bb8e22c9d029
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Wed Jul 31 19:19:41 2013 -0400

Add test on updating references in named range.

This currently fails.

Change-Id: Ibb2b9e4430c97479d068d94d233f04f60b255966

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index f731f2a..e85c01c55 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1064,6 +1064,24 @@ void Test::testFormulaRefUpdateNamedExpression()
 CPPUNIT_ASSERT_EQUAL(34.0, m_pDoc-GetValue(ScAddress(2,7,0)));
 #endif
 
+// Clear all and start over.
+clearRange(m_pDoc, ScRange(0,0,0,100,100,0));
+pGlobalNames-clear();
+
+pName = new ScRangeData(
+m_pDoc, MyRange, $B$1:$C$6, ScAddress(0,0,0), RT_NAME, 
formula::FormulaGrammar::GRAM_NATIVE);
+bInserted = pGlobalNames-insert(pName);
+CPPUNIT_ASSERT_MESSAGE(Failed to insert a new name., bInserted);
+pName-GetSymbol(aExpr);
+CPPUNIT_ASSERT_EQUAL(OUString($B$1:$C$6), aExpr);
+
+// Insert range of cells to shift right. The range partially overlaps the 
named range.
+m_pDoc-InsertCol(ScRange(2,4,0,3,8,0));
+
+// This should not alter the range.
+pName-GetSymbol(aExpr);
+CPPUNIT_ASSERT_EQUAL(OUString($B$1:$C$6), aExpr);
+
 m_pDoc-DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

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

2013-07-26 Thread Noel Power
 sc/qa/unit/data/ods/fdo62729.ods  |binary
 sc/qa/unit/subsequent_export-test.cxx |   30 ++
 sc/source/filter/xml/xmlexprt.cxx |1 +
 3 files changed, 31 insertions(+)

New commits:
commit 7b3d8e0a7dcf6ae05e1de5c33ed382822cf52cce
Author: Noel Power noel.po...@suse.com
Date:   Fri Jul 26 13:13:37 2013 +0100

unit test for fdo#62729

Change-Id: Ib9be75459aa49b8bab968dedae9e0760ccef9a26

diff --git a/sc/qa/unit/data/ods/fdo62729.ods b/sc/qa/unit/data/ods/fdo62729.ods
new file mode 100644
index 000..00b5079
Binary files /dev/null and b/sc/qa/unit/data/ods/fdo62729.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 05b0c35..600bc5a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -49,6 +49,7 @@ public:
 void testDataBarExportODS();
 void testDataBarExportXLSX();
 void testMiscRowHeightExport();
+void testNamedRangeBugfdo62729();
 
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
@@ -60,6 +61,7 @@ public:
 CPPUNIT_TEST(testColorScaleExportODS);
 CPPUNIT_TEST(testColorScaleExportXLSX);
 CPPUNIT_TEST(testMiscRowHeightExport);
+CPPUNIT_TEST(testNamedRangeBugfdo62729);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -289,6 +291,34 @@ void ScExportTest::testMiscRowHeightExport()
 miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) );
 }
 
+
+void ScExportTest::testNamedRangeBugfdo62729()
+{
+ScDocShellRef xShell = loadDoc(fdo62729., ODS);
+CPPUNIT_ASSERT(xShell.Is());
+ScDocument* pDoc = xShell-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+ScRangeName* pNames = pDoc-GetRangeName();
+//should be just a single named range
+CPPUNIT_ASSERT(pNames-size() == 1 );
+pDoc-DeleteTab(0);
+//should be still a single named range
+CPPUNIT_ASSERT(pNames-size() == 1 );
+ScDocShellRef xDocSh = saveAndReload(xShell, ODS);
+xShell-DoClose();
+
+CPPUNIT_ASSERT(xDocSh.Is());
+pDoc = xDocSh-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+pNames = pDoc-GetRangeName();
+//after reload should still have a named range
+CPPUNIT_ASSERT(pNames-size() == 1 );
+
+xDocSh-DoClose();
+}
+
 ScExportTest::ScExportTest()
   : ScBootstrapFixture(/sc/qa/unit/data)
 {
commit b5fffdb8d0438a2fe933a5742d41fe50a14b71f3
Author: Noel Power noel.po...@suse.com
Date:   Fri Jul 26 11:25:51 2013 +0100

fix for fdo#62729 reference pos can point to non existing table

there is an existing function ( called at least from uno names api also )
that updates the tab pos, calling that seems to fix this problem

Change-Id: I6f6f31895eda9c338eeabd3f3285bf2c9eb23b7e

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 1943238..23fd580 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3727,6 +3727,7 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
 AddAttribute(sAttrName, it-second-GetName());
 
 OUString sBaseCellAddress;
+it-second-ValidateTabRefs();
 ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, 
it-second-GetPos(), pDoc,
 FormulaGrammar::CONV_OOO, ' ', false, SCA_ABS_3D);
 AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, 
sBaseCellAddress);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


<    1   2