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: ...@@ -157,7 +157,7 @@ public:
SwFrmFmt* GetFrmFmt() const { return const_cast<SwFrmFmt*>(static_cast<const SwFrmFmt*>(GetRegisteredIn())); } 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::beans::XPropertySet,
::com::sun::star::lang::XServiceInfo ::com::sun::star::lang::XServiceInfo
...@@ -172,7 +172,8 @@ class SwXTextTableRow : public cppu::WeakImplHelper2 ...@@ -172,7 +172,8 @@ class SwXTextTableRow : public cppu::WeakImplHelper2
protected: protected:
virtual ~SwXTextTableRow(); virtual ~SwXTextTableRow();
//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:
SwXTextTableRow(SwFrmFmt* pFmt, SwTableLine* pLine); SwXTextTableRow(SwFrmFmt* pFmt, SwTableLine* pLine);
...@@ -549,7 +550,7 @@ public: ...@@ -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::table::XTableRows,
::com::sun::star::lang::XServiceInfo ::com::sun::star::lang::XServiceInfo
...@@ -557,7 +558,8 @@ class SwXTableRows : public cppu::WeakImplHelper2 ...@@ -557,7 +558,8 @@ class SwXTableRows : public cppu::WeakImplHelper2
public SwClient 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: protected:
virtual ~SwXTableRows(); virtual ~SwXTableRows();
public: public:
...@@ -587,7 +589,7 @@ 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; virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
//SwClient //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 class SwXTableColumns : public cppu::WeakImplHelper2
......
...@@ -104,6 +104,24 @@ ...@@ -104,6 +104,24 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
using ::editeng::SvxBorderLine; 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 #define UNO_TABLE_COLUMN_SUM 10000
static void lcl_SendChartEvent(::cppu::OWeakObject & rSource, static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
...@@ -1244,22 +1262,11 @@ void SwXCell::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) ...@@ -1244,22 +1262,11 @@ 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) 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()) if(!pFindHint->m_pCell && pFindHint->m_pTableBox == GetTblBox())
pFindHint->m_pCell = this; pFindHint->m_pCell = this;
} }
...@@ -1277,7 +1284,7 @@ SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTab ...@@ -1277,7 +1284,7 @@ SwXCell* SwXCell::CreateXCell(SwFrmFmt* pTblFmt, SwTableBox* pBox, SwTable *pTab
if(it == pTable->GetTabSortBoxes().end()) if(it == pTable->GetTabSortBoxes().end())
return nullptr; return nullptr;
size_t const nPos = it - pTable->GetTabSortBoxes().begin(); size_t const nPos = it - pTable->GetTabSortBoxes().begin();
sw::FindXCellHint aHint{pBox}; FindXCellHint aHint{pBox};
pTblFmt->CallSwClientNotify(aHint); pTblFmt->CallSwClientNotify(aHint);
return aHint.m_pCell ? aHint.m_pCell : new SwXCell(pTblFmt, pBox, nPos); 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) ...@@ -1525,6 +1532,18 @@ void SwXTextTableRow::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
ClientModify(this, pOld, 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* SwXTextTableRow::FindLine(SwTable* pTable, SwTableLine* pLine)
{ {
SwTableLine* pRet = 0; SwTableLine* pRet = 0;
...@@ -4761,20 +4780,11 @@ uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex) ...@@ -4761,20 +4780,11 @@ uno::Any SwXTableRows::getByIndex(sal_Int32 nIndex)
if(static_cast<size_t>(nIndex) >= pTable->GetTabLines().size()) if(static_cast<size_t>(nIndex) >= pTable->GetTabLines().size())
throw lang::IndexOutOfBoundsException(); throw lang::IndexOutOfBoundsException();
SwTableLine* pLine = pTable->GetTabLines()[nIndex]; SwTableLine* pLine = pTable->GetTabLines()[nIndex];
SwIterator<SwXTextTableRow,SwFmt> aIter( *pFrmFmt ); FindXRowHint aHint{pLine};
SwXTextTableRow* pXRow = aIter.First(); pFrmFmt->CallSwClientNotify(aHint);
while( pXRow ) if(!aHint.m_pRow)
{ aHint.m_pRow = new SwXTextTableRow(pFrmFmt, pLine);
// is there already a proper cell? uno::Reference<beans::XPropertySet> xRet = (beans::XPropertySet*)aHint.m_pRow;
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;
return uno::makeAny(xRet); 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