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

use Notify instead of SwIterator<>

Change-Id: Id9e0bcaf2e961e2d797e4c180aa782cb0e418bcf
üst f6bc8126
...@@ -64,7 +64,7 @@ cppu::WeakImplHelper4 ...@@ -64,7 +64,7 @@ cppu::WeakImplHelper4
::com::sun::star::container::XEnumerationAccess ::com::sun::star::container::XEnumerationAccess
> >
SwXCellBaseClass; SwXCellBaseClass;
class SwXCell : public SwXCellBaseClass, class SwXCell SAL_FINAL : public SwXCellBaseClass,
public SwXText, public SwXText,
public SwClient public SwClient
{ {
...@@ -94,7 +94,8 @@ protected: ...@@ -94,7 +94,8 @@ protected:
virtual ~SwXCell(); virtual ~SwXCell();
//SwClient //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: public:
SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, size_t nPos = NOTFOUND); SwXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, size_t nPos = NOTFOUND);
......
...@@ -1244,26 +1244,42 @@ void SwXCell::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ...@@ -1244,26 +1244,42 @@ void SwXCell::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
ClientModify(this, pOld, 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))
{
auto* pFindHint(static_cast<const sw::FindXCellHint*>(&rHint));
if(!pFindHint->m_pCell && pFindHint->m_pTableBox == GetTblBox())
pFindHint->m_pCell = this;
}
else
SwClient::SwClientNotify(rModify, rHint);
}
SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTable ) SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTable )
{ {
if(!pTblFmt || !pBox) if(!pTblFmt || !pBox)
return nullptr; return nullptr;
if( !pTable ) if(!pTable)
pTable = SwTable::FindTable( pTblFmt ); pTable = SwTable::FindTable(pTblFmt);
SwTableSortBoxes::const_iterator it = pTable->GetTabSortBoxes().find( pBox ); SwTableSortBoxes::const_iterator it = pTable->GetTabSortBoxes().find(pBox);
if( it == pTable->GetTabSortBoxes().end() ) if(it == pTable->GetTabSortBoxes().end())
return nullptr; return nullptr;
// if the box exists, then return a cell
SwIterator<SwXCell,SwFmt> aIter( *pTblFmt );
for(SwXCell* pXCell = aIter.First(); pXCell; pXCell = aIter.Next())
{
// is there already a proper cell?
if(pXCell->GetTblBox() == pBox)
return pXCell;
}
// otherwise create it
size_t const nPos = it - pTable->GetTabSortBoxes().begin(); size_t const nPos = it - pTable->GetTabSortBoxes().begin();
return new SwXCell(pTblFmt, pBox, nPos); sw::FindXCellHint aHint{pBox};
pTblFmt->CallSwClientNotify(aHint);
return aHint.m_pCell ? aHint.m_pCell : new SwXCell(pTblFmt, pBox, nPos);
} }
/** search if a box exists in a table /** search if a box exists in a table
......
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