summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-28 05:52:28 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-28 22:14:21 +0100
commit132601712ca3922c02b64cef6ea382120dd4511f (patch)
tree8e66350f7c6791e9124788860175c71f1e8ed3af
parent95f2ba75cb07462e4a53f39795a72cfdaaf36452 (diff)
also kill SwIterator here for a Notify call
Change-Id: Ic8e8a581bb38bf064117f74aab7362da318e21c4
-rw-r--r--sw/inc/unotbl.hxx12
-rw-r--r--sw/source/core/unocore/unotbl.cxx66
2 files changed, 45 insertions, 33 deletions
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index bb2c593a272a..cc4b39d1b367 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -157,7 +157,7 @@ public:
SwFrmFmt* GetFrmFmt() const { return const_cast<SwFrmFmt*>(static_cast<const SwFrmFmt*>(GetRegisteredIn())); }
};
-class SwXTextTableRow : public cppu::WeakImplHelper2
+class SwXTextTableRow SAL_FINAL : public cppu::WeakImplHelper2
<
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceInfo
@@ -172,7 +172,8 @@ class SwXTextTableRow : public cppu::WeakImplHelper2
protected:
virtual ~SwXTextTableRow();
//SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
public:
SwXTextTableRow(SwFrmFmt* pFmt, SwTableLine* pLine);
@@ -549,7 +550,7 @@ public:
};
-class SwXTableRows : public cppu::WeakImplHelper2
+class SwXTableRows SAL_FINAL : public cppu::WeakImplHelper2
<
::com::sun::star::table::XTableRows,
::com::sun::star::lang::XServiceInfo
@@ -557,7 +558,8 @@ class SwXTableRows : public cppu::WeakImplHelper2
public SwClient
{
- SwFrmFmt* GetFrmFmt() const { return const_cast<SwFrmFmt*>(static_cast<const SwFrmFmt*>(GetRegisteredIn())); }
+ SwFrmFmt* GetFrmFmt() { return static_cast<SwFrmFmt*>(GetRegisteredIn()); }
+ const SwFrmFmt* GetFrmFmt() const { return const_cast<SwXTableRows*>(this)->GetFrmFmt(); }
protected:
virtual ~SwXTableRows();
public:
@@ -587,7 +589,7 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
//SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
};
class SwXTableColumns : public cppu::WeakImplHelper2
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 08941e41f9c2..253cf8aed2ec 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -104,6 +104,24 @@
using namespace ::com::sun::star;
using ::editeng::SvxBorderLine;
+namespace
+{
+ struct FindXCellHint SAL_FINAL : SfxHint
+ {
+ FindXCellHint(SwTableBox* pTableBox) : m_pTableBox(pTableBox), m_pCell(nullptr) {};
+ void SetCell(SwXCell* pCell) const { m_pCell = pCell; };
+ const SwTableBox* const m_pTableBox;
+ mutable SwXCell* m_pCell;
+ };
+ struct FindXRowHint SAL_FINAL : SfxHint
+ {
+ FindXRowHint(SwTableLine* pTableLine) : m_pTableLine(pTableLine), m_pRow(nullptr) {};
+ void SetRow(SwXTextTableRow* pRow) const { m_pRow = pRow; };
+ const SwTableLine* const m_pTableLine;
+ mutable SwXTextTableRow* m_pRow;
+ };
+}
+
#define UNO_TABLE_COLUMN_SUM 10000
static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
@@ -1244,22 +1262,11 @@ void SwXCell::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
ClientModify(this, pOld, pNew);
}
-namespace sw
-{
- struct FindXCellHint SAL_FINAL : SfxHint
- {
- FindXCellHint(SwTableBox* pTableBox) : m_pTableBox(pTableBox), m_pCell(nullptr) {};
- void SetCell(SwXCell* pCell) const { m_pCell = pCell; };
- const SwTableBox* const m_pTableBox;
- mutable SwXCell* m_pCell;
- };
-}
-
void SwXCell::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
- if(typeid(sw::FindXCellHint) == typeid(rHint))
+ if(typeid(FindXCellHint) == typeid(rHint))
{
- auto* pFindHint(static_cast<const sw::FindXCellHint*>(&rHint));
+ auto* pFindHint(static_cast<const FindXCellHint*>(&rHint));
if(!pFindHint->m_pCell && pFindHint->m_pTableBox == GetTblBox())
pFindHint->m_pCell = this;
}
@@ -1277,7 +1284,7 @@ SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTab
if(it == pTable->GetTabSortBoxes().end())
return nullptr;
size_t const nPos = it - pTable->GetTabSortBoxes().begin();
- sw::FindXCellHint aHint{pBox};
+ FindXCellHint aHint{pBox};
pTblFmt->CallSwClientNotify(aHint);
return aHint.m_pCell ? aHint.m_pCell : new SwXCell(pTblFmt, pBox, nPos);
}
@@ -1525,6 +1532,18 @@ void SwXTextTableRow::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
ClientModify(this, pOld, pNew);
}
+void SwXTextTableRow::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ if(typeid(FindXRowHint) == typeid(rHint))
+ {
+ auto* pFindHint(static_cast<const FindXRowHint*>(&rHint));
+ if(!pFindHint->m_pRow && pFindHint->m_pTableLine == GetTblRow())
+ pFindHint->m_pRow = this;
+ }
+ else
+ SwClient::SwClientNotify(rModify, rHint);
+}
+
SwTableLine* SwXTextTableRow::FindLine(SwTable* pTable, SwTableLine* pLine)
{
SwTableLine* pRet = 0;
@@ -4761,20 +4780,11 @@ uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex)
if(static_cast<size_t>(nIndex) >= pTable->GetTabLines().size())
throw lang::IndexOutOfBoundsException();
SwTableLine* pLine = pTable->GetTabLines()[nIndex];
- SwIterator<SwXTextTableRow,SwFmt> aIter( *pFrmFmt );
- SwXTextTableRow* pXRow = aIter.First();
- while( pXRow )
- {
- // is there already a proper cell?
- if(pXRow->GetTblRow() == pLine)
- break;
- pXRow = aIter.Next();
- }
- // otherwise create it
- if(!pXRow)
- pXRow = new SwXTextTableRow(pFrmFmt, pLine);
- uno::Reference< beans::XPropertySet > xRet =
- (beans::XPropertySet*)pXRow;
+ FindXRowHint aHint{pLine};
+ pFrmFmt->CallSwClientNotify(aHint);
+ if(!aHint.m_pRow)
+ aHint.m_pRow = new SwXTextTableRow(pFrmFmt, pLine);
+ uno::Reference<beans::XPropertySet> xRet = (beans::XPropertySet*)aHint.m_pRow;
return uno::makeAny(xRet);
}