[Libreoffice-commits] core.git: 34 commits - qadevOOo/tests sw/inc sw/qa sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Mon Mar 30 14:25:33 PDT 2015
qadevOOo/tests/java/ifc/chart/_XChartDataArray.java | 2
sw/inc/unotbl.hxx | 10
sw/qa/python/check_table.py | 26
sw/source/core/unocore/unotbl.cxx | 1163 +++++---------------
4 files changed, 379 insertions(+), 822 deletions(-)
New commits:
commit 77315c187af612e3534ad0926f205f0e83fb42fb
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 18:17:40 2015 +0200
SwXTextTable::setDataArray can reuse SwXCellRange too
Change-Id: Ia4aa4abcc6daa433004ab7f624f6b79c618a354d
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 6a04379..a1ef18e 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2401,72 +2401,12 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
return xAllRange->getDataArray();
}
-void SAL_CALL SwXTextTable::setDataArray(
- const uno::Sequence< uno::Sequence< uno::Any > >& rArray )
+void SAL_CALL SwXTextTable::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
throw (uno::RuntimeException, std::exception)
{
- // see SwXTextTable::setData(...) also
-
SolarMutexGuard aGuard;
- const sal_uInt16 nRowCount = getRowCount();
- const sal_uInt16 nColCount = getColumnCount();
-
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- {
- SwTable* pTable = SwTable::FindTable( pFmt );
- if(pTable->IsTblComplex())
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
-
- if(rArray.getLength() != nRowCount)
- {
- throw uno::RuntimeException();
- }
- const uno::Sequence< uno::Any >* pRowArray = rArray.getConstArray();
- for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
- {
- const uno::Sequence< uno::Any >& rColSeq = pRowArray[nRow];
- if(rColSeq.getLength() != nColCount)
- {
- throw uno::RuntimeException();
- }
- const uno::Any * pColArray = rColSeq.getConstArray();
- uno::Reference< table::XCell > xCellRef;
- for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
- {
- SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow);
- //! keep (additional) reference to object to prevent implicit destruction
- //! in following UNO calls (when object will get referenced)
- xCellRef = pXCell;
- SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
- if(!pBox)
- {
- throw uno::RuntimeException();
- }
- else
- {
- const uno::Any &rAny = pColArray[nCol];
- if (uno::TypeClass_STRING == rAny.getValueTypeClass())
- sw_setString( *pXCell, *static_cast<OUString const *>(rAny.getValue()) );
- else
- {
- double d = 0;
- // #i20067# don't throw exception just do nothing if
- // there is no value set
- if( (rAny >>= d) )
- sw_setValue( *pXCell, d );
- else
- sw_setString( *pXCell, OUString(), true );
-
- }
- }
- }
- }
- }
+ uno::Reference<sheet::XCellRangeData> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
+ return xAllRange->setDataArray(rArray);
}
uno::Sequence< uno::Sequence< double > > SwXTextTable::getData(void)
commit db123d181a48918dd85a90415d3557a78951c8bd
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 18:07:01 2015 +0200
lets get a XTest reference right away
Change-Id: Ib805a20cd3f121ae1d021a28e3b9908afdad4ab4
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index d98d86b..6a04379 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4025,11 +4025,8 @@ uno::Sequence<OUString> SwXCellRange::getRowDescriptions(void)
const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
- auto xCell = getCellByPosition(0, i);
- if(!xCell.is())
- throw uno::RuntimeException();
- uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
- pArray[i - nStart] = xText->getString();
+ const uno::Reference<text::XText> xCell(getCellByPosition(0, i), uno::UNO_QUERY_THROW);
+ pArray[i - nStart] = xCell->getString();
}
return aRet;
}
@@ -4048,16 +4045,12 @@ uno::Sequence<OUString> SwXCellRange::getColumnDescriptions(void)
const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nColumnCount; i++)
{
- auto xCell = getCellByPosition(i, 0);
- if(!xCell.is())
- throw uno::RuntimeException();
- uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
- pArray[i - nStart] = xText->getString();
+ const uno::Reference<text::XText> xCell(getCellByPosition(i, 0), uno::UNO_QUERY_THROW);
+ pArray[i - nStart] = xCell->getString();
}
return aRet;
}
-///@see SwXTextTable::setRowDescriptions (TODO: seems to be copy and paste programming here)
void SwXCellRange::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
throw(uno::RuntimeException, std::exception)
{
@@ -4072,11 +4065,8 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
- uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
- if(!xCell.is())
- throw uno::RuntimeException();
- uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
- xText->setString(pArray[i-nStart]);
+ uno::Reference<text::XText> xCell(getCellByPosition(0, i), uno::UNO_QUERY_THROW);
+ xCell->setString(pArray[i-nStart]);
}
}
void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
@@ -4093,11 +4083,8 @@ void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnD
const OUString* pArray = rColumnDesc.getConstArray();
for(sal_uInt16 i = nStart; i < nColumnCount; i++)
{
- uno::Reference<table::XCell> xCell = getCellByPosition(i, 0);
- if(!xCell.is())
- throw uno::RuntimeException();
- uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
- xText->setString(pArray[i-nStart]);
+ uno::Reference<text::XText> xCell(getCellByPosition(i, 0), uno::UNO_QUERY_THROW);
+ xCell->setString(pArray[i-nStart]);
}
}
commit 84e71f3bad28f2003a0f654f0938d5bc7e309666
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 17:52:39 2015 +0200
use even more SwXCellRange impls from SwXTextTable
Change-Id: If1eede3bc1dc4effdb6a46ad2c0aeed2d6cd57a2
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index e98982e..d98d86b 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2539,39 +2539,13 @@ uno::Sequence<OUString> SwXTextTable::getRowDescriptions(void)
return xAllRange->getRowDescriptions();
}
-void SwXTextTable::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc) throw( uno::RuntimeException, std::exception )
+void SwXTextTable::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
+ throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- {
- const sal_uInt16 nRowCount = getRowCount();
- if(!nRowCount || rRowDesc.getLength() < (m_bFirstRowAsLabel ? nRowCount - 1 : nRowCount))
- {
- throw uno::RuntimeException();
- }
- const OUString* pArray = rRowDesc.getConstArray();
- if(m_bFirstColumnAsLabel)
- {
- const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nRowCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
- xText->setString(pArray[i - nStart]);
- }
- }
- else
- {
- OSL_FAIL("Where to put theses labels?");
- }
- }
- else
- throw uno::RuntimeException();
+ uno::Reference<chart::XChartDataArray> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(m_bFirstRowAsLabel, m_bFirstColumnAsLabel);
+ xAllRange->setRowDescriptions(rRowDesc);
}
uno::Sequence<OUString> SwXTextTable::getColumnDescriptions(void)
@@ -2583,41 +2557,13 @@ uno::Sequence<OUString> SwXTextTable::getColumnDescriptions(void)
return xAllRange->getColumnDescriptions();
}
-void SwXTextTable::setColumnDescriptions(const uno::Sequence< OUString >& rColumnDesc) throw( uno::RuntimeException, std::exception )
+void SwXTextTable::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
+ throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- const sal_uInt16 nColCount = getColumnCount();
- if(!nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- {
- const OUString* pArray = rColumnDesc.getConstArray();
- if(m_bFirstRowAsLabel && rColumnDesc.getLength() >= nColCount - (m_bFirstColumnAsLabel ? 1 : 0))
- {
- const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nColCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
- xText->setString(pArray[i - nStart]);
- }
- }
- else
- {
- OSL_FAIL("Where do these labels come from?");
- }
- }
- else
- throw uno::RuntimeException();
+ uno::Reference<chart::XChartDataArray> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(m_bFirstRowAsLabel, m_bFirstColumnAsLabel);
+ return xAllRange->setColumnDescriptions(rColumnDesc);
}
void SAL_CALL SwXTextTable::addChartDataChangeEventListener(
commit 7cb7ced25e656b1edcc4f8be5ee80bf45a2b3264
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 17:51:59 2015 +0200
whops, index swap
Change-Id: I2c25952f6f4ac4b67cb02557f3497f203bb503d2
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 38b2d05..e98982e 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4147,7 +4147,7 @@ void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnD
const OUString* pArray = rColumnDesc.getConstArray();
for(sal_uInt16 i = nStart; i < nColumnCount; i++)
{
- uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
+ uno::Reference<table::XCell> xCell = getCellByPosition(i, 0);
if(!xCell.is())
throw uno::RuntimeException();
uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
commit 299d90299d70fac0bed00bc63a65b29fc130b44a
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 17:50:38 2015 +0200
fix bounds checking
Change-Id: I837cd043c7e5ee825feb1ede670ebd5ff912c487
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index f1f5cca..38b2d05 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4120,10 +4120,10 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
const sal_uInt16 nRowCount = getRowCount();
if(!m_bFirstColumnAsLabel)
return; // if there are no labels we cannot set descriptions
- if(!nRowCount || rRowDesc.getLength() < nRowCount)
- throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const OUString* pArray = rRowDesc.getConstArray();
const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
+ if(!nRowCount || rRowDesc.getLength() + nStart < nRowCount)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
@@ -4141,10 +4141,10 @@ void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnD
const sal_uInt16 nColumnCount = getColumnCount();
if(!m_bFirstRowAsLabel)
return; // if there are no labels we cannot set descriptions
- if(!nColumnCount || rColumnDesc.getLength() < nColumnCount)
+ const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
+ if(!nColumnCount || rColumnDesc.getLength() + nStart < nColumnCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const OUString* pArray = rColumnDesc.getConstArray();
- const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nColumnCount; i++)
{
uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
commit 2f95d196bf28471810ccce1503fd0ff379cccc4b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 16:58:37 2015 +0200
add Python test for table describtions
Change-Id: Ie7637b8cf26e663bbb47f0df9fdb441a8af754c5
diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index 9ec6187..cd67edf 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -254,6 +254,32 @@ class CheckTable(unittest.TestCase):
# close document
xDoc.dispose()
+ def test_descriptions(self):
+ xDoc = self.__class__._xDoc
+ # insert table
+ xTable = xDoc.createInstance("com.sun.star.text.TextTable")
+ xTable.initialize(3, 3)
+ xCursor = xDoc.Text.createTextCursor()
+ xDoc.Text.insertTextContent(xCursor, xTable, False)
+ self.assertEqual(3, xTable.Rows.Count)
+ self.assertEqual(3, xTable.Columns.Count)
+ for x in range(3):
+ for y in range(3):
+ xCell = xTable.getCellByPosition(x, y)
+ xCell.String = 'Cell %d %d' % (x, y)
+ self.assertEqual('Cell 0 0', xTable.getCellByPosition(0,0).String)
+ self.assertEqual('Cell 1 1', xTable.getCellByPosition(1,1).String)
+ self.assertEqual('Cell 2 2', xTable.getCellByPosition(2,2).String)
+ xTable.ChartColumnAsLabel = True
+ xTable.ChartRowAsLabel = True
+ self.assertEqual(2, len(xTable.RowDescriptions))
+ self.assertEqual('Cell 0 1', xTable.RowDescriptions[0])
+ self.assertEqual('Cell 0 2', xTable.RowDescriptions[1])
+ self.assertEqual(2, len(xTable.ColumnDescriptions))
+ self.assertEqual('Cell 1 0', xTable.ColumnDescriptions[0])
+ self.assertEqual('Cell 2 0', xTable.ColumnDescriptions[1])
+
+
if __name__ == '__main__':
unittest.main()
commit 394c3f32aff2ef4ee06dcb897fbcd1a939d04384
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 16:45:12 2015 +0200
reorder {Row,Column}Description (prepare for unify)
Change-Id: If98689a6cd36d117fc5f88fda41ebac5eae6deed
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index f27e2e2..f1f5cca 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2574,45 +2574,13 @@ void SwXTextTable::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
throw uno::RuntimeException();
}
-uno::Sequence< OUString > SwXTextTable::getColumnDescriptions(void)
- throw( uno::RuntimeException, std::exception )
+uno::Sequence<OUString> SwXTextTable::getColumnDescriptions(void)
+ throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- const sal_uInt16 nColCount = getColumnCount();
- if(!nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
- uno::Sequence< OUString > aRet(m_bFirstRowAsLabel ? nColCount - 1 : nColCount);
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- {
- OUString* pArray = aRet.getArray();
- if(m_bFirstRowAsLabel)
- {
- const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nColCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
-
- pArray[i - nStart] = xText->getString();
- }
- }
- else
- {
- OSL_FAIL("Where do these labels come from?");
- }
- }
- else
- throw uno::RuntimeException();
- return aRet;
+ uno::Reference<chart::XChartDataArray> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(m_bFirstRowAsLabel, m_bFirstColumnAsLabel);
+ return xAllRange->getColumnDescriptions();
}
void SwXTextTable::setColumnDescriptions(const uno::Sequence< OUString >& rColumnDesc) throw( uno::RuntimeException, std::exception )
@@ -4119,10 +4087,33 @@ uno::Sequence<OUString> SwXCellRange::getRowDescriptions(void)
}
return aRet;
}
+uno::Sequence<OUString> SwXCellRange::getColumnDescriptions(void)
+ throw(uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ const sal_uInt16 nColumnCount = getColumnCount();
+ if(!nColumnCount)
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ uno::Sequence<OUString> aRet(m_bFirstRowAsLabel ? nColumnCount - 1 : nColumnCount);
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
+ if(!m_bFirstRowAsLabel)
+ return {}; // without labels we have no descriptions
+ OUString* pArray = aRet.getArray();
+ const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
+ for(sal_uInt16 i = nStart; i < nColumnCount; i++)
+ {
+ auto xCell = getCellByPosition(i, 0);
+ if(!xCell.is())
+ throw uno::RuntimeException();
+ uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
+ pArray[i - nStart] = xText->getString();
+ }
+ return aRet;
+}
///@see SwXTextTable::setRowDescriptions (TODO: seems to be copy and paste programming here)
-void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
- throw(uno::RuntimeException, std::exception )
+void SwXCellRange::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
+ throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
@@ -4142,34 +4133,30 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
xText->setString(pArray[i-nStart]);
}
}
-
-uno::Sequence< OUString > SwXCellRange::getColumnDescriptions(void)
+void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
throw(uno::RuntimeException, std::exception)
{
- uno::Sequence<OUString> vResult(getColumnCount());
- setColumnDescriptions(vResult);
- return vResult;
-}
-
-void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& ColumnDesc)
- throw( uno::RuntimeException, std::exception )
-{
SolarMutexGuard aGuard;
- const sal_uInt16 nColCount = getColumnCount();
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
- const OUString* pArray = ColumnDesc.getConstArray();
- if(m_bFirstColumnAsLabel || ColumnDesc.getLength() < nColCount)
+ const sal_uInt16 nColumnCount = getColumnCount();
+ if(!m_bFirstRowAsLabel)
+ return; // if there are no labels we cannot set descriptions
+ if(!nColumnCount || rColumnDesc.getLength() < nColumnCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
- for(sal_uInt16 i = 0; i < nColCount; i++)
+ const OUString* pArray = rColumnDesc.getConstArray();
+ const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
+ for(sal_uInt16 i = nStart; i < nColumnCount; i++)
{
- uno::Reference<table::XCell> xCell = getCellByPosition(i, 0);
+ uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
if(!xCell.is())
throw uno::RuntimeException();
uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
- xText->setString(pArray[i]);
+ xText->setString(pArray[i-nStart]);
}
}
+
+
void SAL_CALL SwXCellRange::addChartDataChangeEventListener(
const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
throw (uno::RuntimeException, std::exception)
commit d867ab4be9968f7fec28e6af65ee2c23c517008d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 16:42:23 2015 +0200
add some helpful log messages
Change-Id: I58762fdd6efafbd4ec164f190d9aeadb9cb09f76
diff --git a/qadevOOo/tests/java/ifc/chart/_XChartDataArray.java b/qadevOOo/tests/java/ifc/chart/_XChartDataArray.java
index 99a41b5..21af50f 100644
--- a/qadevOOo/tests/java/ifc/chart/_XChartDataArray.java
+++ b/qadevOOo/tests/java/ifc/chart/_XChartDataArray.java
@@ -163,6 +163,7 @@ public class _XChartDataArray extends MultiMethodTest {
bResult &= dscs.length == colDscs.length;
if (bResult) {
for (int i = 0; i < dscs.length; i++) {
+ log.println("Col " + i + ": got " + dscs[i] + " expected: " + colDscs[i]);
bResult &= dscs[i].equals(colDscs[i]);
}
}
@@ -187,6 +188,7 @@ public class _XChartDataArray extends MultiMethodTest {
bResult &= dscs.length == rowDscs.length;
if (bResult) {
for (int i = 0; i < dscs.length; i++) {
+ log.println("Row " + i + ": got " + dscs[i] + " expected: " + rowDscs[i]);
bResult &= dscs[i].equals(rowDscs[i]);
}
}
commit 94979c53514a34144c19aceb585eef73cf27b5c4
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 15:25:57 2015 +0200
remove useless cast causing a warning
Change-Id: I802dd3d98d5f223d64c90f9020a6dc3eaa1f9c76
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index d627229..f27e2e2 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4434,7 +4434,7 @@ uno::Any SwXTableColumns::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- if(nIndex < 0 || getCount() <= static_cast<size_t>(nIndex))
+ if(nIndex < 0 || getCount() <= nIndex)
throw lang::IndexOutOfBoundsException();
return uno::makeAny(uno::Reference<uno::XInterface>()); // i#21699 not supported
}
commit ab14c7e3a4c32715113bca171839a88193aa77b7
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 14:52:19 2015 +0200
remove unused variable
Change-Id: I7c13b06fb329347e84e34a177e00a9de42f47a6f
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index e438ace..d627229 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4360,7 +4360,6 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
if(nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
- bool bSuccess = false;
SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
OUString sTLName = sw_GetCellName(0, nIndex);
const SwTableBox* pTLBox = pTable->GetTblBox(sTLName);
commit 8f4b3fd788ff6d91b31d6950f2382c3d45a40702
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 14:51:37 2015 +0200
make SwXTextTable::getRowDescriptions reuse SwXCellRange
Change-Id: Ia8194ed8945e7b3ef0eb187545047fa949c4434b
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 895c0bd..e438ace 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2530,45 +2530,13 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
}
}
-uno::Sequence< OUString > SwXTextTable::getRowDescriptions(void) throw( uno::RuntimeException, std::exception )
+uno::Sequence<OUString> SwXTextTable::getRowDescriptions(void)
+ throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- const sal_uInt16 nRowCount = getRowCount();
- if(!nRowCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
- uno::Sequence< OUString > aRet(m_bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
-
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- {
- OUString* pArray = aRet.getArray();
- if(m_bFirstColumnAsLabel)
- {
- const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nRowCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
- if(!xCell.is())
- {
- //exception ...
- break;
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
- pArray[i - nStart] = xText->getString();
- }
- }
- else
- {
- OSL_FAIL("Where do these labels come from?");
- }
- }
- else
- throw uno::RuntimeException();
- return aRet;
+ uno::Reference<chart::XChartDataArray> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(m_bFirstRowAsLabel, m_bFirstColumnAsLabel);
+ return xAllRange->getRowDescriptions();
}
void SwXTextTable::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc) throw( uno::RuntimeException, std::exception )
commit f4b01361213ef62eff7fe718e4e4afc25becb54b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 14:32:35 2015 +0200
make SwXTextTable::getData reuse the code from SwXCellRange
- allow simple passing of the label bools for this
- rename member to match code conventions while at it
Change-Id: I1e754f7f09cd28197185c294a3a8deefc29d05c3
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index cc4b39d..bc81c94 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -322,8 +322,8 @@ private:
unsigned short nRows;
unsigned short nColumns;
- bool bFirstRowAsLabel :1;
- bool bFirstColumnAsLabel :1;
+ bool m_bFirstRowAsLabel;
+ bool m_bFirstColumnAsLabel;
protected:
virtual ~SwXTextTable();
SwXTextTable();
@@ -462,11 +462,13 @@ class SwXCellRange : public cppu::WeakImplHelper7
SwUnoCrsr* pTblCrsr;
- bool bFirstRowAsLabel :1;
- bool bFirstColumnAsLabel :1;
+ bool m_bFirstRowAsLabel;
+ bool m_bFirstColumnAsLabel;
public:
SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, SwRangeDescriptor& rDesc);
+ void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
+ { m_bFirstRowAsLabel = bFirstRowAsLabel, m_bFirstColumnAsLabel = bFirstColumnAsLabel; }
virtual ~SwXCellRange();
TYPEINFO_OVERRIDE();
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index c943da8..895c0bd 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2056,8 +2056,8 @@ SwXTextTable::SwXTextTable()
bIsDescriptor(true),
nRows(2),
nColumns(2),
- bFirstRowAsLabel(false),
- bFirstColumnAsLabel(false)
+ m_bFirstRowAsLabel(false),
+ m_bFirstColumnAsLabel(false)
{ }
SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt)
@@ -2069,8 +2069,8 @@ SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt)
bIsDescriptor(false),
nRows(0),
nColumns(0),
- bFirstRowAsLabel(false),
- bFirstColumnAsLabel(false)
+ m_bFirstRowAsLabel(false),
+ m_bFirstColumnAsLabel(false)
{ }
SwXTextTable::~SwXTextTable()
@@ -2397,8 +2397,6 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- //auto xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1));
- //return static_cast<SwXCellRange*>(xAllRange.get())->getDataArray();
uno::Reference<sheet::XCellRangeData> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
return xAllRange->getDataArray();
}
@@ -2472,45 +2470,12 @@ void SAL_CALL SwXTextTable::setDataArray(
}
uno::Sequence< uno::Sequence< double > > SwXTextTable::getData(void)
- throw( uno::RuntimeException, std::exception )
+ throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- const sal_uInt16 nRowCount = getRowCount();
- const sal_uInt16 nColCount = getColumnCount();
- if(!nRowCount || !nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
-
- SwFrmFmt* pFmt = GetFrmFmt();
- uno::Sequence< uno::Sequence< double > > aRowSeq(bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
- if(pFmt)
- {
- uno::Sequence< double >* pArray = aRowSeq.getArray();
-
- const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
- {
- uno::Sequence< double > aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
- double* pColArray = aColSeq.getArray();
- const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
- for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(nCol, nRow);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- pColArray[nCol - nColStart] = xCell->getValue();
- }
- pArray[nRow - nRowStart] = aColSeq;
- }
- }
- else
- throw uno::RuntimeException();
- return aRowSeq;
+ uno::Reference<chart::XChartDataArray> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(m_bFirstRowAsLabel, m_bFirstColumnAsLabel);
+ return xAllRange->getData();
}
void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData)
@@ -2532,7 +2497,7 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
{
bool bChanged = false;
- const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
+ const sal_uInt16 nRowStart = m_bFirstRowAsLabel ? 1 : 0;
if(rData.getLength() < nRowCount - nRowStart)
{
throw uno::RuntimeException();
@@ -2541,7 +2506,7 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
{
const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
- const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
+ const sal_uInt16 nColStart = m_bFirstColumnAsLabel ? 1 : 0;
if(rColSeq.getLength() < nColCount - nColStart)
{
throw uno::RuntimeException();
@@ -2575,15 +2540,15 @@ uno::Sequence< OUString > SwXTextTable::getRowDescriptions(void) throw( uno::Run
aRuntime.Message = "Table too complex";
throw aRuntime;
}
- uno::Sequence< OUString > aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
+ uno::Sequence< OUString > aRet(m_bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
SwFrmFmt* pFmt = GetFrmFmt();
if(pFmt)
{
OUString* pArray = aRet.getArray();
- if(bFirstColumnAsLabel)
+ if(m_bFirstColumnAsLabel)
{
- const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
+ const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
@@ -2613,14 +2578,14 @@ void SwXTextTable::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
if(pFmt)
{
const sal_uInt16 nRowCount = getRowCount();
- if(!nRowCount || rRowDesc.getLength() < (bFirstRowAsLabel ? nRowCount - 1 : nRowCount))
+ if(!nRowCount || rRowDesc.getLength() < (m_bFirstRowAsLabel ? nRowCount - 1 : nRowCount))
{
throw uno::RuntimeException();
}
const OUString* pArray = rRowDesc.getConstArray();
- if(bFirstColumnAsLabel)
+ if(m_bFirstColumnAsLabel)
{
- const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
+ const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
@@ -2652,14 +2617,14 @@ uno::Sequence< OUString > SwXTextTable::getColumnDescriptions(void)
aRuntime.Message = "Table too complex";
throw aRuntime;
}
- uno::Sequence< OUString > aRet(bFirstRowAsLabel ? nColCount - 1 : nColCount);
+ uno::Sequence< OUString > aRet(m_bFirstRowAsLabel ? nColCount - 1 : nColCount);
SwFrmFmt* pFmt = GetFrmFmt();
if(pFmt)
{
OUString* pArray = aRet.getArray();
- if(bFirstRowAsLabel)
+ if(m_bFirstRowAsLabel)
{
- const sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
+ const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nColCount; i++)
{
uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
@@ -2696,9 +2661,9 @@ void SwXTextTable::setColumnDescriptions(const uno::Sequence< OUString >& rColum
if(pFmt)
{
const OUString* pArray = rColumnDesc.getConstArray();
- if(bFirstRowAsLabel && rColumnDesc.getLength() >= nColCount - (bFirstColumnAsLabel ? 1 : 0))
+ if(m_bFirstRowAsLabel && rColumnDesc.getLength() >= nColCount - (m_bFirstColumnAsLabel ? 1 : 0))
{
- const sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
+ const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nColCount; i++)
{
uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
@@ -2857,10 +2822,10 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
case FN_UNO_RANGE_ROW_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(bFirstRowAsLabel != bTmp)
+ if(m_bFirstRowAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
- bFirstRowAsLabel = bTmp;
+ m_bFirstRowAsLabel = bTmp;
}
}
break;
@@ -2868,10 +2833,10 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
case FN_UNO_RANGE_COL_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(bFirstColumnAsLabel != bTmp)
+ if(m_bFirstColumnAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
- bFirstColumnAsLabel = bTmp;
+ m_bFirstColumnAsLabel = bTmp;
}
}
break;
@@ -3107,12 +3072,12 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
case FN_UNO_RANGE_ROW_LABEL:
{
- aRet <<= bFirstRowAsLabel;
+ aRet <<= m_bFirstRowAsLabel;
}
break;
case FN_UNO_RANGE_COL_LABEL:
- aRet <<= bFirstColumnAsLabel;
+ aRet <<= m_bFirstColumnAsLabel;
break;
case FN_UNO_TABLE_BORDER:
@@ -3531,8 +3496,8 @@ SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt,
aRgDesc(rDesc),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE)),
pTblCrsr(pCrsr),
- bFirstRowAsLabel(false),
- bFirstColumnAsLabel(false)
+ m_bFirstRowAsLabel(false),
+ m_bFirstColumnAsLabel(false)
{
aRgDesc.Normalize();
}
@@ -3726,20 +3691,20 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
case FN_UNO_RANGE_ROW_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(bFirstRowAsLabel != bTmp)
+ if(m_bFirstRowAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_ChartListeners);
- bFirstRowAsLabel = bTmp;
+ m_bFirstRowAsLabel = bTmp;
}
}
break;
case FN_UNO_RANGE_COL_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(bFirstColumnAsLabel != bTmp)
+ if(m_bFirstColumnAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_ChartListeners);
- bFirstColumnAsLabel = bTmp;
+ m_bFirstColumnAsLabel = bTmp;
}
}
break;
@@ -3816,10 +3781,10 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
}
break;
case FN_UNO_RANGE_ROW_LABEL:
- aRet <<= bFirstRowAsLabel;
+ aRet <<= m_bFirstRowAsLabel;
break;
case FN_UNO_RANGE_COL_LABEL:
- aRet <<= bFirstColumnAsLabel;
+ aRet <<= m_bFirstColumnAsLabel;
break;
default:
{
@@ -4111,15 +4076,15 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno:
const sal_uInt16 nColCount = getColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- uno::Sequence< uno::Sequence< double > > aRowSeq(bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
+ uno::Sequence< uno::Sequence< double > > aRowSeq(m_bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
uno::Sequence<double>* pRowArray = aRowSeq.getArray();
- const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
+ const sal_uInt16 nRowStart = m_bFirstRowAsLabel ? 1 : 0;
for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
{
- uno::Sequence<double> aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
+ uno::Sequence<double> aColSeq(m_bFirstColumnAsLabel ? nColCount - 1 : nColCount);
double* pArray = aColSeq.getArray();
- const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
+ const sal_uInt16 nColStart = m_bFirstColumnAsLabel ? 1 : 0;
for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
{
uno::Reference<table::XCell> xCell = getCellByPosition(nCol, nRow);
@@ -4141,14 +4106,14 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
- const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
+ const sal_uInt16 nRowStart = m_bFirstRowAsLabel ? 1 : 0;
if(rData.getLength() < nRowCount - nRowStart)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const uno::Sequence< double >* pRowArray = rData.getConstArray();
for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; ++nRow)
{
const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
- const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
+ const sal_uInt16 nColStart = m_bFirstColumnAsLabel ? 1 : 0;
if(rColSeq.getLength() < nColCount - nColStart)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const double * pColArray = rColSeq.getConstArray();
@@ -4170,12 +4135,12 @@ uno::Sequence<OUString> SwXCellRange::getRowDescriptions(void)
const sal_uInt16 nRowCount = getRowCount();
if(!nRowCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- uno::Sequence<OUString> aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
+ uno::Sequence<OUString> aRet(m_bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
- if(!bFirstColumnAsLabel)
+ if(!m_bFirstColumnAsLabel)
return {}; // without labels we have no descriptions
OUString* pArray = aRet.getArray();
- const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
+ const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
auto xCell = getCellByPosition(0, i);
@@ -4194,12 +4159,12 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
SolarMutexGuard aGuard;
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const sal_uInt16 nRowCount = getRowCount();
- if(!bFirstColumnAsLabel)
+ if(!m_bFirstColumnAsLabel)
return; // if there are no labels we cannot set descriptions
if(!nRowCount || rRowDesc.getLength() < nRowCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const OUString* pArray = rRowDesc.getConstArray();
- const sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
+ const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
@@ -4225,7 +4190,7 @@ void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& Column
const sal_uInt16 nColCount = getColumnCount();
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const OUString* pArray = ColumnDesc.getConstArray();
- if(bFirstColumnAsLabel || ColumnDesc.getLength() < nColCount)
+ if(m_bFirstColumnAsLabel || ColumnDesc.getLength() < nColCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
for(sal_uInt16 i = 0; i < nColCount; i++)
{
commit f86d0413f7cedf096b285c2eb6698653dd99c21e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 01:26:21 2015 +0200
SwXCellRange:: and SwXTextTable::getDataArray() do the same
Change-Id: Ied6712729be7784ec72b1ee5c548527201b406f7
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 95fd5e9..c943da8 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2396,37 +2396,11 @@ uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUStrin
uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
throw (uno::RuntimeException, std::exception)
{
- // see SwXTextTable::getData(...) also
-
SolarMutexGuard aGuard;
- const sal_uInt16 nRowCount = getRowCount();
- const sal_uInt16 nColCount = getColumnCount();
- if(!nRowCount || !nColCount)
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- SwFrmFmt* pFmt(GetFrmFmt());
- uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
- if(!pFmt)
- throw uno::RuntimeException();
- sal_uInt16 nRow = 0;
- for(auto& rRow : aRowSeq)
- {
- rRow = uno::Sequence< uno::Any >(nColCount);
- sal_uInt16 nCol = 0;
- for(auto& rCellAny : rRow)
- {
- SwXCell* pXCell(lcl_CreateXCell(pFmt, nCol++, nRow));
- uno::Reference<table::XCell> xCell = pXCell; // to prevent distruction in UNO calls
- SwTableBox* pBox = pXCell ? pXCell->GetTblBox() : nullptr;
- if(!pBox)
- throw uno::RuntimeException();
- // check if table box value item is set
- SwFrmFmt* pBoxFmt(pBox->GetFrmFmt());
- const bool bIsNum = pBoxFmt->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
- rCellAny = bIsNum ? uno::makeAny(sw_getValue(*pXCell)) : uno::makeAny(lcl_getString(*pXCell));
- }
- ++nRow;
- }
- return aRowSeq;
+ //auto xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1));
+ //return static_cast<SwXCellRange*>(xAllRange.get())->getDataArray();
+ uno::Reference<sheet::XCellRangeData> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
+ return xAllRange->getDataArray();
}
void SAL_CALL SwXTextTable::setDataArray(
@@ -4037,49 +4011,30 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
SolarMutexGuard aGuard;
const sal_uInt16 nRowCount = getRowCount();
const sal_uInt16 nColCount = getColumnCount();
-
if(!nRowCount || !nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwFrmFmt* pFmt(GetFrmFmt());
uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
+ if(!pFmt)
+ throw uno::RuntimeException();
+ sal_uInt16 nRow = 0;
+ for(auto& rRow : aRowSeq)
{
- uno::Sequence< uno::Any >* pRowArray = aRowSeq.getArray();
- uno::Reference< table::XCell > xCellRef;
- for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
+ rRow = uno::Sequence< uno::Any >(nColCount);
+ sal_uInt16 nCol = 0;
+ for(auto& rCellAny : rRow)
{
- uno::Sequence< uno::Any > aColSeq(nColCount);
- uno::Any * pColArray = aColSeq.getArray();
- for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
- {
- SwXCell * pXCell = lcl_CreateXCell(pFmt,
- aRgDesc.nLeft + nCol,
- aRgDesc.nTop + nRow);
- //! keep (additional) reference to object to prevent implicit destruction
- //! in following UNO calls (when object will get referenced)
- xCellRef = pXCell;
- SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
- if(!pBox)
- {
- throw uno::RuntimeException();
- }
- else
- {
- // check if table box value item is set
- SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
- bool bIsNum = pBoxFmt->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET;
- if(!bIsNum)
- pColArray[nCol] <<= lcl_getString(*pXCell);
- else
- pColArray[nCol] <<= sw_getValue(*pXCell);
- }
- }
- pRowArray[nRow] = aColSeq;
+ SwXCell* pXCell(lcl_CreateXCell(pFmt, nCol++, nRow));
+ uno::Reference<table::XCell> xCell = pXCell; // to prevent distruction in UNO calls
+ SwTableBox* pBox = pXCell ? pXCell->GetTblBox() : nullptr;
+ if(!pBox)
+ throw uno::RuntimeException();
+ // check if table box value item is set
+ SwFrmFmt* pBoxFmt(pBox->GetFrmFmt());
+ const bool bIsNum = pBoxFmt->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
+ rCellAny = bIsNum ? uno::makeAny(sw_getValue(*pXCell)) : uno::makeAny(lcl_getString(*pXCell));
}
+ ++nRow;
}
return aRowSeq;
}
commit 439ca5309f7e7659802f7fef44c8690fa099ac22
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Mar 30 00:01:12 2015 +0200
simplify
Change-Id: I358ba505d67d2df6189001bdb0ece9c4676ee67a
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index d478504..95fd5e9 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4154,36 +4154,25 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno:
SolarMutexGuard aGuard;
const sal_uInt16 nRowCount = getRowCount();
const sal_uInt16 nColCount = getColumnCount();
-
if(!nRowCount || !nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
uno::Sequence< uno::Sequence< double > > aRowSeq(bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
+ uno::Sequence<double>* pRowArray = aRowSeq.getArray();
+ const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
+ for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
{
- uno::Sequence< double >* pRowArray = aRowSeq.getArray();
-
- const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
+ uno::Sequence<double> aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
+ double* pArray = aColSeq.getArray();
+ const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
+ for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
{
- uno::Sequence< double > aColSeq(bFirstColumnAsLabel ? nColCount - 1 : nColCount);
- double * pArray = aColSeq.getArray();
- const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
- for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(nCol, nRow);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- pArray[nCol - nColStart] = xCell->getValue();
- }
- pRowArray[nRow - nRowStart] = aColSeq;
+ uno::Reference<table::XCell> xCell = getCellByPosition(nCol, nRow);
+ if(!xCell.is())
+ throw uno::RuntimeException();
+ pArray[nCol - nColStart] = xCell->getValue();
}
+ pRowArray[nRow - nRowStart] = aColSeq;
}
return aRowSeq;
}
commit 670ec2652b682d37b5d712752b14bc17c9c344ac
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 23:56:09 2015 +0200
simplify
Change-Id: I5191dead28a50ad18629d1f46f085f2ea1b8066a
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index e499317..d478504 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4189,44 +4189,31 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno:
}
void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData)
- throw( uno::RuntimeException, std::exception )
+ throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
const sal_uInt16 nRowCount = getRowCount();
const sal_uInt16 nColCount = getColumnCount();
if(!nRowCount || !nColCount)
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
+ const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
+ if(rData.getLength() < nRowCount - nRowStart)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ const uno::Sequence< double >* pRowArray = rData.getConstArray();
+ for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; ++nRow)
{
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt )
- {
- const sal_uInt16 nRowStart = bFirstRowAsLabel ? 1 : 0;
- if(rData.getLength() < nRowCount - nRowStart)
+ const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
+ const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
+ if(rColSeq.getLength() < nColCount - nColStart)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ const double * pColArray = rColSeq.getConstArray();
+ for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
{
- throw uno::RuntimeException();
- }
- const uno::Sequence< double >* pRowArray = rData.getConstArray();
- for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
- {
- const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
- const sal_uInt16 nColStart = bFirstColumnAsLabel ? 1 : 0;
- if(rColSeq.getLength() < nColCount - nColStart)
- {
- throw uno::RuntimeException();
- }
- const double * pColArray = rColSeq.getConstArray();
- for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(nCol, nRow);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- xCell->setValue(pColArray[nCol - nColStart]);
- }
+ uno::Reference<table::XCell> xCell = getCellByPosition(nCol, nRow);
+ if(!xCell.is())
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ xCell->setValue(pColArray[nCol - nColStart]);
}
}
}
commit 2f922eb095d22393d7182bd9e7c2f1116eb539ac
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 23:37:57 2015 +0200
whops, fix subsequentcheck
Change-Id: Icd727e290b2d5851fc3b30e1a697a06a4ad54be0
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 4f72f92..e499317 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4242,7 +4242,7 @@ uno::Sequence<OUString> SwXCellRange::getRowDescriptions(void)
uno::Sequence<OUString> aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
if(!bFirstColumnAsLabel)
- throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ return {}; // without labels we have no descriptions
OUString* pArray = aRet.getArray();
const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
for(sal_uInt16 i = nStart; i < nRowCount; i++)
@@ -4263,16 +4263,19 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
SolarMutexGuard aGuard;
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const sal_uInt16 nRowCount = getRowCount();
- if(!nRowCount || bFirstRowAsLabel|| rRowDesc.getLength() < nRowCount)
+ if(!bFirstColumnAsLabel)
+ return; // if there are no labels we cannot set descriptions
+ if(!nRowCount || rRowDesc.getLength() < nRowCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const OUString* pArray = rRowDesc.getConstArray();
- for(sal_uInt16 i = 0; i < nRowCount; i++)
+ const sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
+ for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
if(!xCell.is())
throw uno::RuntimeException();
uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
- xText->setString(pArray[i]);
+ xText->setString(pArray[i-nStart]);
}
}
commit 374d2bcf67dac2bf7b41ac2d96eb666c627499ef
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 15:12:39 2015 +0200
use helper function for precond check
Change-Id: I6b3c9d50229265e26c1dc8da9194164c18c1687a
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index b81d734..4f72f92 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -121,6 +121,12 @@ namespace
throw uno::RuntimeException("Lost connection to core objects", pObject);
return pFmt;
}
+ SwTable* lcl_EnsureTableNotComplex(SwTable* pTable, cppu::OWeakObject* pObject)
+ {
+ if(pTable->IsTblComplex())
+ throw uno::RuntimeException("Table too complex", pObject);
+ return pTable;
+ }
}
#define UNO_TABLE_COLUMN_SUM 10000
@@ -4446,9 +4452,7 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
if (nCount == 0)
return;
SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
- SwTable* pTable = SwTable::FindTable(pFrmFmt);
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
const size_t nRowCount = pTable->GetTabLines().size();
if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nRowCount))
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
@@ -4490,9 +4494,7 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
if(nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
bool bSuccess = false;
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
OUString sTLName = sw_GetCellName(0, nIndex);
const SwTableBox* pTLBox = pTable->GetTblBox(sTLName);
if(!pTLBox)
@@ -4591,9 +4593,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
if (nCount == 0)
return;
SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
SwTableLines& rLines = pTable->GetTabLines();
SwTableLine* pLine = rLines.front();
const size_t nColCount = pLine->GetTabBoxes().size();
@@ -4636,9 +4636,7 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
if(nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
- SwTable* pTable = SwTable::FindTable(pFrmFmt);
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
const OUString sTLName = sw_GetCellName(nIndex, 0);
const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
if(!pTLBox)
commit 696f79a80d93a53b8c05bfef71865e05b0bc03e9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 15:06:17 2015 +0200
use helper function for precond check
Change-Id: I427c83b27de7adf947ad7f15a5453d51ed4b49b7
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index f7dcc90..b81d734 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -115,6 +115,12 @@ namespace
const Tcoretype* const m_pCore;
mutable Tunotype* m_pResult;
};
+ SwFrmFmt* lcl_EnsureCoreConnected(SwFrmFmt* pFmt, cppu::OWeakObject* pObject)
+ {
+ if(!pFmt)
+ throw uno::RuntimeException("Lost connection to core objects", pObject);
+ return pFmt;
+ }
}
#define UNO_TABLE_COLUMN_SUM 10000
@@ -4228,8 +4234,8 @@ uno::Sequence<OUString> SwXCellRange::getRowDescriptions(void)
if(!nRowCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
uno::Sequence<OUString> aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
- SwFrmFmt* pFmt(GetFrmFmt());
- if(!pFmt || !bFirstColumnAsLabel)
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
+ if(!bFirstColumnAsLabel)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
OUString* pArray = aRet.getArray();
const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
@@ -4249,9 +4255,7 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
throw(uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- SwFrmFmt* pFmt(GetFrmFmt());
- if(!pFmt)
- return;
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const sal_uInt16 nRowCount = getRowCount();
if(!nRowCount || bFirstRowAsLabel|| rRowDesc.getLength() < nRowCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
@@ -4279,9 +4283,7 @@ void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& Column
{
SolarMutexGuard aGuard;
const sal_uInt16 nColCount = getColumnCount();
- SwFrmFmt* pFmt = GetFrmFmt();
- if(!pFmt)
- return;
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const OUString* pArray = ColumnDesc.getConstArray();
if(bFirstColumnAsLabel || ColumnDesc.getLength() < nColCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
@@ -4407,8 +4409,8 @@ uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- SwFrmFmt* pFrmFmt = GetFrmFmt();
- if(!pFrmFmt || nIndex < 0 )
+ SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
+ if(nIndex < 0)
throw lang::IndexOutOfBoundsException();
SwTable* pTable = SwTable::FindTable( pFrmFmt );
if(static_cast<size_t>(nIndex) >= pTable->GetTabLines().size())
@@ -4443,9 +4445,7 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SolarMutexGuard aGuard;
if (nCount == 0)
return;
- SwFrmFmt* pFrmFmt = GetFrmFmt();
- if(!pFrmFmt)
- throw uno::RuntimeException();
+ SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
SwTable* pTable = SwTable::FindTable(pFrmFmt);
if(pTable->IsTblComplex())
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
@@ -4486,8 +4486,8 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SolarMutexGuard aGuard;
if (nCount == 0)
return;
- SwFrmFmt* pFrmFmt = GetFrmFmt();
- if(!pFrmFmt || nIndex < 0 || nCount <=0 )
+ SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
+ if(nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
bool bSuccess = false;
SwTable* pTable = SwTable::FindTable( pFrmFmt );
@@ -4553,9 +4553,7 @@ SwXTableColumns::~SwXTableColumns()
sal_Int32 SwXTableColumns::getCount(void) throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- SwFrmFmt* pFrmFmt(GetFrmFmt());
- if(!pFrmFmt)
- throw uno::RuntimeException();
+ SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
SwTable* pTable = SwTable::FindTable( pFrmFmt );
// if(!pTable->IsTblComplex())
// throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
@@ -4581,9 +4579,7 @@ uno::Type SAL_CALL SwXTableColumns::getElementType(void) throw( uno::RuntimeExce
sal_Bool SwXTableColumns::hasElements(void) throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- SwFrmFmt* pFrmFmt = GetFrmFmt();
- if(!pFrmFmt)
- throw uno::RuntimeException();
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
return sal_True;
}
@@ -4594,9 +4590,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SolarMutexGuard aGuard;
if (nCount == 0)
return;
- SwFrmFmt* pFrmFmt = GetFrmFmt();
- if(!pFrmFmt)
- throw uno::RuntimeException();
+ SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
SwTable* pTable = SwTable::FindTable( pFrmFmt );
if(pTable->IsTblComplex())
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
@@ -4639,8 +4633,8 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SolarMutexGuard aGuard;
if (nCount == 0)
return;
- SwFrmFmt* pFrmFmt(GetFrmFmt());
- if(!pFrmFmt|| nIndex < 0 || nCount <=0 )
+ SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
+ if(nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
SwTable* pTable = SwTable::FindTable(pFrmFmt);
if(pTable->IsTblComplex())
commit 56b5f7ff3b1a4f6842101f6e0be3a9c80bd0b847
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 14:45:25 2015 +0200
simplify
Change-Id: I550ed187381fd92bf8a11775f8f2eda65b25d288
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 923bed2..f7dcc90 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4220,43 +4220,27 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData
}
///@see SwXTextTable::getRowDescriptions (TODO: seems to be copy and paste programming here)
-uno::Sequence< OUString > SwXCellRange::getRowDescriptions(void)
- throw( uno::RuntimeException, std::exception )
+uno::Sequence<OUString> SwXCellRange::getRowDescriptions(void)
+ throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
const sal_uInt16 nRowCount = getRowCount();
if(!nRowCount)
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ uno::Sequence<OUString> aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
+ SwFrmFmt* pFmt(GetFrmFmt());
+ if(!pFmt || !bFirstColumnAsLabel)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ OUString* pArray = aRet.getArray();
+ const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
+ for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
- uno::Sequence< OUString > aRet(bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- {
- OUString* pArray = aRet.getArray();
- if(bFirstColumnAsLabel)
- {
- const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nRowCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
- pArray[i - nStart] = xText->getString();
- }
- }
- else
- {
- OSL_FAIL("Where do these labels come from?");
- }
+ auto xCell = getCellByPosition(0, i);
+ if(!xCell.is())
+ throw uno::RuntimeException();
+ uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
+ pArray[i - nStart] = xText->getString();
}
- else
- throw uno::RuntimeException();
return aRet;
}
commit 26ae223d74a49ba51d22c68f1a3772a3d2421d9b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 13:49:51 2015 +0200
fix subsequentchecks
Change-Id: If4e87c59b4c2b28c2c42d4a3fb83959589b97e63
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index eff9359..923bed2 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4269,7 +4269,7 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
if(!pFmt)
return;
const sal_uInt16 nRowCount = getRowCount();
- if(!nRowCount || bFirstRowAsLabel|| RowDesc.getLength() < nRowCount)
+ if(!nRowCount || bFirstRowAsLabel|| rRowDesc.getLength() < nRowCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const OUString* pArray = rRowDesc.getConstArray();
for(sal_uInt16 i = 0; i < nRowCount; i++)
@@ -4573,8 +4573,8 @@ sal_Int32 SwXTableColumns::getCount(void) throw( uno::RuntimeException, std::exc
if(!pFrmFmt)
throw uno::RuntimeException();
SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(!pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+// if(!pTable->IsTblComplex())
+// throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
SwTableLines& rLines = pTable->GetTabLines();
SwTableLine* pLine = rLines.front();
return pLine->GetTabBoxes().size();
commit cdd40eb7c0a65c313b1d5887517e128e46b23902
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 01:36:51 2015 +0100
simplify
Change-Id: Ia3fad4e1272f72a09062cdb3d03cb391081e5dd5
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 40572a5..eff9359 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4262,37 +4262,23 @@ uno::Sequence< OUString > SwXCellRange::getRowDescriptions(void)
///@see SwXTextTable::setRowDescriptions (TODO: seems to be copy and paste programming here)
void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
- throw( uno::RuntimeException, std::exception )
+ throw(uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
-
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
+ SwFrmFmt* pFmt(GetFrmFmt());
+ if(!pFmt)
+ return;
+ const sal_uInt16 nRowCount = getRowCount();
+ if(!nRowCount || bFirstRowAsLabel|| RowDesc.getLength() < nRowCount)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ const OUString* pArray = rRowDesc.getConstArray();
+ for(sal_uInt16 i = 0; i < nRowCount; i++)
{
- const sal_uInt16 nRowCount = getRowCount();
- if(!nRowCount || rRowDesc.getLength() < (bFirstRowAsLabel ? nRowCount - 1 : nRowCount))
- {
+ uno::Reference<table::XCell> xCell = getCellByPosition(0, i);
+ if(!xCell.is())
throw uno::RuntimeException();
- }
- const OUString* pArray = rRowDesc.getConstArray();
- if(bFirstColumnAsLabel)
- {
- const sal_uInt16 nStart = bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nRowCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(0, i);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
- xText->setString(pArray[i - nStart]);
- }
- }
- else
- {
- OSL_FAIL("Where to put theses labels?");
- }
+ uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
+ xText->setString(pArray[i]);
}
}
commit 2f241ed70c5065b526cac88a3400f9c47830f516
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 01:30:49 2015 +0100
simplify/eat copypasta
Change-Id: I388c314b4baf72e889a0b23a1fbd1c0f0715e80d
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 6a431a3..40572a5 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4262,9 +4262,10 @@ uno::Sequence< OUString > SwXCellRange::getRowDescriptions(void)
///@see SwXTextTable::setRowDescriptions (TODO: seems to be copy and paste programming here)
void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
- throw( uno::RuntimeException, std::exception )
+ throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
+
SwFrmFmt* pFmt = GetFrmFmt();
if(pFmt)
{
@@ -4295,48 +4296,14 @@ void SwXCellRange::setRowDescriptions(const uno::Sequence< OUString >& rRowDesc)
}
}
-///@see SwXTextTable::setColumnDescriptions (TODO: seems to be copy and paste programming here)
uno::Sequence< OUString > SwXCellRange::getColumnDescriptions(void)
- throw( uno::RuntimeException, std::exception )
+ throw(uno::RuntimeException, std::exception)
{
- SolarMutexGuard aGuard;
- const sal_uInt16 nColCount = getColumnCount();
- if(!nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
- uno::Sequence< OUString > aRet(bFirstRowAsLabel ? nColCount - 1 : nColCount);
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- {
- OUString* pArray = aRet.getArray();
- if(bFirstRowAsLabel)
- {
- const sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nColCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
- pArray[i - nStart] = xText->getString();
- }
- }
- else
- {
- OSL_FAIL("Where do these labels come from?");
- }
- }
- else
- throw uno::RuntimeException();
- return aRet;
+ uno::Sequence<OUString> vResult(getColumnCount());
+ setColumnDescriptions(vResult);
+ return vResult;
}
-///@see SwXTextTable::setColumnDescriptions (TODO: seems to be copy and paste programming here)
void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& ColumnDesc)
throw( uno::RuntimeException, std::exception )
{
commit 99ecd8abe7e9a65e1d4af04ee160d3941aadebad
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 01:14:51 2015 +0100
simplify
Change-Id: I2bd8e4e121c9919b52b69a6672aaa7f061d986bb
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index d8a216a..6a431a3 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4338,33 +4338,23 @@ uno::Sequence< OUString > SwXCellRange::getColumnDescriptions(void)
///@see SwXTextTable::setColumnDescriptions (TODO: seems to be copy and paste programming here)
void SwXCellRange::setColumnDescriptions(const uno::Sequence< OUString >& ColumnDesc)
- throw( uno::RuntimeException, std::exception )
+ throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
const sal_uInt16 nColCount = getColumnCount();
SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
+ if(!pFmt)
+ return;
+ const OUString* pArray = ColumnDesc.getConstArray();
+ if(bFirstColumnAsLabel || ColumnDesc.getLength() < nColCount)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ for(sal_uInt16 i = 0; i < nColCount; i++)
{
- const OUString* pArray = ColumnDesc.getConstArray();
- if(bFirstRowAsLabel && ColumnDesc.getLength() >= nColCount - (bFirstColumnAsLabel ? 1 : 0))
- {
- const sal_uInt16 nStart = bFirstColumnAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nColCount; i++)
- {
- uno::Reference< table::XCell > xCell = getCellByPosition(i, 0);
- if(!xCell.is())
- {
- throw uno::RuntimeException();
- }
- uno::Reference< text::XText > xText(xCell, uno::UNO_QUERY);
-
- xText->setString(pArray[i - nStart]);
- }
- }
- else
- {
- OSL_FAIL("Where to put theses labels?");
- }
+ uno::Reference<table::XCell> xCell = getCellByPosition(i, 0);
+ if(!xCell.is())
+ throw uno::RuntimeException();
+ uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
+ xText->setString(pArray[i]);
}
}
commit 2326a22140f46c2b4cb2fbde72ac5444f478ee44
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 01:04:43 2015 +0100
be honest and except when not implemented
Change-Id: I4508dd683fd7ff506cfaec7ce42c1fa10438983a
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 0991e18..d8a216a 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4385,21 +4385,14 @@ throw (uno::RuntimeException, std::exception)
}
sal_Bool SwXCellRange::isNotANumber(double /*fNumber*/) throw( uno::RuntimeException, std::exception )
-{
- OSL_FAIL("not implemented");
- return sal_False;
-}
+ { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
double SwXCellRange::getNotANumber(void) throw( uno::RuntimeException, std::exception )
-{
- OSL_FAIL("not implemented");
- return 0.;
-}
+ { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor(void) throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
-
return SwUnoCursorHelper::CreateSortDescriptor(true);
}
@@ -4409,26 +4402,21 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD
{
SolarMutexGuard aGuard;
SwSortOptions aSortOpt;
- SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt &&
- SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
+ SwFrmFmt* pFmt(GetFrmFmt());
+ if(pFmt && SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
{
SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*pTblCrsr);
rTableCrsr.MakeBoxSels();
- UnoActionContext aContext( pFmt->GetDoc() );
+ UnoActionContext aContext(pFmt->GetDoc());
pFmt->GetDoc()->SortTbl(rTableCrsr.GetSelectedBoxes(), aSortOpt);
}
}
sal_uInt16 SwXCellRange::getColumnCount(void)
-{
- return static_cast<sal_uInt16>(aRgDesc.nRight - aRgDesc.nLeft + 1);
-}
+ { return static_cast<sal_uInt16>(aRgDesc.nRight - aRgDesc.nLeft + 1); }
sal_uInt16 SwXCellRange::getRowCount(void)
-{
- return static_cast<sal_uInt16>(aRgDesc.nBottom - aRgDesc.nTop + 1);
-}
+ { return static_cast<sal_uInt16>(aRgDesc.nBottom - aRgDesc.nTop + 1); }
const SwUnoCrsr* SwXCellRange::GetTblCrsr() const
{
commit fda5c4d4d268aaab5f778b93f08a9b42a9c26ae9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 01:01:44 2015 +0100
flatten and simplify
Change-Id: Ib3562bafa3a21538918d98e8ed416f8b20067114
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 6fda68a..0991e18 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4422,21 +4422,18 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD
sal_uInt16 SwXCellRange::getColumnCount(void)
{
- return static_cast< sal_uInt16 >(aRgDesc.nRight - aRgDesc.nLeft + 1);
+ return static_cast<sal_uInt16>(aRgDesc.nRight - aRgDesc.nLeft + 1);
}
sal_uInt16 SwXCellRange::getRowCount(void)
{
- return static_cast< sal_uInt16 >(aRgDesc.nBottom - aRgDesc.nTop + 1);
+ return static_cast<sal_uInt16>(aRgDesc.nBottom - aRgDesc.nTop + 1);
}
const SwUnoCrsr* SwXCellRange::GetTblCrsr() const
{
- const SwUnoCrsr* pRet = 0;
SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt)
- pRet = pTblCrsr;
- return pRet;
+ return pFmt ? pTblCrsr : nullptr;
}
void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
commit ec1901ef85adb3c1ebf2847d5ecd1d2a76a08f47
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 00:59:47 2015 +0100
reduce UNO boilerplate
Change-Id: I7fa6a5fcd8bf1ac82d089a1db0e0ae40e4700bf8
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 11081fc..6fda68a 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4463,32 +4463,22 @@ void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
// SwXTableRows
OUString SwXTableRows::getImplementationName(void) throw( uno::RuntimeException, std::exception )
-{
- return OUString("SwXTableRows");
-}
+ { return OUString("SwXTableRows"); }
sal_Bool SwXTableRows::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
-{
- return cppu::supportsService(this, rServiceName);
-}
+ { return cppu::supportsService(this, rServiceName); }
uno::Sequence< OUString > SwXTableRows::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
-{
- uno::Sequence< OUString > aRet(1);
- OUString* pArray = aRet.getArray();
- pArray[0] = "com.sun.star.text.TableRows";
- return aRet;
-}
+ { return { "com.sun.star.text.TableRows" }; }
+
TYPEINIT1(SwXTableRows, SwClient);
SwXTableRows::SwXTableRows(SwFrmFmt& rFrmFmt) :
SwClient(&rFrmFmt)
-{
-}
+{ }
SwXTableRows::~SwXTableRows()
-{
-}
+{ }
sal_Int32 SwXTableRows::getCount(void) throw( uno::RuntimeException, std::exception )
{
commit 0ffa1e835b68a627c4238eef9d3829282a544801
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 00:57:33 2015 +0100
flatten and simplify
Change-Id: I5f00f8f31dee2841fb993f310be256a166042c85
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 09f90c6..11081fc 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4493,16 +4493,11 @@ SwXTableRows::~SwXTableRows()
sal_Int32 SwXTableRows::getCount(void) throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- sal_Int32 nRet = 0;
SwFrmFmt* pFrmFmt = GetFrmFmt();
if(!pFrmFmt)
throw uno::RuntimeException();
- else
- {
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- nRet = pTable->GetTabLines().size();
- }
- return nRet;
+ SwTable* pTable = SwTable::FindTable(pFrmFmt);
+ return pTable->GetTabLines().size();
}
///@see SwXCell::CreateXCell (TODO: seems to be copy and paste programming here)
commit fe447d2e1b6e1b0fa5d3d12bf5e8b3dab5733da0
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 00:56:08 2015 +0100
flatten and simplify
Change-Id: I2ec511a662b8109399cc2d836108fe8ceb12a1b8
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index fbd5f3c..09f90c6 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4549,50 +4549,38 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt = GetFrmFmt();
if(!pFrmFmt)
throw uno::RuntimeException();
- else
+ SwTable* pTable = SwTable::FindTable(pFrmFmt);
+ if(pTable->IsTblComplex())
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ const size_t nRowCount = pTable->GetTabLines().size();
+ if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nRowCount))
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ const OUString sTLName = sw_GetCellName(0, nIndex);
+ const SwTableBox* pTLBox = pTable->GetTblBox(sTLName);
+ bool bAppend = false;
+ if(!pTLBox)
{
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(!pTable->IsTblComplex())
- {
- const size_t nRowCount = pTable->GetTabLines().size();
- if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nRowCount))
- {
- uno::RuntimeException aExcept;
- aExcept.Message = "Illegal arguments";
- throw aExcept;
- }
-
- const OUString sTLName = sw_GetCellName(0, nIndex);
- const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
- bool bAppend = false;
- if(!pTLBox)
- {
- bAppend = true;
- // to append at the end the cursor must be in the last line
- SwTableLines& rLines = pTable->GetTabLines();
- SwTableLine* pLine = rLines.back();
- SwTableBoxes& rBoxes = pLine->GetTabBoxes();
- pTLBox = rBoxes.front();
- }
- if(pTLBox)
- {
- const SwStartNode* pSttNd = pTLBox->GetSttNd();
- SwPosition aPos(*pSttNd);
- // set cursor to the upper-left cell of the range
- UnoActionContext aAction(pFrmFmt->GetDoc());
- SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
- pUnoCrsr->Move( fnMoveForward, fnGoNode );
-
- {
- // remove actions
- UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
- }
-
- pFrmFmt->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
- delete pUnoCrsr;
- }
- }
+ bAppend = true;
+ // to append at the end the cursor must be in the last line
+ SwTableLines& rLines = pTable->GetTabLines();
+ SwTableLine* pLine = rLines.back();
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ pTLBox = rBoxes.front();
+ }
+ if(!pTLBox)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ const SwStartNode* pSttNd = pTLBox->GetSttNd();
+ SwPosition aPos(*pSttNd);
+ // set cursor to the upper-left cell of the range
+ UnoActionContext aAction(pFrmFmt->GetDoc());
+ SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
+ pUnoCrsr->Move( fnMoveForward, fnGoNode );
+ {
+ // remove actions
+ UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
}
+ pFrmFmt->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
+ delete pUnoCrsr;
}
void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
commit 78ccfb18662af879b9ed12451efb097c4dda3118
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 00:51:54 2015 +0100
flatten and simplify
Change-Id: Ie2500d115d3fd856481345430839507c814c1bac
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index fb3a4fd..fbd5f3c 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4604,55 +4604,41 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt = GetFrmFmt();
if(!pFrmFmt || nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
- else
+ bool bSuccess = false;
+ SwTable* pTable = SwTable::FindTable( pFrmFmt );
+ if(pTable->IsTblComplex())
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ OUString sTLName = sw_GetCellName(0, nIndex);
+ const SwTableBox* pTLBox = pTable->GetTblBox(sTLName);
+ if(!pTLBox)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
{
- bool bSuccess = false;
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(!pTable->IsTblComplex())
- {
- OUString sTLName = sw_GetCellName(0, nIndex);
- const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
- if(pTLBox)
- {
- {
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
- }
- const SwStartNode* pSttNd = pTLBox->GetSttNd();
- SwPosition aPos(*pSttNd);
- // set cursor to the upper-left cell of the range
- SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
- pUnoCrsr->Move( fnMoveForward, fnGoNode );
- pUnoCrsr->SetRemainInSection( false );
- const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
- const SwTableBox* pBLBox = pTable->GetTblBox( sBLName );
- if(pBLBox)
- {
- pUnoCrsr->SetMark();
- pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
- pUnoCrsr->Move( fnMoveForward, fnGoNode );
- SwUnoTableCrsr* pCrsr =
- dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
- pCrsr->MakeBoxSels();
- { // these braces are important
- UnoActionContext aAction(pFrmFmt->GetDoc());
- pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr);
- delete pUnoCrsr;
- bSuccess = true;
- }
- {
- // invalidate all actions
- UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
- }
- }
- }
- }
- if(!bSuccess)
- {
- uno::RuntimeException aExcept;
- aExcept.Message = "Illegal arguments";
- throw aExcept;
- }
+ // invalidate all actions
+ UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
+ }
+ const SwStartNode* pSttNd = pTLBox->GetSttNd();
+ SwPosition aPos(*pSttNd);
+ // set cursor to the upper-left cell of the range
+ SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
+ pUnoCrsr->Move(fnMoveForward, fnGoNode);
+ pUnoCrsr->SetRemainInSection( false );
+ const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
+ const SwTableBox* pBLBox = pTable->GetTblBox( sBLName );
+ if(!pBLBox)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ pUnoCrsr->SetMark();
+ pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
+ pUnoCrsr->Move(fnMoveForward, fnGoNode);
+ SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
+ pCrsr->MakeBoxSels();
+ { // these braces are important
+ UnoActionContext aAction(pFrmFmt->GetDoc());
+ pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr);
+ delete pUnoCrsr;
+ }
+ {
+ // invalidate all actions
+ UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
}
}
commit 326177f4c4f3ae07fef9b66328abcea91ee18358
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 00:39:33 2015 +0100
reduce UNO boilerplate
Change-Id: I4f63b15c3c3f6e9e22d4a4732eef64190769dbba
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 85e30ce..fb3a4fd 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4657,40 +4657,27 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
}
void SwXTableRows::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
-{
- ClientModify(this, pOld, pNew);
-}
+ { ClientModify(this, pOld, pNew); }
// SwXTableColumns
OUString SwXTableColumns::getImplementationName(void) throw( uno::RuntimeException, std::exception )
-{
- return OUString("SwXTableColumns");
-}
+ { return OUString("SwXTableColumns"); }
sal_Bool SwXTableColumns::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
-{
- return cppu::supportsService(this, rServiceName);
-}
+ { return cppu::supportsService(this, rServiceName); }
uno::Sequence< OUString > SwXTableColumns::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
-{
- uno::Sequence< OUString > aRet(1);
- OUString* pArray = aRet.getArray();
- pArray[0] = "com.sun.star.text.TableColumns";
- return aRet;
-}
+ { return { "com.sun.star.text.TableColumns"}; }
TYPEINIT1(SwXTableColumns, SwClient);
SwXTableColumns::SwXTableColumns(SwFrmFmt& rFrmFmt) :
SwClient(&rFrmFmt)
-{
-}
+{ }
SwXTableColumns::~SwXTableColumns()
-{
-}
+{ }
sal_Int32 SwXTableColumns::getCount(void) throw( uno::RuntimeException, std::exception )
{
@@ -4712,7 +4699,7 @@ uno::Any SwXTableColumns::getByIndex(sal_Int32 nIndex)
SolarMutexGuard aGuard;
if(nIndex < 0 || getCount() <= static_cast<size_t>(nIndex))
throw lang::IndexOutOfBoundsException();
- return uno::makeAny(uno::Reference<uno::XInterface()); // i#21699 not supported
+ return uno::makeAny(uno::Reference<uno::XInterface>()); // i#21699 not supported
}
uno::Type SAL_CALL SwXTableColumns::getElementType(void) throw( uno::RuntimeException, std::exception )
commit 12038a6191798211823cecc070bc02b8ad36956d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 00:37:21 2015 +0100
getCount() should throw exceptions on complex table like others
Change-Id: Ie504426209601695131e4c684bde7ee27fac87d8
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 41040b5..85e30ce 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4695,21 +4695,15 @@ SwXTableColumns::~SwXTableColumns()
sal_Int32 SwXTableColumns::getCount(void) throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- sal_Int32 nRet = 0;
- SwFrmFmt* pFrmFmt = GetFrmFmt();
+ SwFrmFmt* pFrmFmt(GetFrmFmt());
if(!pFrmFmt)
throw uno::RuntimeException();
- else
- {
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(!pTable->IsTblComplex())
- {
- SwTableLines& rLines = pTable->GetTabLines();
- SwTableLine* pLine = rLines.front();
- nRet = pLine->GetTabBoxes().size();
- }
- }
- return nRet;
+ SwTable* pTable = SwTable::FindTable( pFrmFmt );
+ if(!pTable->IsTblComplex())
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTableLines& rLines = pTable->GetTabLines();
+ SwTableLine* pLine = rLines.front();
+ return pLine->GetTabBoxes().size();
}
uno::Any SwXTableColumns::getByIndex(sal_Int32 nIndex)
commit e0bc0b7aeb18ff638d826f07e243af776b7a5a3c
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 29 00:34:05 2015 +0100
simplify
Change-Id: I45bf66ce275fd78cf62b13146b6d088d4cdb910b
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 11e0ed3..41040b5 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4716,25 +4716,9 @@ uno::Any SwXTableColumns::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- uno::Reference< uno::XInterface > xRet;
- SwFrmFmt* pFrmFmt = GetFrmFmt();
- if(!pFrmFmt)
- throw uno::RuntimeException();
- else
- {
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list