[Libreoffice-commits] core.git: 19 commits - sw/qa sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Mon Apr 13 08:22:25 PDT 2015
sw/qa/python/check_table.py | 59 +++-
sw/source/core/unocore/unotbl.cxx | 503 +++++++++++++-------------------------
2 files changed, 220 insertions(+), 342 deletions(-)
New commits:
commit d0b4c6e4bacc9e894cbee2b34e6242c67566f9df
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Apr 13 14:45:14 2015 +0200
add some label tests
Change-Id: I4272be68041a269dce3bbd9de2bc7997cbcf9ab8
diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index e85246a..ab3adde 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -333,6 +333,12 @@ class CheckTable(unittest.TestCase):
xTable.ChartRowAsLabel = True
self.assertEqual( xTable.Data, ((5,6), (8,9)))
xTable.Data = ((55,66), (88,99))
+ xTable.ChartColumnAsLabel = True
+ xTable.ChartRowAsLabel = False
+ self.assertEqual( xTable.Data, ((2,3), (55,66), (88,99)))
+ xTable.ChartColumnAsLabel = False
+ xTable.ChartRowAsLabel = True
+ self.assertEqual( xTable.Data, ((4,55,66), (7,88,99)))
xTable.ChartColumnAsLabel = False
xTable.ChartRowAsLabel = False
self.assertEqual( xTable.Data, ((1,2,3), (4,55,66), (7,88,99)))
commit 615c293198a631558bc4b39091b3c999732e28f2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Apr 13 01:38:51 2015 +0200
add set/getData tests
Change-Id: I846ac849461d986d331b0366c36af46558fe9a14
diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index 773a71f..e85246a 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -8,6 +8,14 @@ from com.sun.star.table.BorderLineStyle import (DOUBLE, SOLID, EMBOSSED,\
class CheckTable(unittest.TestCase):
_uno = None
+ def _fill_table(self, xTable):
+ for x in range(3):
+ for y in range(3):
+ xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
+ def _check_table(self, xTable):
+ for x in range(3):
+ for y in range(3):
+ self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
@classmethod
def setUpClass(cls):
cls._uno = UnoInProcess()
@@ -248,14 +256,6 @@ class CheckTable(unittest.TestCase):
# close document
xDoc.dispose()
- def _fill_table(self, xTable):
- for x in range(3):
- for y in range(3):
- xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
- def _check_table(self, xTable):
- for x in range(3):
- for y in range(3):
- self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
def test_descriptions(self):
xDoc = CheckTable._uno.openEmptyWriterDoc()
# insert table
@@ -310,6 +310,33 @@ class CheckTable(unittest.TestCase):
foo = xTable2.ColumnDescriptions
xDoc.dispose()
+ def test_getset_data(self):
+ xDoc = CheckTable._uno.openEmptyWriterDoc()
+ # insert table
+ xTable = xDoc.createInstance("com.sun.star.text.TextTable")
+ xTable.initialize(3, 3)
+ xCursor = xDoc.Text.createTextCursor()
+ xDoc.Text.insertTextContent(xCursor, xTable, False)
+ xTable.ChartColumnAsLabel = False
+ xTable.ChartRowAsLabel = False
+ # roundtrip
+ xTable.Data = ((1,2,3), (4,5,6), (7,8,9))
+ self.assertEqual( xTable.Data, ((1,2,3), (4,5,6), (7,8,9)))
+ # missing row
+ with self.assertRaises(Exception):
+ xTable.Data = ((1,2,3), (4,5,6))
+ # missing column
+ with self.assertRaises(Exception):
+ xTable.Data = ((1,2), (4,5), (7,8))
+ # with labels
+ xTable.ChartColumnAsLabel = True
+ xTable.ChartRowAsLabel = True
+ self.assertEqual( xTable.Data, ((5,6), (8,9)))
+ xTable.Data = ((55,66), (88,99))
+ xTable.ChartColumnAsLabel = False
+ xTable.ChartRowAsLabel = False
+ self.assertEqual( xTable.Data, ((1,2,3), (4,55,66), (7,88,99)))
+ xDoc.dispose()
if __name__ == '__main__':
unittest.main()
commit ea3661e622acdee357fc5ff0c4d01db781b94d37
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Apr 13 01:05:27 2015 +0200
move check_table/fill_table from inner f. to priv. member fnct.
Change-Id: I7670f8164d8a44414277f285e3aa19de1764a86e
diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index a8cf3a9..773a71f 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -248,15 +248,15 @@ class CheckTable(unittest.TestCase):
# close document
xDoc.dispose()
+ def _fill_table(self, xTable):
+ for x in range(3):
+ for y in range(3):
+ xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
+ def _check_table(self, xTable):
+ for x in range(3):
+ for y in range(3):
+ self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
def test_descriptions(self):
- def fill_table():
- for x in range(3):
- for y in range(3):
- xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
- def check_table():
- for x in range(3):
- for y in range(3):
- self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
xDoc = CheckTable._uno.openEmptyWriterDoc()
# insert table
xTable = xDoc.createInstance("com.sun.star.text.TextTable")
@@ -266,8 +266,8 @@ class CheckTable(unittest.TestCase):
self.assertEqual(3, xTable.Rows.Count)
self.assertEqual(3, xTable.Columns.Count)
# fill table
- fill_table()
- check_table()
+ self._fill_table(xTable)
+ self._check_table(xTable)
# check without labels first
xTable.ChartColumnAsLabel = False
xTable.ChartRowAsLabel = False
@@ -275,7 +275,7 @@ class CheckTable(unittest.TestCase):
self.assertEqual(0, len(xTable.ColumnDescriptions))
self.RowDescriptions = ('foo', 'bar', 'baz') # no labels, thus noop
self.ColumnDescriptions = ('foo', 'bar', 'baz') # no labels, thus noop
- check_table()
+ self._check_table(xTable)
# now check with labels
xTable.ChartColumnAsLabel = True
xTable.ChartRowAsLabel = True
@@ -289,7 +289,7 @@ class CheckTable(unittest.TestCase):
xTable.RowDescriptions = ('foo',) # too short
with self.assertRaises(Exception):
xTable.ColumnDescriptions = ('foo',) # too short
- check_table()
+ self._check_table(xTable)
xTable.RowDescriptions = ('fooRow', 'bazRow')
xTable.ColumnDescriptions = ('fooColumn', 'bazColumn')
self.assertEqual('fooRow', xTable.getCellByPosition(0,1).String)
@@ -300,7 +300,7 @@ class CheckTable(unittest.TestCase):
xTable.getCellByPosition(0,2).String = 'Cell 0 2'
xTable.getCellByPosition(1,0).String = 'Cell 1 0'
xTable.getCellByPosition(2,0).String = 'Cell 2 0'
- check_table() # ... to ensure the rest was untouched
+ self._check_table(xTable) # ... to ensure the rest was untouched
# check disconnected table excepts, but doesnt crash
xTable2 = xDoc.createInstance("com.sun.star.text.TextTable")
xTable2.initialize(3, 3)
commit ea35a682d2f5b508293e6dcef23629c435fcb6e1
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 02:53:49 2015 +0200
use getCells()
Change-Id: Ib3e115b7b96d0536db6917e84cfac7816176b296
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 588ad25..4ab232d 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3674,13 +3674,13 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno
if(!pFmt)
return;
if(rArray.getLength() != nRowCount)
- throw uno::RuntimeException("Row count mismatch", static_cast<cppu::OWeakObject*>(this));
+ throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rArray.getLength()), static_cast<cppu::OWeakObject*>(this));
auto vCells(getCells());
auto pCurrentCell(vCells.begin());
for(const auto& rColSeq : rArray)
{
if(rColSeq.getLength() != nColCount)
- throw uno::RuntimeException("Column count mismatch", static_cast<cppu::OWeakObject*>(this));
+ throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rColSeq.getLength()), static_cast<cppu::OWeakObject*>(this));
for(const auto& aValue : rColSeq)
{
auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
@@ -3706,16 +3706,16 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno:
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel)
{
- uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstRowAsLabel ? 1 : 0, m_bFirstColumnAsLabel ? 1 : 0,
- nRowCount, nColCount), uno::UNO_QUERY);
+ uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstColumnAsLabel ? 1 : 0, m_bFirstRowAsLabel ? 1 : 0,
+ nColCount-1, nRowCount-1), uno::UNO_QUERY);
return xDataRange->getData();
}
- uno::Sequence< uno::Sequence< double > > vRows(nColCount);
+ uno::Sequence< uno::Sequence< double > > vRows(nRowCount);
auto vCells(getCells());
auto pCurrentCell(vCells.begin());
for(auto& rRow : vRows)
{
- rRow = uno::Sequence<double>(nRowCount);
+ rRow = uno::Sequence<double>(nColCount);
for(auto& rValue : rRow)
{
rValue = (*pCurrentCell)->getValue();
@@ -3733,24 +3733,25 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData
const sal_uInt16 nColCount = getColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel)
+ {
+ uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstColumnAsLabel ? 1 : 0, m_bFirstRowAsLabel ? 1 : 0,
+ nColCount-1, nRowCount-1), uno::UNO_QUERY);
+ return xDataRange->setData(rData);
+ }
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
- 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)
+ if(rData.getLength() != nRowCount)
+ throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rData.getLength()), static_cast<cppu::OWeakObject*>(this));
+ auto vCells(getCells());
+ auto pCurrentCell(vCells.begin());
+ for(const auto& rRow : rData)
{
- const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart];
- 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();
- for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
+ if(rRow.getLength() != nColCount)
+ throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rRow.getLength()), static_cast<cppu::OWeakObject*>(this));
+ for(const auto& rValue : rRow)
{
- 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]);
+ uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_QUERY)->setValue(rValue);
+ ++pCurrentCell;
}
}
}
commit b845d236f530327610a6f69b0126c63693028e84
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 02:37:45 2015 +0200
use getCells()
Change-Id: I11ac9c87ac1d17b2ebc847e268d935c23f129ce1
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 7deff41..588ad25 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3704,25 +3704,25 @@ 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(m_bFirstRowAsLabel ? nRowCount - 1 : nRowCount);
- lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
- uno::Sequence<double>* pRowArray = aRowSeq.getArray();
- const sal_uInt16 nRowStart = m_bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; nRow++)
+ if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel)
{
- uno::Sequence<double> aColSeq(m_bFirstColumnAsLabel ? nColCount - 1 : nColCount);
- double* pArray = aColSeq.getArray();
- const sal_uInt16 nColStart = m_bFirstColumnAsLabel ? 1 : 0;
- for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
+ uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstRowAsLabel ? 1 : 0, m_bFirstColumnAsLabel ? 1 : 0,
+ nRowCount, nColCount), uno::UNO_QUERY);
+ return xDataRange->getData();
+ }
+ uno::Sequence< uno::Sequence< double > > vRows(nColCount);
+ auto vCells(getCells());
+ auto pCurrentCell(vCells.begin());
+ for(auto& rRow : vRows)
+ {
+ rRow = uno::Sequence<double>(nRowCount);
+ for(auto& rValue : rRow)
{
- uno::Reference<table::XCell> xCell = getCellByPosition(nCol, nRow);
- if(!xCell.is())
- throw uno::RuntimeException();
- pArray[nCol - nColStart] = xCell->getValue();
+ rValue = (*pCurrentCell)->getValue();
+ ++pCurrentCell;
}
- pRowArray[nRow - nRowStart] = aColSeq;
}
- return aRowSeq;
+ return vRows;
}
void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData)
commit d7b6b1dc1d21dd3925798954a59508a40a700cfd
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 02:05:45 2015 +0200
use getCells() here
Change-Id: Iff3997af302a6ddbfd21fb25cd7f0b94a9a107fe
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 18379c8..7deff41 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3639,28 +3639,25 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
const sal_uInt16 nColCount = getColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- SwFrmFmt* pFmt(GetFrmFmt());
+ lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
- if(!pFmt)
- throw uno::RuntimeException();
- sal_uInt16 nRow = 0;
+ auto vCells(getCells());
+ auto pCurrentCell(vCells.begin());
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;
+ auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
+ SwTableBox* pBox = pCell ? pCell->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));
+ rCellAny = bIsNum ? uno::makeAny(sw_getValue(*pCell)) : uno::makeAny(lcl_getString(*pCell));
+ ++pCurrentCell;
}
- ++nRow;
}
return aRowSeq;
}
commit e5796e0263ed00a7da06ea4351a58cedbfb88822
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 01:45:03 2015 +0200
SwxTextTable::setData can reuse XCellRange
Change-Id: Icf477e355feee338c063aee3c76ed7c5fee63591
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index e0f5e7e..18379c8 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -2310,52 +2310,14 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
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();
- if(pFmt )
- {
- bool bChanged = false;
-
- const sal_uInt16 nRowStart = m_bFirstRowAsLabel ? 1 : 0;
- if(rData.getLength() < nRowCount - nRowStart)
- {
- 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 = m_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]);
- bChanged=true;
- }
- }
- if ( bChanged )
- {
- lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
- }
- }
+ std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(m_pImpl->ThrowIfComplex(*this));
+ uno::Reference<chart::XChartDataArray> const xAllRange(
+ getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
+ uno::UNO_QUERY);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(m_bFirstRowAsLabel, m_bFirstColumnAsLabel);
+ xAllRange->setData(rData);
+ // this is rather inconsistent: setData on XTextTable sends events, but e.g. CellRanges do not
+ lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
}
uno::Sequence<OUString> SwXTextTable::getRowDescriptions(void)
commit 50ce85a860785bdd84dd9caa9aba9273c5613cf7
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 01:38:14 2015 +0200
allow CONVERT_TWIPS be only used when setting
Change-Id: I7021e975a75ca49ea6efbfcbaea3aeb94d693fac
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index f8a3847..e0f5e7e 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1784,7 +1784,7 @@ public:
void SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal);
bool GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny);
template<typename Tpoolitem>
- inline void AddItemToSet(SfxItemSet& rSet, std::function<Tpoolitem()> aItemFactory, sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember);
+ inline void AddItemToSet(SfxItemSet& rSet, std::function<Tpoolitem()> aItemFactory, sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips = false);
void ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc);
};
@@ -1802,7 +1802,7 @@ bool SwTableProperties_Impl::GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMember
{ return aAnyMap.FillValue( nWhichId, nMemberId, rpAny ); }
template<typename Tpoolitem>
-void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet, std::function<Tpoolitem()> aItemFactory, sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember)
+void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet, std::function<Tpoolitem()> aItemFactory, sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips)
{
std::list< std::pair<sal_uInt16, const uno::Any* > > vMemberAndAny;
for(sal_uInt16 nMember : vMember)
@@ -1816,7 +1816,7 @@ void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet, std::function<Tpooli
{
Tpoolitem aItem = aItemFactory();
for(auto& aMemberAndAny : vMemberAndAny)
- aItem.PutValue(*aMemberAndAny.second, aMemberAndAny.first);
+ aItem.PutValue(*aMemberAndAny.second, aMemberAndAny.first | (bAddTwips ? CONVERT_TWIPS : 0) );
rSet.Put(aItem);
}
}
@@ -1874,22 +1874,9 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc)
if(bPutBreak)
AddItemToSet<SvxFmtBreakItem>(aSet, [&rFrmFmt]() { return rFrmFmt.GetBreak(); }, RES_BREAK, {0});
- const uno::Any* pShadow;
- if(GetProperty(RES_SHADOW, 0, pShadow))
- {
- SvxShadowItem aShd(rFrmFmt.GetShadow());
- aShd.PutValue(*pShadow, CONVERT_TWIPS); // putting to CONVERT_TWIPS, but getting from 0?
- aSet.Put(aShd);
- }
+ AddItemToSet<SvxShadowItem>(aSet, [&rFrmFmt]() { return rFrmFmt.GetShadow(); }, RES_SHADOW, {0}, true);
AddItemToSet<SvxFmtKeepItem>(aSet, [&rFrmFmt]() { return rFrmFmt.GetKeep(); }, RES_KEEP, {0});
-
- const uno::Any* pHOrient;
- if(GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_ORIENT, pHOrient))
- {
- SwFmtHoriOrient aOrient(rFrmFmt.GetHoriOrient());
- aOrient.PutValue(*pHOrient, MID_HORIORIENT_ORIENT|CONVERT_TWIPS);
- aSet.Put(aOrient);
- }
+ AddItemToSet<SwFmtHoriOrient>(aSet, [&rFrmFmt]() { return rFrmFmt.GetHoriOrient(); }, RES_HORI_ORIENT, {MID_HORIORIENT_ORIENT}, true);
const uno::Any* pSzRel(nullptr);
GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel);
commit 27972b53a5695ffba720d377d15b0bde60dd79f9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 01:18:24 2015 +0200
simplify
Change-Id: I18670621a218f77b7996c3b7418fde4c4a230059
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index eb5a0f8..f8a3847 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3717,66 +3717,36 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
}
///@see SwXCellRange::setData
-void SAL_CALL SwXCellRange::setDataArray(
- const uno::Sequence< uno::Sequence< uno::Any > >& rArray )
- throw (uno::RuntimeException, std::exception)
+void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray) 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;
- }
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
SwFrmFmt* pFmt = GetFrmFmt();
- if(pFmt )
+ if(!pFmt)
+ return;
+ if(rArray.getLength() != nRowCount)
+ throw uno::RuntimeException("Row count mismatch", static_cast<cppu::OWeakObject*>(this));
+ auto vCells(getCells());
+ auto pCurrentCell(vCells.begin());
+ for(const auto& rColSeq : rArray)
{
- if(rArray.getLength() != nRowCount)
+ if(rColSeq.getLength() != nColCount)
+ throw uno::RuntimeException("Column count mismatch", static_cast<cppu::OWeakObject*>(this));
+ for(const auto& aValue : rColSeq)
{
- 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,
- 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
- {
- 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 );
- }
- }
- }
+ auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
+ if(!pCell || !pCell->GetTblBox())
+ throw uno::RuntimeException("Box for cell missing", static_cast<cppu::OWeakObject*>(this));
+ if(aValue.isExtractableTo(cppu::UnoType<OUString>::get()))
+ sw_setString(*pCell, aValue.get<OUString>());
+ else if(aValue.isExtractableTo(cppu::UnoType<double>::get()))
+ sw_setValue(*pCell, aValue.get<double>());
+ else
+ sw_setString(*pCell, OUString(), true);
+ ++pCurrentCell;
}
}
}
commit ff1c479dba6210a885a4bd561a2f4c29ec0ee99e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 00:20:20 2015 +0200
simplify exception
Change-Id: I98e9ee171bf2b207696be7db90ff3e3ce83b06ed
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 1e8b33e..eb5a0f8 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1057,11 +1057,7 @@ uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName)
return uno::Any();
auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
if(!pEntry)
- {
- beans::UnknownPropertyException aEx;
- aEx.Message = rPropertyName;
- throw(aEx);
- }
+ throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
switch(pEntry->nWID)
{
case FN_UNO_CELL_ROW_SPAN:
commit 4b7f140a0436a3ff5301786565e8e205f07e2528
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Apr 11 00:14:11 2015 +0200
use copy_n to simplify
Change-Id: Ia5b8b01ecabbf8c7afe4e75c7245e734c23545ce
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 6649d3b..1e8b33e 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -802,22 +802,14 @@ sal_Int64 SAL_CALL SwXCell::getSomething( const uno::Sequence< sal_Int8 >& rId )
uno::Sequence< uno::Type > SAL_CALL SwXCell::getTypes( ) throw(uno::RuntimeException, std::exception)
{
static uno::Sequence< uno::Type > aRetTypes;
- if(!aRetTypes.getLength())
- {
- aRetTypes = SwXCellBaseClass::getTypes();
- uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
-
- long nIndex = aRetTypes.getLength();
- aRetTypes.realloc(
- aRetTypes.getLength() +
- aTextTypes.getLength());
- uno::Type* pRetTypes = aRetTypes.getArray();
-
- const uno::Type* pTextTypes = aTextTypes.getConstArray();
- for(long nPos = 0; nPos <aTextTypes.getLength(); nPos++)
- pRetTypes[nIndex++] = pTextTypes[nPos];
- }
+ if(aRetTypes.getLength())
+ return aRetTypes;
+ const auto& rCellTypes = SwXCellBaseClass::getTypes();
+ const auto& rTextTypes = SwXText::getTypes();
+ aRetTypes = uno::Sequence<uno::Type>(rCellTypes.getLength() + rTextTypes.getLength());
+ std::copy_n(rCellTypes.begin(), rCellTypes.getLength(), aRetTypes.begin());
+ std::copy_n(rTextTypes.begin(), rTextTypes.getLength(), aRetTypes.begin()+rCellTypes.getLength());
return aRetTypes;
}
commit d6831689e5eb165589cd6bcfcc359f181c1ee903
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Apr 10 23:56:21 2015 +0200
use some more nullptr
Change-Id: I7a4214e63cf2fbf34cf5235d1e8b1c50431ecdb1
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 6e6024b..6649d3b 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -757,7 +757,7 @@ SwXCell::SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBx, size_t const nPos) :
SwClient(pTblFmt),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
pBox(pBx),
- pStartNode(0),
+ pStartNode(nullptr),
nFndPos(nPos)
{
}
@@ -766,7 +766,7 @@ SwXCell::SwXCell(SwFrmFmt* pTblFmt, const SwStartNode& rStartNode) :
SwXText(pTblFmt->GetDoc(), CURSOR_TBLTEXT),
SwClient(pTblFmt),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
- pBox(0),
+ pBox(nullptr),
pStartNode(&rStartNode),
nFndPos(NOTFOUND)
{
commit f1d40d4f0d17aea4d8cce1fa9dd0de8c998e3a72
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Apr 10 23:47:53 2015 +0200
simplify
Change-Id: I1de47afface7d221f7df43ae4e0bfa7d1cb4f4ce
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 2b8b16e..6e6024b 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -663,31 +663,23 @@ static void lcl_SetTblSeparators(const uno::Any& rVal, SwTable* pTable, SwTableB
const uno::Sequence< text::TableColumnSeparator>* pSepSeq =
static_cast<uno::Sequence< text::TableColumnSeparator> const *>(rVal.getValue());
- if(pSepSeq && static_cast<size_t>(pSepSeq->getLength()) == nOldCount)
+ if(!pSepSeq || static_cast<size_t>(pSepSeq->getLength()) != nOldCount)
+ return;
+ SwTabCols aCols(aOldCols);
+ const text::TableColumnSeparator* pArray = pSepSeq->getConstArray();
+ long nLastValue = 0;
+ //sal_Int32 nTblWidth = aCols.GetRight() - aCols.GetLeft();
+ for(size_t i = 0; i < nOldCount; ++i)
{
- SwTabCols aCols(aOldCols);
- bool bError = false;
- const text::TableColumnSeparator* pArray = pSepSeq->getConstArray();
- long nLastValue = 0;
- //sal_Int32 nTblWidth = aCols.GetRight() - aCols.GetLeft();
- for(size_t i = 0; i < nOldCount; ++i)
- {
- aCols[i] = pArray[i].Position;
- if(pArray[i].IsVisible == (aCols.IsHidden(i) ? 1 : 0) ||
+ aCols[i] = pArray[i].Position;
+ if(pArray[i].IsVisible == (aCols.IsHidden(i) ? 1 : 0) ||
(!bRow && aCols.IsHidden(i)) ||
aCols[i] < nLastValue ||
UNO_TABLE_COLUMN_SUM < aCols[i] )
- {
- bError = true;
- break;
- }
- nLastValue = aCols[i];
- }
- if(!bError)
- {
- pDoc->SetTabCols(*pTable, aCols, aOldCols, pBox, bRow );
- }
+ return; // probably this should assert()
+ nLastValue = aCols[i];
}
+ pDoc->SetTabCols(*pTable, aCols, aOldCols, pBox, bRow );
}
static inline OUString lcl_getString( SwXCell &rCell )
commit e51e63e9e712472f367efa3bea0f2389ef349b43
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Apr 10 23:30:10 2015 +0200
simplify
Change-Id: Icd65860188686b153e3c5b367f305155d9762ff9
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index e788d0f..2b8b16e 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -564,15 +564,12 @@ void SwRangeDescriptor::Normalize()
static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRow)
{
- SwXCell* pXCell = nullptr;
const OUString sCellName = sw_GetCellName(nColumn, nRow);
SwTable* pTable = SwTable::FindTable(pFmt);
- SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox( sCellName ));
- if(pBox)
- {
- pXCell = SwXCell::CreateXCell(pFmt, pBox, pTable);
- }
- return pXCell;
+ SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox(sCellName));
+ if(!pBox)
+ return nullptr;
+ return SwXCell::CreateXCell(pFmt, pBox, pTable);
}
static void lcl_InspectLines(SwTableLines& rLines, std::vector<OUString>& rAllNames)
commit 31a3112834f3f9c9bc86234ec4fcdfae912b3fbc
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Apr 10 23:26:54 2015 +0200
usw std::swap
Change-Id: I4305e644e65d82d775e3d36b4fa3ad9ca6bc82ae
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 9cc1425..e788d0f 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -557,17 +557,9 @@ void sw_NormalizeRange(OUString &rCell1, OUString &rCell2)
void SwRangeDescriptor::Normalize()
{
if (nTop > nBottom)
- {
- sal_Int32 nTmp = nTop;
- nTop = nBottom;
- nBottom = nTmp;
- }
+ std::swap(nBottom, nTop);
if (nLeft > nRight)
- {
- sal_Int32 nTmp = nLeft;
- nLeft = nRight;
- nRight = nTmp;
- }
+ std::swap(nLeft, nRight);
}
static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRow)
commit 6fa48a73b342d95db52f38b1514c3a1ac00cba31
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Apr 10 23:17:18 2015 +0200
refactor
Change-Id: I97f5e21e94fbe551744f935ccd28683c7f11ea4d
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index ef02a4d..9cc1425 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -357,42 +357,43 @@ void sw_GetCellPosition(const OUString &rCellName,
{
rColumn = rRow = -1; // default return values indicating failure
const sal_Int32 nLen = rCellName.getLength();
- if (nLen)
+ if(!nLen)
{
- sal_Int32 nRowPos = 0;
- while (nRowPos<nLen)
+ SAL_WARN("sw.uno", "failed to get column or row index");
+ return;
+ }
+ sal_Int32 nRowPos = 0;
+ while (nRowPos<nLen)
+ {
+ if (rCellName[nRowPos]>='0' && rCellName[nRowPos]<='9')
{
- if (rCellName[nRowPos]>='0' && rCellName[nRowPos]<='9')
- {
- break;
- }
- ++nRowPos;
+ break;
}
- if (nRowPos>0 && nRowPos<nLen)
+ ++nRowPos;
+ }
+ if (nRowPos>0 && nRowPos<nLen)
+ {
+ sal_Int32 nColIdx = 0;
+ for (sal_Int32 i = 0; i < nRowPos; ++i)
{
- sal_Int32 nColIdx = 0;
- for (sal_Int32 i = 0; i < nRowPos; ++i)
+ nColIdx *= 52;
+ if (i < nRowPos - 1)
+ ++nColIdx;
+ const sal_Unicode cChar = rCellName[i];
+ if ('A' <= cChar && cChar <= 'Z')
+ nColIdx += cChar - 'A';
+ else if ('a' <= cChar && cChar <= 'z')
+ nColIdx += 26 + cChar - 'a';
+ else
{
- nColIdx *= 52;
- if (i < nRowPos - 1)
- ++nColIdx;
- const sal_Unicode cChar = rCellName[i];
- if ('A' <= cChar && cChar <= 'Z')
- nColIdx += cChar - 'A';
- else if ('a' <= cChar && cChar <= 'z')
- nColIdx += 26 + cChar - 'a';
- else
- {
- nColIdx = -1; // sth failed
- break;
- }
+ nColIdx = -1; // sth failed
+ break;
}
-
- rColumn = nColIdx;
- rRow = rCellName.copy(nRowPos).toInt32() - 1; // - 1 because indices ought to be 0 based
}
+
+ rColumn = nColIdx;
+ rRow = rCellName.copy(nRowPos).toInt32() - 1; // - 1 because indices ought to be 0 based
}
- OSL_ENSURE( rColumn >= 0 && rRow >= 0, "failed to get column or row index" );
}
/** compare position of two cells (check rows first)
@@ -512,28 +513,24 @@ OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow )
*/
const SwTableBox* lcl_FindCornerTableBox(const SwTableLines& rTableLines, const bool i_bTopLeft)
{
- bool bFirst = true;
- const SwTableBox* pBox = 0;
- do
+ const SwTableLines* pLines(&rTableLines);
+ while(true)
{
- const SwTableLines& rLines(bFirst ? rTableLines : pBox->GetTabLines());
- bFirst = false;
- assert(rLines.size() != 0);
- if (!rLines.empty())
- {
- const SwTableLine* pLine(i_bTopLeft ? rLines.front() : rLines.back());
- assert(pLine);
- const SwTableBoxes& rBoxes(pLine->GetTabBoxes());
- assert(rBoxes.size() != 0);
- pBox = i_bTopLeft ? rBoxes.front() : rBoxes.back();
- assert(pBox);
- }
- else
- {
- pBox = 0;
- }
- } while (pBox && !pBox->GetSttNd());
- return pBox;
+ assert(!pLines->empty());
+ if(pLines->empty())
+ return nullptr;
+ const SwTableLine* pLine(i_bTopLeft ? pLines->front() : pLines->back());
+ assert(pLine);
+ const SwTableBoxes& rBoxes(pLine->GetTabBoxes());
+ assert(rBoxes.size() != 0);
+ const SwTableBox* pBox = i_bTopLeft ? rBoxes.front() : rBoxes.back();
+ assert(pBox);
+ if(!pBox)
+ return nullptr;
+ if(pBox->GetSttNd())
+ return pBox;
+ pLines = &pBox->GetTabLines();
+ }
}
/** cleanup order in a range
commit 7e9bff63166189f78582356f428405c391f766f9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Apr 10 21:42:45 2015 +0200
simplify
Change-Id: I1effcb591bb60f3b77f7d0875353896f6ffbf984
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 9d4570d..ef02a4d 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -259,7 +259,6 @@ static void lcl_SetSpecialProperty(SwFrmFmt* pFmt,
static uno::Any lcl_GetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimpleEntry* pEntry )
{
- uno::Any aRet;
switch(pEntry->nWID)
{
case FN_TABLE_HEADLINE_REPEAT:
@@ -268,69 +267,52 @@ static uno::Any lcl_GetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimp
SwTable* pTable = SwTable::FindTable( pFmt );
const sal_uInt16 nRepeat = pTable->GetRowsToRepeat();
if(pEntry->nWID == FN_TABLE_HEADLINE_REPEAT)
- {
- aRet <<= nRepeat > 0;
- }
- else
- aRet <<= (sal_Int32)nRepeat;
+ return uno::makeAny<bool>(nRepeat > 0);
+ return uno::makeAny<sal_Int32>(nRepeat);
}
- break;
case FN_TABLE_WIDTH:
case FN_TABLE_IS_RELATIVE_WIDTH:
case FN_TABLE_RELATIVE_WIDTH:
{
+ uno::Any aRet;
const SwFmtFrmSize& rSz = pFmt->GetFrmSize();
if(FN_TABLE_WIDTH == pEntry->nWID)
rSz.QueryValue(aRet, MID_FRMSIZE_WIDTH|CONVERT_TWIPS);
else if(FN_TABLE_RELATIVE_WIDTH == pEntry->nWID)
rSz.QueryValue(aRet, MID_FRMSIZE_REL_WIDTH);
else
- {
- aRet <<= 0 != rSz.GetWidthPercent();
- }
+ aRet = uno::makeAny<bool>(0 != rSz.GetWidthPercent());
+ return aRet;
}
- break;
case RES_PAGEDESC:
{
const SfxItemSet& rSet = pFmt->GetAttrSet();
const SfxPoolItem* pItem;
- OUString sPDesc;
if(SfxItemState::SET == rSet.GetItemState(RES_PAGEDESC, false, &pItem))
{
const SwPageDesc* pDsc = static_cast<const SwFmtPageDesc*>(pItem)->GetPageDesc();
if(pDsc)
- {
- sPDesc = SwStyleNameMapper::GetProgName(pDsc->GetName(), nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
- }
+ return uno::makeAny<OUString>(SwStyleNameMapper::GetProgName(pDsc->GetName(), nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC ));
}
- aRet <<= sPDesc;
+ return uno::makeAny(OUString());
}
- break;
- case RES_ANCHOR :
- aRet <<= text::TextContentAnchorType_AT_PARAGRAPH;
- break;
+ case RES_ANCHOR:
+ return uno::makeAny(text::TextContentAnchorType_AT_PARAGRAPH);
- case FN_UNO_ANCHOR_TYPES :
+ case FN_UNO_ANCHOR_TYPES:
{
- uno::Sequence<text::TextContentAnchorType> aTypes(1);
- text::TextContentAnchorType* pArray = aTypes.getArray();
- pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
- aRet <<= aTypes;
+ uno::Sequence<text::TextContentAnchorType> aTypes{text::TextContentAnchorType_AT_PARAGRAPH};
+ return uno::makeAny(aTypes);
}
- break;
case FN_UNO_WRAP :
- {
- aRet <<= text::WrapTextMode_NONE;
- }
- break;
+ return uno::makeAny(text::WrapTextMode_NONE);
case FN_PARAM_LINK_DISPLAY_NAME :
- aRet <<= pFmt->GetName();
- break;
+ return uno::makeAny(pFmt->GetName());
case FN_UNO_REDLINE_NODE_START:
case FN_UNO_REDLINE_NODE_END:
@@ -339,10 +321,8 @@ static uno::Any lcl_GetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimp
SwNode* pTblNode = pTable->GetTableNode();
if(FN_UNO_REDLINE_NODE_END == pEntry->nWID)
pTblNode = pTblNode->EndOfSectionNode();
- const SwRedlineTbl& rRedTbl = pFmt->GetDoc()->getIDocumentRedlineAccess().GetRedlineTbl();
- for(size_t nRed = 0; nRed < rRedTbl.size(); ++nRed)
+ for(const SwRangeRedline* pRedline : pFmt->GetDoc()->getIDocumentRedlineAccess().GetRedlineTbl())
{
- const SwRangeRedline* pRedline = rRedTbl[nRed];
const SwNode& rRedPointNode = pRedline->GetNode(true);
const SwNode& rRedMarkNode = pRedline->GetNode(false);
if(&rRedPointNode == pTblNode || &rRedMarkNode == pTblNode)
@@ -350,14 +330,12 @@ static uno::Any lcl_GetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimp
const SwNode& rStartOfRedline = SwNodeIndex(rRedPointNode) <= SwNodeIndex(rRedMarkNode) ?
rRedPointNode : rRedMarkNode;
bool bIsStart = &rStartOfRedline == pTblNode;
- aRet <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart);
- break;
+ return uno::makeAny(SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart));
}
}
}
- break;
}
- return aRet;
+ return uno::Any();
}
/** get position of a cell with a given name
commit 9f3aaa5c8cff4b4991272e1b71666428985d74e6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Apr 2 18:40:51 2015 +0200
simplify
Change-Id: I1b1f9d544e00e7900232ff9416a99fc0c5faa4e5
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 578556a..9d4570d 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1088,24 +1088,16 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV
{
auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
if(!pEntry)
- {
- beans::UnknownPropertyException aEx;
- aEx.Message = rPropertyName;
- throw(aEx);
- }
- if(pEntry->nWID == FN_UNO_CELL_ROW_SPAN)
- {
- sal_Int32 nRowSpan = 0;
- if(aValue >>= nRowSpan)
- pBox->setRowSpan(nRowSpan);
- }
- else
+ throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
+ if(pEntry->nWID != FN_UNO_CELL_ROW_SPAN)
{
SwFrmFmt* pBoxFmt = pBox->ClaimFrmFmt();
SwAttrSet aSet(pBoxFmt->GetAttrSet());
m_pPropSet->setPropertyValue(rPropertyName, aValue, aSet);
pBoxFmt->GetDoc()->SetAttr(aSet, *pBoxFmt);
}
+ else if(aValue.isExtractableTo(cppu::UnoType<sal_Int32>::get()))
+ pBox->setRowSpan(aValue.get<sal_Int32>());
}
}
commit b137dfceac0740c7650b37a5a0b8935b23151114
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Apr 2 18:29:35 2015 +0200
simplify
Change-Id: Ib77efe1ee17afdbf058af4f1d360ef2dee658278
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 59a4428..578556a 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -18,6 +18,7 @@
*/
#include <list>
+#include <array>
#include <utility>
#include <vector>
#include <algorithm>
@@ -1061,21 +1062,12 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV
if(rPropertyName == "FRMDirection")
{
SvxFrameDirection eDir = FRMDIR_ENVIRONMENT;
- sal_Int32 nNum = aValue.get<sal_Int32>();
- SAL_INFO("sw.uno", "FRMDirection val " << nNum);
- switch (nNum)
+ try
{
- case 0:
- eDir = FRMDIR_HORI_LEFT_TOP;
- break;
- case 1:
- eDir = FRMDIR_HORI_RIGHT_TOP;
- break;
- case 2:
- eDir = FRMDIR_VERT_TOP_RIGHT;
- break;
- default:
- OSL_FAIL("unknown direction code, maybe it's a bitfield");
+ const std::array<SvxFrameDirection, 3> vDirs = { FRMDIR_HORI_LEFT_TOP, FRMDIR_HORI_RIGHT_TOP, FRMDIR_VERT_TOP_RIGHT };
+ eDir = vDirs.at(aValue.get<sal_Int32>());
+ } catch(std::out_of_range) {
+ SAL_WARN("sw.uno", "unknown direction code, maybe it's a bitfield");
}
SvxFrameDirectionItem aItem(eDir, RES_FRAMEDIR);
pBox->GetFrmFmt()->SetFmtAttr(aItem);
More information about the Libreoffice-commits
mailing list