[Libreoffice-commits] core.git: 2 commits - solenv/gbuild sw/inc sw/qa sw/source

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Tue Jun 30 09:18:04 PDT 2015


 solenv/gbuild/Output.mk             |    7 +++++
 sw/inc/unotbl.hxx                   |    4 +--
 sw/qa/extras/uiwriter/uiwriter.cxx  |   16 ++++++++++++
 sw/source/core/unocore/unochart.cxx |   44 ++++++++++++++++-----------------
 sw/source/core/unocore/unotbl.cxx   |   47 ++++++++++++------------------------
 5 files changed, 63 insertions(+), 55 deletions(-)

New commits:
commit 98c6cf40a60c272277ca9a7baa2723a97e38b3ff
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Tue Jun 30 17:20:04 2015 +0200

    colorful interactive gbuild output
    
    Change-Id: I22e9eacfddff611d368963162024437f4a7b7fdf

diff --git a/solenv/gbuild/Output.mk b/solenv/gbuild/Output.mk
index ca3da3b..b9f8515 100644
--- a/solenv/gbuild/Output.mk
+++ b/solenv/gbuild/Output.mk
@@ -48,6 +48,13 @@ endef
 gb_Output_ESCAPE := $(shell echo|awk 'BEGIN { printf "%c", 27 }' -)
 gb_Output_BELL := $(shell echo|awk 'BEGIN { printf "%c", 7 }' -)
 
+# default to color output, if interactive
+ifeq ($(origin gb_COLOR),undefined)
+ifneq ($(MAKE_TERMOUT),)
+gb_COLOR=$(true)
+endif
+endif
+
 # only enable colorized output if
 # - gb_COLOR is set
 # - we have a known term
commit 69ef1a0b445341cfa53b201c73eab93d7745b431
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Tue Jun 30 01:07:15 2015 +0200

    make GetCellPosition a member and visible
    
    ... to move test code out of production code
    
    Change-Id: I8bd38f57faba41a0af3740eda098144d9e49fe15

diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index e8009a8..810be4d 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -438,6 +438,8 @@ public:
    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
 
     SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
+    SW_DLLPUBLIC static void GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow);
+
 };
 
 class SwXCellRange : public cppu::WeakImplHelper
@@ -636,8 +638,6 @@ int sw_CompareCellRanges(
 
 void sw_NormalizeRange( OUString &rCell1, OUString &rCell2 );
 
-void sw_GetCellPosition( const OUString &rCellName, sal_Int32 &rColumn, sal_Int32 &rRow);
-
 OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow );
 
 int sw_CompareCellsByColFirst( const OUString &rCellName1, const OUString &rCellName2 );
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 668aa43..9f5a8fc 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -34,6 +34,7 @@
 #include <test/mtfxmldump.hxx>
 #include <unocrsr.hxx>
 #include <unocrsrhelper.hxx>
+#include <unotbl.hxx>
 
 #include <svx/svdpage.hxx>
 #include <svx/svdview.hxx>
@@ -106,6 +107,7 @@ public:
     void testTdf90883TableBoxGetCoordinates();
     void testEmbeddedDataSource();
     void testUnoCursorPointer();
+    void testTextTableCellNames();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -152,6 +154,7 @@ public:
     CPPUNIT_TEST(testTdf90883TableBoxGetCoordinates);
     CPPUNIT_TEST(testEmbeddedDataSource);
     CPPUNIT_TEST(testUnoCursorPointer);
+    CPPUNIT_TEST(testTextTableCellNames);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1285,6 +1288,19 @@ void SwUiWriterTest::testUnoCursorPointer()
     CPPUNIT_ASSERT(!static_cast<bool>(pCursor));
 }
 
+void SwUiWriterTest::testTextTableCellNames()
+{
+    sal_Int32 nCol, nRow2;
+    SwXTextTable::GetCellPosition( OUString("z1"), nCol, nRow2);
+    CPPUNIT_ASSERT(nCol == 51);
+    SwXTextTable::GetCellPosition( OUString("AA1"), nCol, nRow2);
+    CPPUNIT_ASSERT(nCol == 52);
+    SwXTextTable::GetCellPosition( OUString("AB1"), nCol, nRow2);
+    CPPUNIT_ASSERT(nCol == 53);
+    SwXTextTable::GetCellPosition( OUString("BB1"), nCol, nRow2);
+    CPPUNIT_ASSERT(nCol == 105);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index d6f4353..e1fe9c1 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -203,8 +203,8 @@ bool FillRangeDescriptor(
         return false;
 
     rDesc.nTop = rDesc.nLeft = rDesc.nBottom = rDesc.nRight = -1;
-    sw_GetCellPosition( aTLName, rDesc.nLeft,  rDesc.nTop );
-    sw_GetCellPosition( aBRName, rDesc.nRight, rDesc.nBottom );
+    SwXTextTable::GetCellPosition( aTLName, rDesc.nLeft,  rDesc.nTop );
+    SwXTextTable::GetCellPosition( aBRName, rDesc.nRight, rDesc.nBottom );
     rDesc.Normalize();
     OSL_ENSURE( rDesc.nTop    != -1 &&
                 rDesc.nLeft   != -1 &&
@@ -708,8 +708,8 @@ uno::Reference< chart2::data::XDataSource > SwChartDataProvider::Impl_createData
                 OSL_ENSURE( bOk2, "failed to get table and start/end cells" );
 
                 sal_Int32 nStartRow, nStartCol, nEndRow, nEndCol;
-                sw_GetCellPosition( aStartCell, nStartCol, nStartRow );
-                sw_GetCellPosition( aEndCell,   nEndCol,   nEndRow );
+                SwXTextTable::GetCellPosition( aStartCell, nStartCol, nStartRow );
+                SwXTextTable::GetCellPosition( aEndCell,   nEndCol,   nEndRow );
                 OSL_ENSURE( nStartRow <= nEndRow && nStartCol <= nEndCol,
                         "cell range not normalized");
 
@@ -1002,8 +1002,8 @@ OUString SwChartDataProvider::GetBrokenCellRangeForExport(
         GetTableAndCellsFromRangeRep( rCellRangeRepresentation,
             aTableName, aStartCell, aEndCell, false );
         sal_Int32 nStartCol = -1, nStartRow = -1, nEndCol = -1, nEndRow = -1;
-        sw_GetCellPosition( aStartCell, nStartCol, nStartRow );
-        sw_GetCellPosition( aEndCell, nEndCol, nEndRow );
+        SwXTextTable::GetCellPosition( aStartCell, nStartCol, nStartRow );
+        SwXTextTable::GetCellPosition( aEndCell, nEndCol, nEndRow );
 
         // get new cell names
         ++nStartRow;
@@ -1118,8 +1118,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArgume
         sal_Int32 nFirstCol = -1, nFirstRow = -1, nLastCol = -1, nLastRow = -1;
         const OUString aCell( !aLabelStartCell.isEmpty() ? aLabelStartCell : aValuesStartCell );
         OSL_ENSURE( !aCell.isEmpty() , "start cell missing?" );
-        sw_GetCellPosition( aCell, nFirstCol, nFirstRow);
-        sw_GetCellPosition( aValuesEndCell, nLastCol, nLastRow);
+        SwXTextTable::GetCellPosition( aCell, nFirstCol, nFirstRow);
+        SwXTextTable::GetCellPosition( aValuesEndCell, nLastCol, nLastRow);
 
         sal_Int16 nDirection = -1;  // -1: not yet set,  0: columns,  1: rows, -2: failed
         if (nFirstCol == nLastCol && nFirstRow == nLastRow) // a single cell...
@@ -1172,8 +1172,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArgume
             if (!aLabelStartCell.isEmpty() && !aLabelEndCell.isEmpty())
             {
                 sal_Int32 nStartCol = -1, nStartRow = -1, nEndCol = -1, nEndRow = -1;
-                sw_GetCellPosition( aLabelStartCell, nStartCol, nStartRow );
-                sw_GetCellPosition( aLabelEndCell,   nEndCol,   nEndRow );
+                SwXTextTable::GetCellPosition( aLabelStartCell, nStartCol, nStartRow );
+                SwXTextTable::GetCellPosition( aLabelEndCell,   nEndCol,   nEndRow );
                 if (nStartRow < 0 || nEndRow >= nTableRows ||
                     nStartCol < 0 || nEndCol >= nTableCols)
                 {
@@ -1194,8 +1194,8 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArgume
             if (!aValuesStartCell.isEmpty() && !aValuesEndCell.isEmpty())
             {
                 sal_Int32 nStartCol = -1, nStartRow = -1, nEndCol = -1, nEndRow = -1;
-                sw_GetCellPosition( aValuesStartCell, nStartCol, nStartRow );
-                sw_GetCellPosition( aValuesEndCell,   nEndCol,   nEndRow );
+                SwXTextTable::GetCellPosition( aValuesStartCell, nStartCol, nStartRow );
+                SwXTextTable::GetCellPosition( aValuesEndCell,   nEndCol,   nEndRow );
                 if (nStartRow < 0 || nEndRow >= nTableRows ||
                     nStartCol < 0 || nEndCol >= nTableCols)
                 {
@@ -1222,16 +1222,16 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArgume
             sal_Int32 nStartRow = -1, nStartCol = -1, nEndRow = -1, nEndCol = -1;
             if (xCurLabel.is())
             {
-                sw_GetCellPosition( aLabelStartCell, nStartCol, nStartRow);
-                sw_GetCellPosition( aLabelEndCell,   nEndCol,   nEndRow);
+                SwXTextTable::GetCellPosition( aLabelStartCell, nStartCol, nStartRow);
+                SwXTextTable::GetCellPosition( aLabelEndCell,   nEndCol,   nEndRow);
                 OSL_ENSURE( (nStartCol == nEndCol && (nEndRow - nStartRow + 1) == xCurLabel->getData().getLength()) ||
                             (nStartRow == nEndRow && (nEndCol - nStartCol + 1) == xCurLabel->getData().getLength()),
                         "label sequence length does not match range representation!" );
             }
             if (xCurValues.is())
             {
-                sw_GetCellPosition( aValuesStartCell, nStartCol, nStartRow);
-                sw_GetCellPosition( aValuesEndCell,   nEndCol,   nEndRow);
+                SwXTextTable::GetCellPosition( aValuesStartCell, nStartCol, nStartRow);
+                SwXTextTable::GetCellPosition( aValuesEndCell,   nEndCol,   nEndRow);
                 OSL_ENSURE( (nStartCol == nEndCol && (nEndRow - nStartRow + 1) == xCurValues->getData().getLength()) ||
                             (nStartRow == nEndRow && (nEndCol - nStartCol + 1) == xCurValues->getData().getLength()),
                         "value sequence length does not match range representation!" );
@@ -1660,8 +1660,8 @@ void SwChartDataProvider::AddRowCols(
     if (pFirstBox && pLastBox)
     {
         sal_Int32 nFirstCol = -1, nFirstRow = -1, nLastCol = -1, nLastRow = -1;
-        sw_GetCellPosition( pFirstBox->GetName(), nFirstCol, nFirstRow  );
-        sw_GetCellPosition( pLastBox->GetName(),  nLastCol,  nLastRow );
+        SwXTextTable::GetCellPosition( pFirstBox->GetName(), nFirstCol, nFirstRow  );
+        SwXTextTable::GetCellPosition( pLastBox->GetName(),  nLastCol,  nLastRow );
 
         bool bAddCols = false;  // default; also to be used if nBoxes == 1 :-/
         if (nFirstCol == nLastCol && nFirstRow != nLastRow)
@@ -1767,7 +1767,7 @@ OUString SAL_CALL SwChartDataProvider::convertRangeToXML( const OUString& rRange
             throw lang::IllegalArgumentException();
 
         sal_Int32 nCol, nRow;
-        sw_GetCellPosition( aStartCell, nCol, nRow );
+        SwXTextTable::GetCellPosition( aStartCell, nCol, nRow );
         if (nCol < 0 || nRow < 0)
             throw uno::RuntimeException();
 
@@ -1780,7 +1780,7 @@ OUString SAL_CALL SwChartDataProvider::convertRangeToXML( const OUString& rRange
         aCellRange.aUpperLeft.bIsEmpty  = false;
         if (aStartCell != aEndCell && !aEndCell.isEmpty())
         {
-            sw_GetCellPosition( aEndCell, nCol, nRow );
+            SwXTextTable::GetCellPosition( aEndCell, nCol, nRow );
             if (nCol < 0 || nRow < 0)
                 throw uno::RuntimeException();
 
@@ -2466,8 +2466,8 @@ bool SwChartDataSequence::DeleteBox( const SwTableBox &rBox )
         OUString aPointCellName( pTable->GetTableBox( pPointStartNode->GetIndex() )->GetName() );
         OUString aMarkCellName( pTable->GetTableBox( pMarkStartNode->GetIndex() )->GetName() );
 
-        sw_GetCellPosition( aPointCellName, nPointCol, nPointRow );
-        sw_GetCellPosition( aMarkCellName,  nMarkCol,  nMarkRow );
+        SwXTextTable::GetCellPosition( aPointCellName, nPointCol, nPointRow );
+        SwXTextTable::GetCellPosition( aMarkCellName,  nMarkCol,  nMarkRow );
         OSL_ENSURE( nPointRow >= 0 && nPointCol >= 0, "invalid row and col" );
         OSL_ENSURE( nMarkRow >= 0 && nMarkCol >= 0, "invalid row and col" );
 
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 49d43ca..3b6c184 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -349,14 +349,13 @@ static uno::Any lcl_GetSpecialProperty(SwFrameFormat* pFormat, const SfxItemProp
  * where IsTableComplex() returns false).
  *
  * @param rCellName e.g. A1..Z1, a1..z1, AA1..AZ1, Aa1..Az1, BA1..BZ1, Ba1..Bz1, ...
- * @param [IN,OUT] rColumn (0-based)
- * @param [IN,OUT] rRow (0-based)
+ * @param [IN,OUT] o_rColumn (0-based)
+ * @param [IN,OUT] o_rRow (0-based)
  */
 //TODO: potential for throwing proper exceptions instead of having every caller to check for errors
-void sw_GetCellPosition(const OUString &rCellName,
-                        sal_Int32 &rColumn, sal_Int32 &rRow)
+void SwXTextTable::GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow)
 {
-    rColumn = rRow = -1;    // default return values indicating failure
+    o_rColumn = o_rRow = -1;    // default return values indicating failure
     const sal_Int32 nLen = rCellName.getLength();
     if(!nLen)
     {
@@ -392,8 +391,8 @@ void sw_GetCellPosition(const OUString &rCellName,
             }
         }
 
-        rColumn = nColIdx;
-        rRow    = rCellName.copy(nRowPos).toInt32() - 1; // - 1 because indices ought to be 0 based
+        o_rColumn = nColIdx;
+        o_rRow    = rCellName.copy(nRowPos).toInt32() - 1; // - 1 because indices ought to be 0 based
     }
 }
 
@@ -409,8 +408,8 @@ void sw_GetCellPosition(const OUString &rCellName,
 int sw_CompareCellsByRowFirst( const OUString &rCellName1, const OUString &rCellName2 )
 {
     sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
-    sw_GetCellPosition( rCellName1, nCol1, nRow1 );
-    sw_GetCellPosition( rCellName2, nCol2, nRow2 );
+    SwXTextTable::GetCellPosition( rCellName1, nCol1, nRow1 );
+    SwXTextTable::GetCellPosition( rCellName2, nCol2, nRow2 );
 
     if (nRow1 < nRow2 || (nRow1 == nRow2 && nCol1 < nCol2))
         return -1;
@@ -432,8 +431,8 @@ int sw_CompareCellsByRowFirst( const OUString &rCellName1, const OUString &rCell
 int sw_CompareCellsByColFirst( const OUString &rCellName1, const OUString &rCellName2 )
 {
     sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
-    sw_GetCellPosition( rCellName1, nCol1, nRow1 );
-    sw_GetCellPosition( rCellName2, nCol2, nRow2 );
+    SwXTextTable::GetCellPosition( rCellName1, nCol1, nRow1 );
+    SwXTextTable::GetCellPosition( rCellName2, nCol2, nRow2 );
 
     if (nCol1 < nCol2 || (nCol1 == nCol2 && nRow1 < nRow2))
         return -1;
@@ -484,20 +483,6 @@ int sw_CompareCellRanges(
  */
 OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow )
 {
-#if OSL_DEBUG_LEVEL > 0
-    {
-        sal_Int32 nCol, nRow2;
-        sw_GetCellPosition( OUString("z1"), nCol, nRow2);
-        OSL_ENSURE( nCol == 51, "sw_GetCellPosition failed" );
-        sw_GetCellPosition( OUString("AA1"), nCol, nRow2);
-        OSL_ENSURE( nCol == 52, "sw_GetCellPosition failed" );
-        sw_GetCellPosition( OUString("AB1"), nCol, nRow2);
-        OSL_ENSURE( nCol == 53, "sw_GetCellPosition failed" );
-        sw_GetCellPosition( OUString("BB1"), nCol, nRow2);
-        OSL_ENSURE( nCol == 105, "sw_GetCellPosition failed" );
-    }
-#endif
-
     if (nColumn < 0 || nRow < 0)
         return OUString();
     OUString sCellName;
@@ -544,8 +529,8 @@ const SwTableBox* lcl_FindCornerTableBox(const SwTableLines& rTableLines, const
 void sw_NormalizeRange(OUString &rCell1, OUString &rCell2)
 {
     sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
-    sw_GetCellPosition( rCell1, nCol1, nRow1 );
-    sw_GetCellPosition( rCell2, nCol2, nRow2 );
+    SwXTextTable::GetCellPosition( rCell1, nCol1, nRow1 );
+    SwXTextTable::GetCellPosition( rCell2, nCol2, nRow2 );
     if (nCol2 < nCol1 || nRow2 < nRow1)
     {
         rCell1  = sw_GetCellName( std::min(nCol1, nCol2), std::min(nRow1, nRow2) );
@@ -2287,8 +2272,8 @@ uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUStrin
         throw uno::RuntimeException();
     SwRangeDescriptor aDesc;
     aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
-    sw_GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop );
-    sw_GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom );
+    SwXTextTable::GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop );
+    SwXTextTable::GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom );
 
     // we should normalize the range now (e.g. A5:C1 will become A1:C5)
     // since (depending on what is done later) it will be troublesome
@@ -3280,8 +3265,8 @@ uno::Reference< table::XCellRange >  SwXCellRange::getCellRangeByName(const OUSt
         throw uno::RuntimeException();
     SwRangeDescriptor aDesc;
     aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
-    sw_GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
-    sw_GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
+    SwXTextTable::GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
+    SwXTextTable::GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
     aDesc.Normalize();
     return getCellRangeByPosition(aDesc.nLeft - aRgDesc.nLeft, aDesc.nTop - aRgDesc.nTop,
                 aDesc.nRight - aRgDesc.nLeft, aDesc.nBottom - aRgDesc.nTop);


More information about the Libreoffice-commits mailing list