Kaydet (Commit) 13260171 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

also kill SwIterator here for a Notify call

Change-Id: Ic8e8a581bb38bf064117f74aab7362da318e21c4
üst 95f2ba75
......@@ -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
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment