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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Jun 24 15:30:05 PDT 2015


 sw/qa/python/check_table.py         |   48 ++++++++++++++++++++++++++++-
 sw/source/core/unocore/unochart.cxx |   59 +++++++++++++++++-------------------
 2 files changed, 75 insertions(+), 32 deletions(-)

New commits:
commit 246d4d2cd898d046be90da24e449eec21d7ddfa6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Jun 25 00:15:26 2015 +0200

    add tests for SwChartDataSequence and SwChartDataProvider
    
    Change-Id: I468bb651b5febd090fb3cc15795589124c1e8375

diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index f026e62..2996614 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -1,6 +1,7 @@
 import math
 import unittest
 from org.libreoffice.unotest import UnoInProcess
+from com.sun.star.beans import PropertyValue
 from com.sun.star.uno import RuntimeException
 from com.sun.star.table import BorderLine
 from com.sun.star.table import BorderLine2
@@ -414,6 +415,42 @@ class CheckTable(unittest.TestCase):
             self.assertTrue(math.isnan(xTable.Data[2][x]))
         xDoc.dispose()
 
+    def test_chartdataprovider(self):
+        xDoc = CheckTable._uno.openEmptyWriterDoc()
+        xTable = xDoc.createInstance("com.sun.star.text.TextTable")
+        xTable.initialize(4, 3)
+        xCursor = xDoc.Text.createTextCursor()
+        xDoc.Text.insertTextContent(xCursor, xTable, False)
+        xTable.ChartColumnAsLabel = False
+        xTable.ChartRowAsLabel = False
+        xTable.Data = ((1,2,3), (4,5,6), (7,8,9), (10,11,12))
+        self.assertTrue(xTable.Name == 'Table1')
+        self.assertIn('com.sun.star.text.GenericTextDocument', xDoc.SupportedServiceNames)
+        xChartdataprovider = xDoc.createInstance('com.sun.star.chart2.data.DataProvider')
+        self.assertIs(type(xChartdataprovider.ImplementationName), type('SwChartDataProvider')) # not testing value, just type and coverage
+        self.assertTrue(xChartdataprovider.supportsService('com.sun.star.chart2.data.DataProvider'))
+        self.assertFalse(xChartdataprovider.supportsService('foo'))
+        self.assertIn('com.sun.star.chart2.data.DataProvider', xChartdataprovider.SupportedServiceNames)
+        pv = PropertyValue()
+        pv.Name = 'CellRangeRepresentation'
+        pv.Value = 'Table1.A1:C2'
+        xDataSource = xChartdataprovider.createDataSource((pv,))
+        self.assertEqual(len(xDataSource.DataSequences), 3)
+        expectedValues = ((1,4), (2,5), (3,6))
+        expectedCellrange = ('A1:A2', 'B1:B2', 'C1:C2')
+        for col in range(3):
+            xSeq = xDataSource.DataSequences[col].Values
+            self.assertIs(type(xSeq.ImplementationName), type('SwChartDataSequence')) # not testing value, just type and coverage
+            self.assertTrue(xSeq.supportsService('com.sun.star.chart2.data.DataSequence'))
+            self.assertFalse(xSeq.supportsService('foo'))
+            self.assertIn('com.sun.star.chart2.data.DataSequence', xSeq.SupportedServiceNames)
+            self.assertEqual(xSeq.SourceRangeRepresentation, 'Table1.%s' % expectedCellrange[col])
+            self.assertEqual(xSeq.Data, expectedValues[col])
+            self.assertEqual(xSeq.NumericalData, expectedValues[col])
+            self.assertEqual(
+                    [int(txtval) for txtval in xSeq.TextualData],
+                    [val         for    val in expectedValues[col]])
+
 if __name__ == '__main__':
     unittest.main()
 
commit d43bb0e02df3b24d6dedde6fd6351923cb25bce6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Jun 25 00:14:24 2015 +0200

    remove left-over debug line
    
    Change-Id: I8dc0ad1907c1523be9654f808c401be075a97db1

diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index ba1010d..f026e62 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -384,7 +384,6 @@ class CheckTable(unittest.TestCase):
         xRows = xTable.Rows
         xRows.insertByIndex(1, 2)
         nan = float('nan')
-        print(xTable.Data)
         self.assertEqual(xTable.Data[0], (1,2,3))
         self.assertEqual(xTable.Data[3], (4,5,6))
         self.assertEqual(xTable.Data[4], (7,8,9))
commit 8a57c4309866ea0eaac7ccf9cc39aed35218fe0d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Jun 25 00:12:19 2015 +0200

    fix misleading comment
    
    Change-Id: I5dd3be60ef37cc9be39cd0640b60b44c638d8869

diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 2a20228..afa0dda6 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -985,7 +985,7 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL SwChartDataProvider::create
  * Fix for #i79009
  * we need to return a property that has the same value as the property
  * 'CellRangeRepresentation' but for all rows which are increased by one.
- * E.g. Table1:A1:D5 -> Table1:A2:D6
+ * E.g. Table1.A1:D5 -> Table1,A2:D6
  * Since the problem is only for old charts which did not support multiple
  * we do not need to provide that property/string if the 'CellRangeRepresentation'
  * contains multiple ranges.
commit 684d2ad37aed1240eea03dac381acd1c73383b20
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Jun 25 00:11:14 2015 +0200

    remove nullptr check obsoleted by shared_ptr
    
    regression from 5b6e338f5c9383aad6efae9b4d1420e12b2397ca
    
    Change-Id: I3101327a643e3a2ebe2aebfdc511492393fc8bbb

diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index e8d4298..2a20228 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -393,42 +393,39 @@ static void GetFormatAndCreateCursorFromRangeRep(
 
         *ppTblFmt = pTableFormat;
 
-        if (rpUnoCrsr)
+        rpUnoCrsr.reset();  // default result in case of failure
+
+        SwTable *pTable = pTableFormat ? SwTable::FindTable( pTableFormat ) : 0;
+        // create new SwUnoCrsr spanning the specified range
+        //! see also SwXTextTable::GetRangeByName
+        // #i80314#
+        // perform validation check. Thus, pass <true> as 2nd parameter to <SwTable::GetTableBox(..)>
+        const SwTableBox* pTLBox =
+                        pTable ? pTable->GetTableBox( aStartCell, true ) : 0;
+        if(pTLBox)
         {
-            rpUnoCrsr.reset();  // default result in case of failure
+            // The Actions need to be removed here
+            UnoActionRemoveContext aRemoveContext(pTableFormat->GetDoc());
+            const SwStartNode* pSttNd = pTLBox->GetSttNd();
+            SwPosition aPos(*pSttNd);
+
+            // set cursor to top left box of range
+            auto pUnoCrsr = pTableFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+            pUnoCrsr->Move( fnMoveForward, fnGoNode );
+            pUnoCrsr->SetRemainInSection( false );
 
-            SwTable *pTable = pTableFormat ? SwTable::FindTable( pTableFormat ) : 0;
-            // create new SwUnoCrsr spanning the specified range
-            //! see also SwXTextTable::GetRangeByName
             // #i80314#
             // perform validation check. Thus, pass <true> as 2nd parameter to <SwTable::GetTableBox(..)>
-            const SwTableBox* pTLBox =
-                            pTable ? pTable->GetTableBox( aStartCell, true ) : 0;
-            if(pTLBox)
+            const SwTableBox* pBRBox = pTable->GetTableBox( aEndCell, true );
+            if(pBRBox)
             {
-                // The Actions need to be removed here
-                UnoActionRemoveContext aRemoveContext(pTableFormat->GetDoc());
-                const SwStartNode* pSttNd = pTLBox->GetSttNd();
-                SwPosition aPos(*pSttNd);
-
-                // set cursor to top left box of range
-                auto pUnoCrsr = pTableFormat->GetDoc()->CreateUnoCrsr(aPos, true);
+                pUnoCrsr->SetMark();
+                pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
                 pUnoCrsr->Move( fnMoveForward, fnGoNode );
-                pUnoCrsr->SetRemainInSection( false );
-
-                // #i80314#
-                // perform validation check. Thus, pass <true> as 2nd parameter to <SwTable::GetTableBox(..)>
-                const SwTableBox* pBRBox = pTable->GetTableBox( aEndCell, true );
-                if(pBRBox)
-                {
-                    pUnoCrsr->SetMark();
-                    pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd();
-                    pUnoCrsr->Move( fnMoveForward, fnGoNode );
-                    SwUnoTableCrsr* pCrsr =
-                        dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
-                    pCrsr->MakeBoxSels();
-                    rpUnoCrsr = pUnoCrsr;
-                }
+                SwUnoTableCrsr* pCrsr =
+                    dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr.get());
+                pCrsr->MakeBoxSels();
+                rpUnoCrsr = pUnoCrsr;
             }
         }
     }
commit c574038c2332574651e243dfbd55d69bf475dc9b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jun 24 15:07:29 2015 +0200

    test XServiceInfo stuff, while at it
    
    Change-Id: Ib39411bd71f366f4dc1ea9dca2a45f31777feb7a

diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index b61bedb..ba1010d 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -355,9 +355,19 @@ class CheckTable(unittest.TestCase):
         xTable.ChartRowAsLabel = False
         xTable.Data = ((1,2,3), (4,5,6), (7,8,9), (10,11,12))
         xRows = xTable.Rows
+        self.assertIs(type(xRows.ImplementationName), type('SwXTableRows')) # not testing value, just type and coverage
+        self.assertTrue(xRows.supportsService('com.sun.star.text.TableRows'))
+        self.assertFalse(xRows.supportsService('foo'))
+        self.assertIn('com.sun.star.text.TableRows', xRows.SupportedServiceNames)
+        self.assertNotIn('foo', xRows.SupportedServiceNames)
         xRows.removeByIndex(1, 2)
         self.assertEqual( xTable.Data, ((1,2,3), (10,11,12)))
         xCols = xTable.Columns
+        self.assertIs(type(xCols.ImplementationName), type('SwXTableColumns')) # not testing value, just type and coverage
+        self.assertTrue(xCols.supportsService('com.sun.star.text.TableColumns'))
+        self.assertFalse(xCols.supportsService('foo'))
+        self.assertIn('com.sun.star.text.TableColumns', xCols.SupportedServiceNames)
+        self.assertNotIn('foo', xCols.SupportedServiceNames)
         xCols.removeByIndex(1, 1)
         self.assertEqual( xTable.Data, ((1,3), (10,12)))
         xDoc.dispose()


More information about the Libreoffice-commits mailing list