[Libreoffice-commits] core.git: 6 commits - sw/inc sw/source
Michael Stahl
mstahl at redhat.com
Fri Feb 5 13:44:45 UTC 2016
sw/inc/unotbl.hxx | 81 +---
sw/source/core/unocore/unochart.cxx | 2
sw/source/core/unocore/unotbl.cxx | 644 ++++++++++++++++++++++--------------
sw/source/filter/xml/xmltble.cxx | 4
sw/source/filter/xml/xmltbli.cxx | 4
5 files changed, 425 insertions(+), 310 deletions(-)
New commits:
commit b31de9cde52f940af0d2c563163de98ded20a9a8
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Feb 5 14:00:30 2016 +0100
sw: move all SwXTextTable implementation details to pImpl
... and drop some obviously unnecessary SolarMutexGuards.
Change-Id: Ie61198a264d52d1ebf7bd7c7de12a83845f4beb1
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index a3da669..a80a57d 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -302,13 +302,6 @@ class SwXTextTable : public cppu::WeakImplHelper
private:
class Impl;
::sw::UnoImplPtr<Impl> m_pImpl;
- css::uno::WeakReference< css::table::XTableRows > m_xRows;
- css::uno::WeakReference< css::table::XTableColumns > m_xColumns;
-
- const SfxItemPropertySet* m_pPropSet;
-
- bool m_bFirstRowAsLabel;
- bool m_bFirstColumnAsLabel;
SwXTextTable();
SwXTextTable(SwFrameFormat& rFrameFormat);
@@ -320,6 +313,8 @@ public:
SW_DLLPUBLIC static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+ SW_DLLPUBLIC static void GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow);
+
SW_DLLPUBLIC SwFrameFormat* GetFrameFormat();
//XUnoTunnel
@@ -413,16 +408,6 @@ public:
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override;
- void attachToRange(const css::uno::Reference< css::text::XTextRange > & xTextRange)throw( css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception );
-
- sal_uInt16 getRowCount();
- sal_uInt16 getColumnCount();
- static css::uno::Reference< css::table::XCellRange > GetRangeByName(SwFrameFormat* pFormat, SwTable* pTable,
- const OUString& sTLName, const OUString& sBRName,
- SwRangeDescriptor& rDesc);
-
- SW_DLLPUBLIC static void GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow);
-
};
class SwXCellRange : public cppu::WeakImplHelper
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 15cb83b..31372e1 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1960,6 +1960,14 @@ public:
uno::WeakReference<uno::XInterface> m_wThis;
::cppu::OMultiTypeInterfaceContainerHelper m_Listeners;
+ const SfxItemPropertySet * m_pPropSet;
+
+ css::uno::WeakReference<css::table::XTableRows> m_xRows;
+ css::uno::WeakReference<css::table::XTableColumns> m_xColumns;
+
+ bool m_bFirstRowAsLabel;
+ bool m_bFirstColumnAsLabel;
+
// Descriptor-interface
std::unique_ptr<SwTableProperties_Impl> m_pTableProps;
OUString m_sTableName;
@@ -1969,12 +1977,20 @@ public:
Impl(SwFrameFormat *const pFrameFormat)
: SwClient(pFrameFormat)
, m_Listeners(m_Mutex)
+ , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE))
+ , m_bFirstRowAsLabel(false)
+ , m_bFirstColumnAsLabel(false)
, m_pTableProps((pFrameFormat) ? nullptr : new SwTableProperties_Impl)
, m_nRows((pFrameFormat) ? 0 : 2)
, m_nColumns((pFrameFormat) ? 0 : 2)
{
}
+ SwFrameFormat * GetFrameFormat()
+ {
+ return static_cast<SwFrameFormat*>(GetRegisteredIn());
+ }
+
bool IsDescriptor()
{
return m_pTableProps != nullptr;
@@ -1983,8 +1999,8 @@ public:
// note: lock mutex before calling this to avoid concurrent update
static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
{
- sal_uInt16 const nRowCount(rThis.getRowCount());
- sal_uInt16 const nColCount(rThis.getColumnCount());
+ sal_uInt16 const nRowCount(rThis.m_pImpl->GetRowCount());
+ sal_uInt16 const nColCount(rThis.m_pImpl->GetColumnCount());
if (!nRowCount || !nColCount)
{
throw uno::RuntimeException("Table too complex",
@@ -1993,6 +2009,9 @@ public:
return std::make_pair(nRowCount, nColCount);
}
+ sal_uInt16 GetRowCount();
+ sal_uInt16 GetColumnCount();
+
// SwClient
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
@@ -2020,19 +2039,13 @@ sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >&
SwXTextTable::SwXTextTable()
: m_pImpl(new Impl(nullptr))
- ,
- m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
- m_bFirstRowAsLabel(false),
- m_bFirstColumnAsLabel(false)
-{ }
+{
+}
SwXTextTable::SwXTextTable(SwFrameFormat& rFrameFormat)
: m_pImpl(new Impl(&rFrameFormat))
- ,
- m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
- m_bFirstRowAsLabel(false),
- m_bFirstColumnAsLabel(false)
-{ }
+{
+}
SwXTextTable::~SwXTextTable()
{
@@ -2056,7 +2069,7 @@ uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* c
SwFrameFormat* SwXTextTable::GetFrameFormat()
{
- return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(m_pImpl->GetRegisteredIn()));
+ return m_pImpl->GetFrameFormat();
}
void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeException, std::exception )
@@ -2067,27 +2080,29 @@ void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeExc
m_pImpl->m_nColumns = static_cast<sal_uInt16>(nC);
}
-uno::Reference< table::XTableRows > SwXTextTable::getRows() throw( uno::RuntimeException, std::exception )
+uno::Reference<table::XTableRows> SAL_CALL SwXTextTable::getRows()
+throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- uno::Reference<table::XTableRows> xResult(m_xRows);
+ uno::Reference<table::XTableRows> xResult(m_pImpl->m_xRows);
if(xResult.is())
return xResult;
if(SwFrameFormat* pFormat = GetFrameFormat())
- m_xRows = xResult = new SwXTableRows(*pFormat);
+ m_pImpl->m_xRows = xResult = new SwXTableRows(*pFormat);
if(!xResult.is())
throw uno::RuntimeException();
return xResult;
}
-uno::Reference< table::XTableColumns > SwXTextTable::getColumns() throw( uno::RuntimeException, std::exception )
+uno::Reference<table::XTableColumns> SAL_CALL SwXTextTable::getColumns()
+throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- uno::Reference<table::XTableColumns> xResult(m_xColumns);
+ uno::Reference<table::XTableColumns> xResult(m_pImpl->m_xColumns);
if(xResult.is())
return xResult;
if(SwFrameFormat* pFormat = GetFrameFormat())
- m_xColumns = xResult = new SwXTableColumns(*pFormat);
+ m_pImpl->m_xColumns = xResult = new SwXTableColumns(*pFormat);
if(!xResult.is())
throw uno::RuntimeException();
return xResult;
@@ -2131,10 +2146,13 @@ uno::Reference<text::XTextTableCursor> SwXTextTable::createCursorByCellName(cons
return new SwXTextTableCursor(pFormat, pBox);
}
-void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
- throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
+void SAL_CALL
+SwXTextTable::attach(const uno::Reference<text::XTextRange> & xTextRange)
+throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
- // attachToRange must only be called once
+ SolarMutexGuard aGuard;
+
+ // attach() must only be called once
if (!m_pImpl->IsDescriptor()) /* already attached ? */
throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this));
@@ -2202,13 +2220,6 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
}
}
-void SwXTextTable::attach(const uno::Reference< text::XTextRange > & xTextRange)
- throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
-{
- SolarMutexGuard aGuard;
- attachToRange(xTextRange);
-}
-
uno::Reference<text::XTextRange> SwXTextTable::getAnchor()
throw( uno::RuntimeException, std::exception )
{
@@ -2261,11 +2272,13 @@ uno::Reference<table::XCell> SwXTextTable::getCellByPosition(sal_Int32 nColumn,
throw lang::IndexOutOfBoundsException();
}
-uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrameFormat* pFormat, SwTable* pTable,
+namespace {
+
+static uno::Reference<table::XCellRange> GetRangeByName(
+ SwFrameFormat* pFormat, SwTable* pTable,
const OUString& rTLName, const OUString& rBRName,
SwRangeDescriptor& rDesc)
{
- SolarMutexGuard aGuard;
const SwTableBox* pTLBox = pTable->GetTableBox(rTLName);
if(!pTLBox)
return nullptr;
@@ -2289,6 +2302,8 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrameFormat* p
return SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, rDesc).get();
}
+} // namespace
+
uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
throw(uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
{
@@ -2371,7 +2386,8 @@ uno::Sequence< uno::Sequence< double > > SwXTextTable::getData()
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);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
+ m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
return xAllRange->getData();
}
@@ -2383,7 +2399,8 @@ void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData
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);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
+ m_pImpl->m_bFirstRowAsLabel, m_pImpl->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);
@@ -2397,7 +2414,8 @@ uno::Sequence<OUString> SwXTextTable::getRowDescriptions()
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);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
+ m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
return xAllRange->getRowDescriptions();
}
@@ -2409,7 +2427,8 @@ void SwXTextTable::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
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);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
+ m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
xAllRange->setRowDescriptions(rRowDesc);
}
@@ -2421,7 +2440,8 @@ uno::Sequence<OUString> SwXTextTable::getColumnDescriptions()
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);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
+ m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
return xAllRange->getColumnDescriptions();
}
@@ -2433,7 +2453,8 @@ void SwXTextTable::setColumnDescriptions(const uno::Sequence<OUString>& rColumnD
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);
+ static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
+ m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
return xAllRange->setColumnDescriptions(rColumnDesc);
}
@@ -2526,7 +2547,7 @@ void SwXTextTable::autoFormat(const OUString& sAutoFormatName)
uno::Reference< beans::XPropertySetInfo > SwXTextTable::getPropertySetInfo() throw( uno::RuntimeException, std::exception )
{
- static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
+ static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
return xRef;
}
@@ -2540,7 +2561,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
if(!aValue.hasValue())
throw lang::IllegalArgumentException();
const SfxItemPropertySimpleEntry* pEntry =
- m_pPropSet->getPropertyMap().getByName(rPropertyName);
+ m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
if( !pEntry )
throw lang::IllegalArgumentException();
if(pFormat)
@@ -2567,10 +2588,10 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
case FN_UNO_RANGE_ROW_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(m_bFirstRowAsLabel != bTmp)
+ if (m_pImpl->m_bFirstRowAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
- m_bFirstRowAsLabel = bTmp;
+ m_pImpl->m_bFirstRowAsLabel = bTmp;
}
}
break;
@@ -2578,10 +2599,10 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
case FN_UNO_RANGE_COL_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(m_bFirstColumnAsLabel != bTmp)
+ if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
- m_bFirstColumnAsLabel = bTmp;
+ m_pImpl->m_bFirstColumnAsLabel = bTmp;
}
}
break;
@@ -2762,7 +2783,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
default:
{
SwAttrSet aSet(pFormat->GetAttrSet());
- m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
+ m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
pFormat->GetDoc()->SetAttr(aSet, *pFormat);
}
}
@@ -2786,7 +2807,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
uno::Any aRet;
SwFrameFormat* pFormat = GetFrameFormat();
const SfxItemPropertySimpleEntry* pEntry =
- m_pPropSet->getPropertyMap().getByName(rPropertyName);
+ m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
if (!pEntry)
throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
@@ -2816,12 +2837,12 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
case FN_UNO_RANGE_ROW_LABEL:
{
- aRet <<= m_bFirstRowAsLabel;
+ aRet <<= m_pImpl->m_bFirstRowAsLabel;
}
break;
case FN_UNO_RANGE_COL_LABEL:
- aRet <<= m_bFirstColumnAsLabel;
+ aRet <<= m_pImpl->m_bFirstColumnAsLabel;
break;
case FN_UNO_TABLE_BORDER:
@@ -3001,7 +3022,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
default:
{
const SwAttrSet& rSet = pFormat->GetAttrSet();
- m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
+ m_pImpl->m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
}
}
}
@@ -3096,9 +3117,8 @@ void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException,
m_pImpl->m_sTableName = rName;
}
-sal_uInt16 SwXTextTable::getRowCount()
+sal_uInt16 SwXTextTable::Impl::GetRowCount()
{
- SolarMutexGuard aGuard;
sal_uInt16 nRet = 0;
SwFrameFormat* pFormat = GetFrameFormat();
if(pFormat)
@@ -3112,9 +3132,8 @@ sal_uInt16 SwXTextTable::getRowCount()
return nRet;
}
-sal_uInt16 SwXTextTable::getColumnCount()
+sal_uInt16 SwXTextTable::Impl::GetColumnCount()
{
- SolarMutexGuard aGuard;
SwFrameFormat* pFormat = GetFrameFormat();
sal_uInt16 nRet = 0;
if(pFormat)
commit 47a415075e9f33136b14512879384a8bece490c8
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Feb 5 13:20:21 2016 +0100
sw: remove redundant SwXTextTable::Impl::m_isDescriptor
Change-Id: I51139c1c7658e6b71ebb704a8d02d1a8366a32d5
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 5b88481..15cb83b 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1963,7 +1963,6 @@ public:
// Descriptor-interface
std::unique_ptr<SwTableProperties_Impl> m_pTableProps;
OUString m_sTableName;
- bool m_isDescriptor;
unsigned short m_nRows;
unsigned short m_nColumns;
@@ -1971,12 +1970,16 @@ public:
: SwClient(pFrameFormat)
, m_Listeners(m_Mutex)
, m_pTableProps((pFrameFormat) ? nullptr : new SwTableProperties_Impl)
- , m_isDescriptor((pFrameFormat) ? false : true)
, m_nRows((pFrameFormat) ? 0 : 2)
, m_nColumns((pFrameFormat) ? 0 : 2)
{
}
+ bool IsDescriptor()
+ {
+ return m_pTableProps != nullptr;
+ }
+
// note: lock mutex before calling this to avoid concurrent update
static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
{
@@ -2058,7 +2061,7 @@ SwFrameFormat* SwXTextTable::GetFrameFormat()
void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeException, std::exception )
{
- if (!m_pImpl->m_isDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX)
+ if (!m_pImpl->IsDescriptor() || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX)
throw uno::RuntimeException();
m_pImpl->m_nRows = static_cast<sal_uInt16>(nR);
m_pImpl->m_nColumns = static_cast<sal_uInt16>(nC);
@@ -2132,7 +2135,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
{
// attachToRange must only be called once
- if (!m_pImpl->m_isDescriptor) /* already attached ? */
+ if (!m_pImpl->IsDescriptor()) /* already attached ? */
throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this));
uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
@@ -2193,7 +2196,6 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
const::uno::Any* pName;
if (m_pImpl->m_pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
setName(pName->get<OUString>());
- m_pImpl->m_isDescriptor = false;
m_pImpl->m_pTableProps.reset();
}
pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, nullptr );
@@ -2766,7 +2768,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
}
}
}
- else if (m_pImpl->m_isDescriptor)
+ else if (m_pImpl->IsDescriptor())
{
m_pImpl->m_pTableProps->SetProperty(pEntry->nWID, pEntry->nMemberId, aValue);
}
@@ -3004,7 +3006,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
}
}
}
- else if (m_pImpl->m_isDescriptor)
+ else if (m_pImpl->IsDescriptor())
{
const uno::Any* pAny = nullptr;
if (!m_pImpl->m_pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
@@ -3033,7 +3035,7 @@ OUString SwXTextTable::getName() throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
SwFrameFormat* pFormat = GetFrameFormat();
- if (!pFormat && !m_pImpl->m_isDescriptor)
+ if (!pFormat && !m_pImpl->IsDescriptor())
throw uno::RuntimeException();
if(pFormat)
{
@@ -3046,7 +3048,7 @@ void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException,
{
SolarMutexGuard aGuard;
SwFrameFormat* pFormat = GetFrameFormat();
- if ((!pFormat && !m_pImpl->m_isDescriptor) ||
+ if ((!pFormat && !m_pImpl->IsDescriptor()) ||
rName.isEmpty() ||
rName.indexOf('.')>=0 ||
rName.indexOf(' ')>=0 )
commit ac9d9f9478c9b688296d723ef3b751d5184753b3
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Feb 5 13:10:43 2016 +0100
sw: move the SwXTextTable descriptor members to SwXTextTable::Impl
Now SolarMutex is locked only once in the destructor.
Change-Id: I945fcf2ac25ddc46fef521777109f4b4ac5e5232
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 0fde2c6..a3da669 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -285,7 +285,6 @@ struct SwRangeDescriptor
void Normalize();
};
-class SwTableProperties_Impl;
class SwXTextTable : public cppu::WeakImplHelper
<
css::text::XTextTable,
@@ -308,13 +307,6 @@ private:
const SfxItemPropertySet* m_pPropSet;
- // Descriptor-interface
- SwTableProperties_Impl* pTableProps;
- OUString m_sTableName;
- bool bIsDescriptor;
- unsigned short nRows;
- unsigned short nColumns;
-
bool m_bFirstRowAsLabel;
bool m_bFirstColumnAsLabel;
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index cb741b1..5b88481 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1800,39 +1800,8 @@ void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropert
void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
{ ClientModify(this, pOld, pNew); }
-class SwXTextTable::Impl
- : public SwClient
-{
-private:
- ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
-
-public:
- uno::WeakReference<uno::XInterface> m_wThis;
- ::cppu::OMultiTypeInterfaceContainerHelper m_Listeners;
-
- Impl(SwFrameFormat *const pFrameFormat)
- : SwClient(pFrameFormat)
- , m_Listeners(m_Mutex)
- {
- }
-
- // note: lock mutex before calling this to avoid concurrent update
- static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
- {
- sal_uInt16 const nRowCount(rThis.getRowCount());
- sal_uInt16 const nColCount(rThis.getColumnCount());
- if (!nRowCount || !nColCount)
- {
- throw uno::RuntimeException("Table too complex",
- static_cast<cppu::OWeakObject*>(&rThis));
- }
- return std::make_pair(nRowCount, nColCount);
- }
-
- // SwClient
- virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
-};
+// SwXTextTable ===========================================================
class SwTableProperties_Impl
{
@@ -1981,6 +1950,51 @@ void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
}
}
+class SwXTextTable::Impl
+ : public SwClient
+{
+private:
+ ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
+
+public:
+ uno::WeakReference<uno::XInterface> m_wThis;
+ ::cppu::OMultiTypeInterfaceContainerHelper m_Listeners;
+
+ // Descriptor-interface
+ std::unique_ptr<SwTableProperties_Impl> m_pTableProps;
+ OUString m_sTableName;
+ bool m_isDescriptor;
+ unsigned short m_nRows;
+ unsigned short m_nColumns;
+
+ Impl(SwFrameFormat *const pFrameFormat)
+ : SwClient(pFrameFormat)
+ , m_Listeners(m_Mutex)
+ , m_pTableProps((pFrameFormat) ? nullptr : new SwTableProperties_Impl)
+ , m_isDescriptor((pFrameFormat) ? false : true)
+ , m_nRows((pFrameFormat) ? 0 : 2)
+ , m_nColumns((pFrameFormat) ? 0 : 2)
+ {
+ }
+
+ // note: lock mutex before calling this to avoid concurrent update
+ static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
+ {
+ sal_uInt16 const nRowCount(rThis.getRowCount());
+ sal_uInt16 const nColCount(rThis.getColumnCount());
+ if (!nRowCount || !nColCount)
+ {
+ throw uno::RuntimeException("Table too complex",
+ static_cast<cppu::OWeakObject*>(&rThis));
+ }
+ return std::make_pair(nRowCount, nColCount);
+ }
+
+ // SwClient
+ virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
+
+};
+
namespace
{
class theSwXTextTableUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextTableUnoTunnelId > {};
@@ -2005,10 +2019,6 @@ SwXTextTable::SwXTextTable()
: m_pImpl(new Impl(nullptr))
,
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
- pTableProps(new SwTableProperties_Impl),
- bIsDescriptor(true),
- nRows(2),
- nColumns(2),
m_bFirstRowAsLabel(false),
m_bFirstColumnAsLabel(false)
{ }
@@ -2017,18 +2027,12 @@ SwXTextTable::SwXTextTable(SwFrameFormat& rFrameFormat)
: m_pImpl(new Impl(&rFrameFormat))
,
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
- pTableProps(nullptr),
- bIsDescriptor(false),
- nRows(0),
- nColumns(0),
m_bFirstRowAsLabel(false),
m_bFirstColumnAsLabel(false)
{ }
SwXTextTable::~SwXTextTable()
{
- SolarMutexGuard aGuard;
- delete pTableProps;
}
uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* const pFrameFormat)
@@ -2054,10 +2058,10 @@ SwFrameFormat* SwXTextTable::GetFrameFormat()
void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeException, std::exception )
{
- if(!bIsDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX )
+ if (!m_pImpl->m_isDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX)
throw uno::RuntimeException();
- nRows = static_cast<sal_uInt16>(nR);
- nColumns = static_cast<sal_uInt16>(nC);
+ m_pImpl->m_nRows = static_cast<sal_uInt16>(nR);
+ m_pImpl->m_nColumns = static_cast<sal_uInt16>(nC);
}
uno::Reference< table::XTableRows > SwXTextTable::getRows() throw( uno::RuntimeException, std::exception )
@@ -2128,7 +2132,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
{
// attachToRange must only be called once
- if(!bIsDescriptor) /* already attached ? */
+ if (!m_pImpl->m_isDescriptor) /* already attached ? */
throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this));
uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
@@ -2142,7 +2146,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
sal::static_int_cast<sal_IntPtr>(xRangeTunnel->getSomething(OTextCursorHelper::getUnoTunnelId())));
}
SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr;
- if(!pDoc || !nRows || !nColumns)
+ if (!pDoc || !m_pImpl->m_nRows || !m_pImpl->m_nColumns)
throw lang::IllegalArgumentException();
SwUnoInternalPaM aPam(*pDoc);
// this now needs to return TRUE
@@ -2164,33 +2168,33 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
}
pTable = pDoc->InsertTable(SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ),
*aPam.GetPoint(),
- nRows,
- nColumns,
+ m_pImpl->m_nRows,
+ m_pImpl->m_nColumns,
text::HoriOrientation::FULL);
if(pTable)
{
// here, the properties of the descriptor need to be analyzed
- pTableProps->ApplyTableAttr(*pTable, *pDoc);
+ m_pImpl->m_pTableProps->ApplyTableAttr(*pTable, *pDoc);
SwFrameFormat* pTableFormat(pTable->GetFrameFormat());
lcl_FormatTable(pTableFormat);
pTableFormat->Add(m_pImpl.get());
- if(!m_sTableName.isEmpty())
+ if (!m_pImpl->m_sTableName.isEmpty())
{
sal_uInt16 nIndex = 1;
- OUString sTmpNameIndex(m_sTableName);
+ OUString sTmpNameIndex(m_pImpl->m_sTableName);
while(pDoc->FindTableFormatByName(sTmpNameIndex, true) && nIndex < USHRT_MAX)
{
- sTmpNameIndex = m_sTableName + OUString::number(nIndex++);
+ sTmpNameIndex = m_pImpl->m_sTableName + OUString::number(nIndex++);
}
pDoc->SetTableName( *pTableFormat, sTmpNameIndex);
}
const::uno::Any* pName;
- if(pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
+ if (m_pImpl->m_pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
setName(pName->get<OUString>());
- bIsDescriptor = false;
- DELETEZ(pTableProps);
+ m_pImpl->m_isDescriptor = false;
+ m_pImpl->m_pTableProps.reset();
}
pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, nullptr );
}
@@ -2762,9 +2766,9 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An
}
}
}
- else if(bIsDescriptor)
+ else if (m_pImpl->m_isDescriptor)
{
- pTableProps->SetProperty( pEntry->nWID, pEntry->nMemberId, aValue);
+ m_pImpl->m_pTableProps->SetProperty(pEntry->nWID, pEntry->nMemberId, aValue);
}
else
throw uno::RuntimeException();
@@ -3000,10 +3004,10 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
}
}
}
- else if(bIsDescriptor)
+ else if (m_pImpl->m_isDescriptor)
{
const uno::Any* pAny = nullptr;
- if(!pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
+ if (!m_pImpl->m_pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
throw lang::IllegalArgumentException();
else if(pAny)
aRet = *pAny;
@@ -3029,20 +3033,20 @@ OUString SwXTextTable::getName() throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
SwFrameFormat* pFormat = GetFrameFormat();
- if(!pFormat && !bIsDescriptor)
+ if (!pFormat && !m_pImpl->m_isDescriptor)
throw uno::RuntimeException();
if(pFormat)
{
return pFormat->GetName();
}
- return m_sTableName;
+ return m_pImpl->m_sTableName;
}
void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
SwFrameFormat* pFormat = GetFrameFormat();
- if((!pFormat && !bIsDescriptor) ||
+ if ((!pFormat && !m_pImpl->m_isDescriptor) ||
rName.isEmpty() ||
rName.indexOf('.')>=0 ||
rName.indexOf(' ')>=0 )
@@ -3087,7 +3091,7 @@ void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException,
pFormat->GetDoc()->getIDocumentState().SetModified();
}
else
- m_sTableName = rName;
+ m_pImpl->m_sTableName = rName;
}
sal_uInt16 SwXTextTable::getRowCount()
commit 94db2ac39d7335fa6358588c887cef998b14b5d6
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Feb 5 12:44:50 2016 +0100
sw: move SwTextTable's SwClient to SwTextTable::Impl
Change-Id: If86bf825a714be00d678d50e80adddaced48c3e2
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 8ebe688..0fde2c6 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -298,8 +298,7 @@ class SwXTextTable : public cppu::WeakImplHelper
css::util::XSortable,
css::lang::XUnoTunnel,
css::sheet::XCellRangeData
->,
- public SwClient
+>
{
private:
class Impl;
@@ -318,10 +317,10 @@ private:
bool m_bFirstRowAsLabel;
bool m_bFirstColumnAsLabel;
-protected:
- virtual ~SwXTextTable();
+
SwXTextTable();
SwXTextTable(SwFrameFormat& rFrameFormat);
+ virtual ~SwXTextTable();
public:
static css::uno::Reference<css::text::XTextTable>
@@ -329,6 +328,8 @@ public:
SW_DLLPUBLIC static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+ SW_DLLPUBLIC SwFrameFormat* GetFrameFormat();
+
//XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException, std::exception) override;
@@ -428,10 +429,6 @@ public:
const OUString& sTLName, const OUString& sBRName,
SwRangeDescriptor& rDesc);
- //SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
-
- SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
SW_DLLPUBLIC static void GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow);
};
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index d61e691..cb741b1 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -136,14 +136,14 @@ namespace
#define UNO_TABLE_COLUMN_SUM 10000
-static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
+static void lcl_SendChartEvent(uno::Reference<uno::XInterface> const& xSource,
::cppu::OInterfaceContainerHelper & rListeners)
{
if (!rListeners.getLength())
return;
//TODO: find appropriate settings of the Event
chart::ChartDataChangeEvent event;
- event.Source = & rSource;
+ event.Source = xSource;
event.Type = chart::ChartDataChangeType_ALL;
event.StartColumn = 0;
event.EndColumn = 1;
@@ -176,17 +176,23 @@ static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
return lcl_SendChartEvent(&rSource, rListeners);
}
-static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
+static void lcl_SendChartEvent(uno::Reference<uno::XInterface> const& xSource,
::cppu::OMultiTypeInterfaceContainerHelper & rListeners)
{
::cppu::OInterfaceContainerHelper *const pContainer(rListeners.getContainer(
cppu::UnoType<chart::XChartDataChangeEventListener>::get()));
if (pContainer)
{
- lcl_SendChartEvent(rSource, *pContainer);
+ lcl_SendChartEvent(xSource, *pContainer);
}
}
+static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
+ ::cppu::OMultiTypeInterfaceContainerHelper & rListeners)
+{
+ return lcl_SendChartEvent(&rSource, rListeners);
+}
+
static bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine)
{
rSvxLine.SetColor(Color(rLine.Color));
@@ -1795,6 +1801,7 @@ void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNe
{ ClientModify(this, pOld, pNew); }
class SwXTextTable::Impl
+ : public SwClient
{
private:
::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
@@ -1803,7 +1810,11 @@ public:
uno::WeakReference<uno::XInterface> m_wThis;
::cppu::OMultiTypeInterfaceContainerHelper m_Listeners;
- Impl() : m_Listeners(m_Mutex) { }
+ Impl(SwFrameFormat *const pFrameFormat)
+ : SwClient(pFrameFormat)
+ , m_Listeners(m_Mutex)
+ {
+ }
// note: lock mutex before calling this to avoid concurrent update
static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
@@ -1817,6 +1828,10 @@ public:
}
return std::make_pair(nRowCount, nColCount);
}
+
+ // SwClient
+ virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
+
};
class SwTableProperties_Impl
@@ -1987,7 +2002,7 @@ sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >&
SwXTextTable::SwXTextTable()
- : m_pImpl(new Impl)
+ : m_pImpl(new Impl(nullptr))
,
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
pTableProps(new SwTableProperties_Impl),
@@ -1999,8 +2014,7 @@ SwXTextTable::SwXTextTable()
{ }
SwXTextTable::SwXTextTable(SwFrameFormat& rFrameFormat)
- : SwClient( &rFrameFormat )
- , m_pImpl(new Impl)
+ : m_pImpl(new Impl(&rFrameFormat))
,
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)),
pTableProps(nullptr),
@@ -2015,8 +2029,6 @@ SwXTextTable::~SwXTextTable()
{
SolarMutexGuard aGuard;
delete pTableProps;
- if(GetRegisteredIn())
- GetRegisteredIn()->Remove(this);
}
uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* const pFrameFormat)
@@ -2035,6 +2047,11 @@ uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* c
return xTable;
}
+SwFrameFormat* SwXTextTable::GetFrameFormat()
+{
+ return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(m_pImpl->GetRegisteredIn()));
+}
+
void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeException, std::exception )
{
if(!bIsDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX )
@@ -2157,7 +2174,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
SwFrameFormat* pTableFormat(pTable->GetFrameFormat());
lcl_FormatTable(pTableFormat);
- pTableFormat->Add(this);
+ pTableFormat->Add(m_pImpl.get());
if(!m_sTableName.isEmpty())
{
sal_uInt16 nIndex = 1;
@@ -3107,26 +3124,27 @@ sal_uInt16 SwXTextTable::getColumnCount()
return nRet;
}
-void SwXTextTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
+void SwXTextTable::Impl::Modify(
+ SfxPoolItem const*const pOld, SfxPoolItem const*const pNew)
{
if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT &&
static_cast<void*>(GetRegisteredIn()) == static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject )
GetRegisteredIn()->Remove(this);
else
ClientModify(this, pOld, pNew);
- if(!GetRegisteredIn())
+ uno::Reference<uno::XInterface> const xThis(m_wThis);
+ if (!xThis.is())
+ { // fdo#72695: if UNO object is already dead, don't revive it with event
+ return;
+ }
+ if (!GetRegisteredIn())
{
- uno::Reference<uno::XInterface> const xThis(m_pImpl->m_wThis);
- if (!xThis.is())
- { // fdo#72695: if UNO object is already dead, don't revive it with event
- return;
- }
lang::EventObject const ev(xThis);
- m_pImpl->m_Listeners.disposeAndClear(ev);
+ m_Listeners.disposeAndClear(ev);
}
else
{
- lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
+ lcl_SendChartEvent(xThis.get(), m_Listeners);
}
}
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index 3e81a90..1b4a180 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -1156,7 +1156,7 @@ void SwXMLTextParagraphExport::exportTable(
OSL_ENSURE( xTextTable.is(), "text table missing" );
if( xTextTable.is() )
{
- const SwXTextTable *pXTable = nullptr;
+ SwXTextTable *pXTable = nullptr;
Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
if( xTableTunnel.is() )
{
@@ -1166,7 +1166,7 @@ void SwXMLTextParagraphExport::exportTable(
}
if( pXTable )
{
- SwFrameFormat *pFormat = pXTable->GetFrameFormat();
+ SwFrameFormat *const pFormat = pXTable->GetFrameFormat();
OSL_ENSURE( pFormat, "table format missing" );
const SwTable *pTable = SwTable::FindTable( pFormat );
OSL_ENSURE( pTable, "table missing" );
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index eda3db8..66c59eb 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -1343,7 +1343,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
}
Reference< XTextTable > xTable;
- const SwXTextTable *pXTable = nullptr;
+ SwXTextTable *pXTable = nullptr;
Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
UNO_QUERY );
OSL_ENSURE( xFactory.is(), "factory missing" );
@@ -1396,7 +1396,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
}
if( pXTable )
{
- SwFrameFormat *pTableFrameFormat = pXTable->GetFrameFormat();
+ SwFrameFormat *const pTableFrameFormat = pXTable->GetFrameFormat();
OSL_ENSURE( pTableFrameFormat, "table format missing" );
SwTable *pTable = SwTable::FindTable( pTableFrameFormat );
OSL_ENSURE( pTable, "table missing" );
commit 042b36467e3e358268a483464d7e3af5689d045d
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Feb 4 23:47:47 2016 +0100
sw: move rest of SwXCellRange implementation details into pImpl
Change-Id: Id2002e535fa1a0c04aadd96e70ed2683bd5eb603
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index ef5c42b..8ebe688 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -40,7 +40,6 @@
#include <TextCursorHelper.hxx>
#include <unotext.hxx>
#include <frmfmt.hxx>
-#include <tuple>
#include <unocrsr.hxx>
class SwTable;
@@ -452,15 +451,6 @@ private:
class Impl;
::sw::UnoImplPtr<Impl> m_pImpl;
- SwRangeDescriptor aRgDesc;
- const SfxItemPropertySet* m_pPropSet;
-
- bool m_bFirstRowAsLabel;
- bool m_bFirstColumnAsLabel;
- std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> getLabelCoordinates(bool bRow);
- css::uno::Sequence<OUString> getLabelDescriptions(bool bRow);
- void setLabelDescriptions(const css::uno::Sequence<OUString>& rDesc, bool bRow);
-
SwXCellRange(sw::UnoCursorPointer pCursor, SwFrameFormat& rFrameFormat, SwRangeDescriptor& rDesc);
virtual ~SwXCellRange();
@@ -469,12 +459,13 @@ public:
sw::UnoCursorPointer pCursor, SwFrameFormat& rFrameFormat,
SwRangeDescriptor& rDesc);
- void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
- { m_bFirstRowAsLabel = bFirstRowAsLabel, m_bFirstColumnAsLabel = bFirstColumnAsLabel; }
- std::vector< css::uno::Reference< css::table::XCell > > GetCells();
+ static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+ void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel);
- static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+ std::vector<css::uno::Reference<css::table::XCell>> GetCells();
+
+ const SwUnoCursor* GetTableCursor() const;
//XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException, std::exception) override;
@@ -535,10 +526,6 @@ public:
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override;
- sal_uInt16 getRowCount();
- sal_uInt16 getColumnCount();
-
- const SwUnoCursor* GetTableCursor() const;
};
class SwXTableRows final : public cppu::WeakImplHelper
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 29d1b14..d61e691 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <tuple>
#include <list>
#include <array>
#include <utility>
@@ -3157,11 +3158,23 @@ public:
sw::UnoCursorPointer m_pTableCursor;
- Impl(sw::UnoCursorPointer const pCursor, SwFrameFormat& rFrameFormat)
+ SwRangeDescriptor m_RangeDescriptor;
+ const SfxItemPropertySet* m_pPropSet;
+
+ bool m_bFirstRowAsLabel;
+ bool m_bFirstColumnAsLabel;
+
+ Impl(sw::UnoCursorPointer const pCursor, SwFrameFormat& rFrameFormat,
+ SwRangeDescriptor& rDesc)
: SwClient(&rFrameFormat)
, m_ChartListeners(m_Mutex)
, m_pTableCursor(pCursor)
+ , m_RangeDescriptor(rDesc)
+ , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
+ , m_bFirstRowAsLabel(false)
+ , m_bFirstColumnAsLabel(false)
{
+ m_RangeDescriptor.Normalize();
}
SwFrameFormat* GetFrameFormat()
@@ -3169,6 +3182,16 @@ public:
return static_cast<SwFrameFormat*>(GetRegisteredIn());
}
+ std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> GetLabelCoordinates(bool bRow);
+
+ uno::Sequence<OUString> GetLabelDescriptions(SwXCellRange & rThis, bool bRow);
+
+ void SetLabelDescriptions(SwXCellRange & rThis,
+ const css::uno::Sequence<OUString>& rDesc, bool bRow);
+
+ sal_Int32 GetRowCount();
+ sal_Int32 GetColumnCount();
+
// SwClient
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
@@ -3215,15 +3238,10 @@ uno::Sequence<OUString> SwXCellRange::getSupportedServiceNames() throw( uno::Run
"com.sun.star.style.ParagraphPropertiesComplex" };
}
-SwXCellRange::SwXCellRange(sw::UnoCursorPointer pCursor, SwFrameFormat& rFrameFormat,
- SwRangeDescriptor& rDesc)
- : m_pImpl(new Impl(pCursor, rFrameFormat))
- , aRgDesc(rDesc)
- , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
- , m_bFirstRowAsLabel(false)
- , m_bFirstColumnAsLabel(false)
+SwXCellRange::SwXCellRange(sw::UnoCursorPointer const pCursor,
+ SwFrameFormat& rFrameFormat, SwRangeDescriptor& rDesc)
+ : m_pImpl(new Impl(pCursor, rFrameFormat, rDesc))
{
- aRgDesc.Normalize();
}
SwXCellRange::~SwXCellRange()
@@ -3241,20 +3259,27 @@ rtl::Reference<SwXCellRange> SwXCellRange::CreateXCellRange(
return pCellRange;
}
+void SwXCellRange::SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
+{
+ m_pImpl->m_bFirstRowAsLabel = bFirstRowAsLabel;
+ m_pImpl->m_bFirstColumnAsLabel = bFirstColumnAsLabel;
+}
+
std::vector< uno::Reference< table::XCell > > SwXCellRange::GetCells()
{
SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
- const sal_Int32 nRowCount(getRowCount());
- const sal_Int32 nColCount(getColumnCount());
+ const sal_Int32 nRowCount(m_pImpl->GetRowCount());
+ const sal_Int32 nColCount(m_pImpl->GetColumnCount());
std::vector< uno::Reference< table::XCell > > vResult;
vResult.reserve(static_cast<size_t>(nRowCount)*static_cast<size_t>(nColCount));
for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
- vResult.push_back(uno::Reference< table::XCell >(lcl_CreateXCell(pFormat, aRgDesc.nLeft + nCol, aRgDesc.nTop + nRow)));
+ vResult.push_back(uno::Reference< table::XCell >(lcl_CreateXCell(pFormat, m_pImpl->m_RangeDescriptor.nLeft + nCol, m_pImpl->m_RangeDescriptor.nTop + nRow)));
return vResult;
}
-uno::Reference< table::XCell > SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
+uno::Reference<table::XCell> SAL_CALL
+SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
throw( uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception )
{
SolarMutexGuard aGuard;
@@ -3263,10 +3288,11 @@ uno::Reference< table::XCell > SwXCellRange::getCellByPosition(sal_Int32 nColum
if(pFormat)
{
if(nColumn >= 0 && nRow >= 0 &&
- getColumnCount() > nColumn && getRowCount() > nRow )
+ m_pImpl->GetColumnCount() > nColumn && m_pImpl->GetRowCount() > nRow )
{
SwXCell* pXCell = lcl_CreateXCell(pFormat,
- aRgDesc.nLeft + nColumn, aRgDesc.nTop + nRow);
+ m_pImpl->m_RangeDescriptor.nLeft + nColumn,
+ m_pImpl->m_RangeDescriptor.nTop + nRow);
if(pXCell)
aRet = pXCell;
}
@@ -3276,7 +3302,8 @@ uno::Reference< table::XCell > SwXCellRange::getCellByPosition(sal_Int32 nColum
return aRet;
}
-uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
+uno::Reference<table::XCellRange> SAL_CALL
+SwXCellRange::getCellRangeByPosition(
sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
throw (uno::RuntimeException, lang::IndexOutOfBoundsException,
std::exception)
@@ -3284,7 +3311,8 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
SolarMutexGuard aGuard;
uno::Reference< table::XCellRange > aRet;
SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
- if(pFormat && getColumnCount() > nRight && getRowCount() > nBottom &&
+ if (pFormat && m_pImpl->GetColumnCount() > nRight
+ && m_pImpl->GetRowCount() > nBottom &&
nLeft <= nRight && nTop <= nBottom
&& nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
{
@@ -3292,10 +3320,10 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
if(!pTable->IsTableComplex())
{
SwRangeDescriptor aNewDesc;
- aNewDesc.nTop = nTop + aRgDesc.nTop;
- aNewDesc.nBottom = nBottom + aRgDesc.nTop;
- aNewDesc.nLeft = nLeft + aRgDesc.nLeft;
- aNewDesc.nRight = nRight + aRgDesc.nLeft;
+ aNewDesc.nTop = nTop + m_pImpl->m_RangeDescriptor.nTop;
+ aNewDesc.nBottom = nBottom + m_pImpl->m_RangeDescriptor.nTop;
+ aNewDesc.nLeft = nLeft + m_pImpl->m_RangeDescriptor.nLeft;
+ aNewDesc.nRight = nRight + m_pImpl->m_RangeDescriptor.nLeft;
aNewDesc.Normalize();
const OUString sTLName = sw_GetCellName(aNewDesc.nLeft, aNewDesc.nTop);
const OUString sBRName = sw_GetCellName(aNewDesc.nRight, aNewDesc.nBottom);
@@ -3329,7 +3357,8 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
return aRet;
}
-uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByName(const OUString& rRange)
+uno::Reference<table::XCellRange> SAL_CALL
+SwXCellRange::getCellRangeByName(const OUString& rRange)
throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
@@ -3343,17 +3372,21 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByName(const OUSt
SwXTextTable::GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
SwXTextTable::GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
aDesc.Normalize();
- return getCellRangeByPosition(aDesc.nLeft - aRgDesc.nLeft, aDesc.nTop - aRgDesc.nTop,
- aDesc.nRight - aRgDesc.nLeft, aDesc.nBottom - aRgDesc.nTop);
+ return getCellRangeByPosition(
+ aDesc.nLeft - m_pImpl->m_RangeDescriptor.nLeft,
+ aDesc.nTop - m_pImpl->m_RangeDescriptor.nTop,
+ aDesc.nRight - m_pImpl->m_RangeDescriptor.nLeft,
+ aDesc.nBottom - m_pImpl->m_RangeDescriptor.nTop);
}
uno::Reference< beans::XPropertySetInfo > SwXCellRange::getPropertySetInfo() throw( uno::RuntimeException, std::exception )
{
- static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
+ static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
return xRef;
}
-void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
+void SAL_CALL
+SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
throw (beans::UnknownPropertyException,
beans::PropertyVetoException,
lang::IllegalArgumentException,
@@ -3365,15 +3398,15 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(pFormat)
{
- const SfxItemPropertySimpleEntry* pEntry =
- m_pPropSet->getPropertyMap().getByName(rPropertyName);
+ const SfxItemPropertySimpleEntry *const pEntry =
+ m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
if(pEntry)
{
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
SwDoc *const pDoc = m_pImpl->m_pTableCursor->GetDoc();
- SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor);
+ SwUnoTableCursor& rCursor(dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor));
{
// HACK: remove pending actions for selecting old style tables
UnoActionRemoveContext aRemoveContext(rCursor);
@@ -3434,20 +3467,20 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
case FN_UNO_RANGE_ROW_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(m_bFirstRowAsLabel != bTmp)
+ if (m_pImpl->m_bFirstRowAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners);
- m_bFirstRowAsLabel = bTmp;
+ m_pImpl->m_bFirstRowAsLabel = bTmp;
}
}
break;
case FN_UNO_RANGE_COL_LABEL:
{
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
- if(m_bFirstColumnAsLabel != bTmp)
+ if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
{
lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners);
- m_bFirstColumnAsLabel = bTmp;
+ m_pImpl->m_bFirstColumnAsLabel = bTmp;
}
}
break;
@@ -3468,7 +3501,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
if (!SwUnoCursorHelper::SetCursorPropertyValue(
*pEntry, aValue, rCursor.GetSelRing(), aItemSet))
{
- m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
+ m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
}
SwUnoCursorHelper::SetCursorAttr(rCursor.GetSelRing(),
aItemSet, SetAttrMode::DEFAULT, true);
@@ -3480,7 +3513,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
}
}
-uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
+uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName)
throw (beans::UnknownPropertyException,
lang::WrappedTargetException,
uno::RuntimeException,
@@ -3491,8 +3524,8 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(pFormat)
{
- const SfxItemPropertySimpleEntry* pEntry =
- m_pPropSet->getPropertyMap().getByName(rPropertyName);
+ const SfxItemPropertySimpleEntry *const pEntry =
+ m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
if(pEntry)
{
switch(pEntry->nWID )
@@ -3532,10 +3565,10 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
}
break;
case FN_UNO_RANGE_ROW_LABEL:
- aRet <<= m_bFirstRowAsLabel;
+ aRet <<= m_pImpl->m_bFirstRowAsLabel;
break;
case FN_UNO_RANGE_COL_LABEL:
- aRet <<= m_bFirstColumnAsLabel;
+ aRet <<= m_pImpl->m_bFirstColumnAsLabel;
break;
case RES_VERT_ORIENT:
{
@@ -3557,7 +3590,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
SwUnoTableCursor *const pCursor =
dynamic_cast<SwUnoTableCursor*>(&(*m_pImpl->m_pTableCursor));
SwUnoCursorHelper::GetCursorAttr(pCursor->GetSelRing(), aSet);
- m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
+ m_pImpl->m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
}
}
}
@@ -3580,12 +3613,12 @@ void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/
{ throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
///@see SwXCellRange::getData
-uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
+uno::Sequence<uno::Sequence<uno::Any>> SAL_CALL SwXCellRange::getDataArray()
throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- const sal_Int32 nRowCount = getRowCount();
- const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = m_pImpl->GetRowCount();
+ const sal_Int32 nColCount = m_pImpl->GetColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
@@ -3611,8 +3644,8 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray) throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- const sal_Int32 nRowCount = getRowCount();
- const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = m_pImpl->GetRowCount();
+ const sal_Int32 nColCount = m_pImpl->GetColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
@@ -3642,16 +3675,19 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno
}
}
-uno::Sequence< uno::Sequence< double > > SwXCellRange::getData() throw( uno::RuntimeException, std::exception )
+uno::Sequence<uno::Sequence<double>> SAL_CALL
+SwXCellRange::getData() throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- const sal_Int32 nRowCount = getRowCount();
- const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = m_pImpl->GetRowCount();
+ const sal_Int32 nColCount = m_pImpl->GetColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel)
+ if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
{
- uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstColumnAsLabel ? 1 : 0, m_bFirstRowAsLabel ? 1 : 0,
+ uno::Reference<chart::XChartDataArray> const xDataRange(
+ getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
+ (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
nColCount-1, nRowCount-1), uno::UNO_QUERY);
return xDataRange->getData();
}
@@ -3670,17 +3706,20 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData() throw( uno::Run
return vRows;
}
-void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData)
+void SAL_CALL
+SwXCellRange::setData(const uno::Sequence< uno::Sequence<double> >& rData)
throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- const sal_Int32 nRowCount = getRowCount();
- const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = m_pImpl->GetRowCount();
+ const sal_Int32 nColCount = m_pImpl->GetColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel)
+ if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
{
- uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstColumnAsLabel ? 1 : 0, m_bFirstRowAsLabel ? 1 : 0,
+ uno::Reference<chart::XChartDataArray> const xDataRange(
+ getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
+ (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
nColCount-1, nRowCount-1), uno::UNO_QUERY);
return xDataRange->setData(rData);
}
@@ -3701,34 +3740,36 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData
}
}
-std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> SwXCellRange::getLabelCoordinates(bool bRow)
+std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32>
+SwXCellRange::Impl::GetLabelCoordinates(bool bRow)
{
sal_uInt32 nLeft, nTop, nRight, nBottom;
nLeft = nTop = nRight = nBottom = 0;
if(bRow)
{
nTop = m_bFirstRowAsLabel ? 1 : 0;
- nBottom = getRowCount()-1;
+ nBottom = GetRowCount() - 1;
}
else
{
nLeft = m_bFirstColumnAsLabel ? 1 : 0;
- nRight = getColumnCount()-1;
+ nRight = GetColumnCount() - 1;
}
return std::make_tuple(nLeft, nTop, nRight, nBottom);
}
-uno::Sequence<OUString> SwXCellRange::getLabelDescriptions(bool bRow)
+uno::Sequence<OUString>
+SwXCellRange::Impl::GetLabelDescriptions(SwXCellRange & rThis, bool bRow)
{
SolarMutexGuard aGuard;
sal_uInt32 nLeft, nTop, nRight, nBottom;
- std::tie(nLeft, nTop, nRight, nBottom) = getLabelCoordinates(bRow);
+ std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
if(!nRight && !nBottom)
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
- if(!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
+ lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
+ if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
return {}; // without labels we have no descriptions
- auto xLabelRange(getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
+ auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
uno::Sequence<OUString> vResult(vCells.size());
std::transform(vCells.begin(), vCells.end(), vResult.begin(),
@@ -3736,39 +3777,51 @@ uno::Sequence<OUString> SwXCellRange::getLabelDescriptions(bool bRow)
return vResult;
}
-uno::Sequence<OUString> SwXCellRange::getRowDescriptions()
- throw( uno::RuntimeException, std::exception )
-{ return getLabelDescriptions(true); }
+uno::Sequence<OUString> SAL_CALL SwXCellRange::getRowDescriptions()
+ throw (uno::RuntimeException, std::exception)
+{
+ return m_pImpl->GetLabelDescriptions(*this, true);
+}
-uno::Sequence<OUString> SwXCellRange::getColumnDescriptions()
- throw(uno::RuntimeException, std::exception)
-{ return getLabelDescriptions(false); }
+uno::Sequence<OUString> SAL_CALL SwXCellRange::getColumnDescriptions()
+ throw (uno::RuntimeException, std::exception)
+{
+ return m_pImpl->GetLabelDescriptions(*this, false);
+}
-void SwXCellRange::setLabelDescriptions(const uno::Sequence<OUString>& rDesc, bool bRow)
+void SwXCellRange::Impl::SetLabelDescriptions(SwXCellRange & rThis,
+ const uno::Sequence<OUString>& rDesc, bool bRow)
{
SolarMutexGuard aGuard;
- lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
- if(!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
+ lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
+ if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
return; // if there are no labels we cannot set descriptions
sal_uInt32 nLeft, nTop, nRight, nBottom;
- std::tie(nLeft, nTop, nRight, nBottom) = getLabelCoordinates(bRow);
+ std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
if(!nRight && !nBottom)
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- auto xLabelRange(getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
+ auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
if (sal::static_int_cast<sal_uInt32>(rDesc.getLength()) != vCells.size())
- throw uno::RuntimeException("Too few or too many descriptions", static_cast<cppu::OWeakObject*>(this));
+ throw uno::RuntimeException("Too few or too many descriptions", static_cast<cppu::OWeakObject*>(&rThis));
auto pDescIterator(rDesc.begin());
for(auto& xCell : vCells)
uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->setString(*pDescIterator++);
}
-void SwXCellRange::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
+
+void SAL_CALL SwXCellRange::setRowDescriptions(
+ const uno::Sequence<OUString>& rRowDesc)
throw(uno::RuntimeException, std::exception)
-{ setLabelDescriptions(rRowDesc, true); }
+{
+ m_pImpl->SetLabelDescriptions(*this, rRowDesc, true);
+}
-void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
+void SAL_CALL SwXCellRange::setColumnDescriptions(
+ const uno::Sequence<OUString>& rColumnDesc)
throw(uno::RuntimeException, std::exception)
-{ setLabelDescriptions(rColumnDesc, false); }
+{
+ m_pImpl->SetLabelDescriptions(*this, rColumnDesc, false);
+}
void SAL_CALL SwXCellRange::addChartDataChangeEventListener(
const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
@@ -3814,11 +3867,15 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD
}
}
-sal_uInt16 SwXCellRange::getColumnCount()
- { return static_cast<sal_uInt16>(aRgDesc.nRight - aRgDesc.nLeft + 1); }
+sal_Int32 SwXCellRange::Impl::GetColumnCount()
+{
+ return m_RangeDescriptor.nRight - m_RangeDescriptor.nLeft + 1;
+}
-sal_uInt16 SwXCellRange::getRowCount()
- { return static_cast<sal_uInt16>(aRgDesc.nBottom - aRgDesc.nTop + 1); }
+sal_Int32 SwXCellRange::Impl::GetRowCount()
+{
+ return m_RangeDescriptor.nBottom - m_RangeDescriptor.nTop + 1;
+}
const SwUnoCursor* SwXCellRange::GetTableCursor() const
{
commit 7e349c0eee15fa0f9d8d71a3c9e311d2da62e670
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Feb 4 22:55:07 2016 +0100
sw: fix SolarMutex asserts from SwXCellRange dtor
Happened when loading a report from the attachment of tdf#97033,
but that bug is apparently about a different crash.
Deploy the sw::UnoImplPtr, which is clearly the best way to avoid such
problems. Also another silly weak pointer this, for tdf#72695.
Change-Id: Ice8db95ca3eecc638bd4a4ef7fa8967d180bd525
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index f79598e..ef5c42b 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -33,7 +33,6 @@
#include <com/sun/star/table/XAutoFormattable.hpp>
#include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer2.hxx>
#include <comphelper/uno3.hxx>
@@ -447,28 +446,31 @@ class SwXCellRange : public cppu::WeakImplHelper
css::chart::XChartDataArray,
css::util::XSortable,
css::sheet::XCellRangeData
->,
- public SwClient
+>
{
- ::osl::Mutex m_Mutex;
- ::comphelper::OInterfaceContainerHelper2 m_ChartListeners;
+private:
+ class Impl;
+ ::sw::UnoImplPtr<Impl> m_pImpl;
SwRangeDescriptor aRgDesc;
const SfxItemPropertySet* m_pPropSet;
- sw::UnoCursorPointer m_pTableCursor;
-
bool m_bFirstRowAsLabel;
bool m_bFirstColumnAsLabel;
std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> getLabelCoordinates(bool bRow);
css::uno::Sequence<OUString> getLabelDescriptions(bool bRow);
void setLabelDescriptions(const css::uno::Sequence<OUString>& rDesc, bool bRow);
-public:
SwXCellRange(sw::UnoCursorPointer pCursor, SwFrameFormat& rFrameFormat, SwRangeDescriptor& rDesc);
+ virtual ~SwXCellRange();
+
+public:
+ static ::rtl::Reference<SwXCellRange> CreateXCellRange(
+ sw::UnoCursorPointer pCursor, SwFrameFormat& rFrameFormat,
+ SwRangeDescriptor& rDesc);
+
void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
{ m_bFirstRowAsLabel = bFirstRowAsLabel, m_bFirstColumnAsLabel = bFirstColumnAsLabel; }
- virtual ~SwXCellRange() {};
std::vector< css::uno::Reference< css::table::XCell > > GetCells();
@@ -533,10 +535,6 @@ public:
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override;
- //SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
-
- SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
sal_uInt16 getRowCount();
sal_uInt16 getColumnCount();
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index a22b4da..bb13239 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2146,7 +2146,7 @@ std::vector< css::uno::Reference< css::table::XCell > > SwChartDataSequence::Get
SwRangeDescriptor aDesc;
if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat, *m_pTableCursor)))
return std::vector< css::uno::Reference< css::table::XCell > >();
- return SwXCellRange(m_pTableCursor, *pTableFormat, aDesc).GetCells();
+ return SwXCellRange::CreateXCellRange(m_pTableCursor, *pTableFormat, aDesc)->GetCells();
}
uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index e20b35b..29d1b14 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -99,6 +99,7 @@
#include <rtl/math.hxx>
#include <editeng/frmdiritem.hxx>
#include <calbck.hxx>
+#include <comphelper/interfacecontainer2.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/string.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -151,14 +152,14 @@ static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
& chart::XChartDataChangeEventListener::chartDataChanged, event);
}
-static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
+static void lcl_SendChartEvent(uno::Reference<uno::XInterface> const& xSource,
::comphelper::OInterfaceContainerHelper2 & rListeners)
{
if (!rListeners.getLength())
return;
//TODO: find appropriate settings of the Event
chart::ChartDataChangeEvent event;
- event.Source = & rSource;
+ event.Source = xSource;
event.Type = chart::ChartDataChangeType_ALL;
event.StartColumn = 0;
event.EndColumn = 1;
@@ -169,6 +170,12 @@ static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
}
static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
+ ::comphelper::OInterfaceContainerHelper2 & rListeners)
+{
+ return lcl_SendChartEvent(&rSource, rListeners);
+}
+
+static void lcl_SendChartEvent(::cppu::OWeakObject & rSource,
::cppu::OMultiTypeInterfaceContainerHelper & rListeners)
{
::cppu::OInterfaceContainerHelper *const pContainer(rListeners.getContainer(
@@ -2255,7 +2262,7 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrameFormat* p
UnoActionRemoveContext aRemoveContext(*pCursor);
pCursor->MakeBoxSels();
// pUnoCursor will be provided and will not be deleted
- return new SwXCellRange(pUnoCursor, *pFormat, rDesc);
+ return SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, rDesc).get();
}
uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
@@ -3137,6 +3144,36 @@ uno::Sequence<OUString> SwXTextTable::getSupportedServiceNames() throw(uno::Runt
"com.sun.star.text.TextSortable" };
}
+
+class SwXCellRange::Impl
+ : public SwClient
+{
+private:
+ ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
+
+public:
+ uno::WeakReference<uno::XInterface> m_wThis;
+ ::comphelper::OInterfaceContainerHelper2 m_ChartListeners;
+
+ sw::UnoCursorPointer m_pTableCursor;
+
+ Impl(sw::UnoCursorPointer const pCursor, SwFrameFormat& rFrameFormat)
+ : SwClient(&rFrameFormat)
+ , m_ChartListeners(m_Mutex)
+ , m_pTableCursor(pCursor)
+ {
+ }
+
+ SwFrameFormat* GetFrameFormat()
+ {
+ return static_cast<SwFrameFormat*>(GetRegisteredIn());
+ }
+
+ // SwClient
+ virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override;
+
+};
+
namespace
{
class theSwXCellRangeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXCellRangeUnoTunnelId > {};
@@ -3180,20 +3217,33 @@ uno::Sequence<OUString> SwXCellRange::getSupportedServiceNames() throw( uno::Run
SwXCellRange::SwXCellRange(sw::UnoCursorPointer pCursor, SwFrameFormat& rFrameFormat,
SwRangeDescriptor& rDesc)
- : SwClient(&rFrameFormat)
- , m_ChartListeners(m_Mutex)
+ : m_pImpl(new Impl(pCursor, rFrameFormat))
, aRgDesc(rDesc)
, m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
- , m_pTableCursor(pCursor)
, m_bFirstRowAsLabel(false)
, m_bFirstColumnAsLabel(false)
{
aRgDesc.Normalize();
}
+SwXCellRange::~SwXCellRange()
+{
+}
+
+rtl::Reference<SwXCellRange> SwXCellRange::CreateXCellRange(
+ sw::UnoCursorPointer const pCursor, SwFrameFormat& rFrameFormat,
+ SwRangeDescriptor& rDesc)
+{
+ SwXCellRange *const pCellRange(new SwXCellRange(pCursor, rFrameFormat, rDesc));
+ uno::Reference<table::XCellRange> xCellRange(pCellRange);
+ // need a permanent Reference to initialize m_wThis
+ pCellRange->m_pImpl->m_wThis = xCellRange;
+ return pCellRange;
+}
+
std::vector< uno::Reference< table::XCell > > SwXCellRange::GetCells()
{
- SwFrameFormat* const pFormat = GetFrameFormat();
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
const sal_Int32 nRowCount(getRowCount());
const sal_Int32 nColCount(getColumnCount());
std::vector< uno::Reference< table::XCell > > vResult;
@@ -3209,7 +3259,7 @@ uno::Reference< table::XCell > SwXCellRange::getCellByPosition(sal_Int32 nColum
{
SolarMutexGuard aGuard;
uno::Reference< table::XCell > aRet;
- SwFrameFormat* pFormat = GetFrameFormat();
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(pFormat)
{
if(nColumn >= 0 && nRow >= 0 &&
@@ -3233,7 +3283,7 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
{
SolarMutexGuard aGuard;
uno::Reference< table::XCellRange > aRet;
- SwFrameFormat* pFormat = GetFrameFormat();
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(pFormat && getColumnCount() > nRight && getRowCount() > nBottom &&
nLeft <= nRight && nTop <= nBottom
&& nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
@@ -3269,8 +3319,7 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition(
UnoActionRemoveContext aRemoveContext(*pCursor);
pCursor->MakeBoxSels();
// pUnoCursor will be provided and will not be deleted
- SwXCellRange* pCellRange = new SwXCellRange(pUnoCursor, *pFormat, aNewDesc);
- aRet = pCellRange;
+ aRet = SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, aNewDesc).get();
}
}
}
@@ -3313,7 +3362,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
std::exception)
{
SolarMutexGuard aGuard;
- SwFrameFormat* pFormat = GetFrameFormat();
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(pFormat)
{
const SfxItemPropertySimpleEntry* pEntry =
@@ -3323,8 +3372,8 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- SwDoc* pDoc = m_pTableCursor->GetDoc();
- SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*m_pTableCursor);
+ SwDoc *const pDoc = m_pImpl->m_pTableCursor->GetDoc();
+ SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor);
{
// HACK: remove pending actions for selecting old style tables
UnoActionRemoveContext aRemoveContext(rCursor);
@@ -3335,9 +3384,9 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
case FN_UNO_TABLE_CELL_BACKGROUND:
{
SvxBrushItem aBrush( RES_BACKGROUND );
- SwDoc::GetBoxAttr( *m_pTableCursor, aBrush );
+ SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
((SfxPoolItem&)aBrush).PutValue(aValue, pEntry->nMemberId);
- pDoc->SetBoxAttr( *m_pTableCursor, aBrush );
+ pDoc->SetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
}
break;
@@ -3372,7 +3421,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
SvxBoxItem aBoxItem(static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX)));
((SfxPoolItem&)aBoxItem).PutValue(aValue, pEntry->nMemberId);
aSet.Put(aBoxItem);
- pDoc->SetTabBorders( *m_pTableCursor, aSet );
+ pDoc->SetTabBorders(*m_pImpl->m_pTableCursor, aSet);
}
break;
case RES_BOXATR_FORMAT:
@@ -3387,7 +3436,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
if(m_bFirstRowAsLabel != bTmp)
{
- lcl_SendChartEvent(*this, m_ChartListeners);
+ lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners);
m_bFirstRowAsLabel = bTmp;
}
}
@@ -3397,7 +3446,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::An
bool bTmp = *static_cast<sal_Bool const *>(aValue.getValue());
if(m_bFirstColumnAsLabel != bTmp)
{
- lcl_SendChartEvent(*this, m_ChartListeners);
+ lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners);
m_bFirstColumnAsLabel = bTmp;
}
}
@@ -3439,7 +3488,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
{
SolarMutexGuard aGuard;
uno::Any aRet;
- SwFrameFormat* pFormat = GetFrameFormat();
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(pFormat)
{
const SfxItemPropertySimpleEntry* pEntry =
@@ -3451,20 +3500,20 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
case FN_UNO_TABLE_CELL_BACKGROUND:
{
SvxBrushItem aBrush( RES_BACKGROUND );
- if(SwDoc::GetBoxAttr( *m_pTableCursor, aBrush ))
+ if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush))
aBrush.QueryValue(aRet, pEntry->nMemberId);
}
break;
case RES_BOX :
{
- SwDoc* pDoc = m_pTableCursor->GetDoc();
+ SwDoc *const pDoc = m_pImpl->m_pTableCursor->GetDoc();
SfxItemSet aSet(pDoc->GetAttrPool(),
RES_BOX, RES_BOX,
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
0);
aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
- SwDoc::GetTabBorders(*m_pTableCursor, aSet);
+ SwDoc::GetTabBorders(*m_pImpl->m_pTableCursor, aSet);
const SvxBoxItem& rBoxItem = static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX));
rBoxItem.QueryValue(aRet, pEntry->nMemberId);
}
@@ -3475,7 +3524,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
case FN_UNO_PARA_STYLE:
{
SwFormatColl *const pTmpFormat =
- SwUnoCursorHelper::GetCurTextFormatColl(*m_pTableCursor, false);
+ SwUnoCursorHelper::GetCurTextFormatColl(*m_pImpl->m_pTableCursor, false);
OUString sRet;
if(pFormat)
sRet = pTmpFormat->GetName();
@@ -3491,7 +3540,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
case RES_VERT_ORIENT:
{
SwFormatVertOrient aVertOrient;
- if( SwDoc::GetBoxAttr( *m_pTableCursor, aVertOrient ) )
+ if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient))
{
aVertOrient.QueryValue( aRet, pEntry->nMemberId );
}
@@ -3499,13 +3548,14 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
break;
default:
{
- SfxItemSet aSet(m_pTableCursor->GetDoc()->GetAttrPool(),
+ SfxItemSet aSet(m_pImpl->m_pTableCursor->GetDoc()->GetAttrPool(),
RES_CHRATR_BEGIN, RES_FRMATR_END -1,
RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
0L);
// first look at the attributes of the cursor
- SwUnoTableCursor* pCursor = dynamic_cast<SwUnoTableCursor*>(&(*m_pTableCursor));
+ SwUnoTableCursor *const pCursor =
+ dynamic_cast<SwUnoTableCursor*>(&(*m_pImpl->m_pTableCursor));
SwUnoCursorHelper::GetCursorAttr(pCursor->GetSelRing(), aSet);
m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
}
@@ -3538,7 +3588,7 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
const sal_Int32 nColCount = getColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
+ lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
auto vCells(GetCells());
auto pCurrentCell(vCells.begin());
@@ -3565,7 +3615,7 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno
const sal_Int32 nColCount = getColumnCount();
if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- SwFrameFormat* pFormat = GetFrameFormat();
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(!pFormat)
return;
if(rArray.getLength() != nRowCount)
@@ -3634,7 +3684,7 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData
nColCount-1, nRowCount-1), uno::UNO_QUERY);
return xDataRange->setData(rData);
}
- lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
+ lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
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());
@@ -3675,7 +3725,7 @@ uno::Sequence<OUString> SwXCellRange::getLabelDescriptions(bool bRow)
std::tie(nLeft, nTop, nRight, nBottom) = getLabelCoordinates(bRow);
if(!nRight && !nBottom)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
+ lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
if(!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
return {}; // without labels we have no descriptions
auto xLabelRange(getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
@@ -3697,7 +3747,7 @@ uno::Sequence<OUString> SwXCellRange::getColumnDescriptions()
void SwXCellRange::setLabelDescriptions(const uno::Sequence<OUString>& rDesc, bool bRow)
{
SolarMutexGuard aGuard;
- lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
+ lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
if(!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
return; // if there are no labels we cannot set descriptions
sal_uInt32 nLeft, nTop, nRight, nBottom;
@@ -3725,7 +3775,7 @@ void SAL_CALL SwXCellRange::addChartDataChangeEventListener(
throw (uno::RuntimeException, std::exception)
{
// no need to lock here as m_pImpl is const and container threadsafe
- m_ChartListeners.addInterface(xListener);
+ m_pImpl->m_ChartListeners.addInterface(xListener);
}
void SAL_CALL SwXCellRange::removeChartDataChangeEventListener(
@@ -3733,7 +3783,7 @@ void SAL_CALL SwXCellRange::removeChartDataChangeEventListener(
throw (uno::RuntimeException, std::exception)
{
// no need to lock here as m_pImpl is const and container threadsafe
- m_ChartListeners.removeInterface(xListener);
+ m_pImpl->m_ChartListeners.removeInterface(xListener);
}
sal_Bool SwXCellRange::isNotANumber(double /*fNumber*/) throw( uno::RuntimeException, std::exception )
@@ -3754,10 +3804,10 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD
{
SolarMutexGuard aGuard;
SwSortOptions aSortOpt;
- SwFrameFormat* pFormat(GetFrameFormat());
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
if(pFormat && SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
{
- SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pTableCursor);
+ SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor);
rTableCursor.MakeBoxSels();
UnoActionContext aContext(pFormat->GetDoc());
pFormat->GetDoc()->SortTable(rTableCursor.GetSelectedBoxes(), aSortOpt);
@@ -3772,22 +3822,28 @@ sal_uInt16 SwXCellRange::getRowCount()
const SwUnoCursor* SwXCellRange::GetTableCursor() const
{
- SwFrameFormat* pFormat = GetFrameFormat();
- return pFormat ? &(*m_pTableCursor) : nullptr;
+ SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
+ return pFormat ? &(*m_pImpl->m_pTableCursor) : nullptr;
}
-void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
+void SwXCellRange::Impl::Modify(
+ SfxPoolItem const*const pOld, SfxPoolItem const*const pNew)
{
- ClientModify(this, pOld, pNew );
+ ClientModify(this, pOld, pNew);
+ uno::Reference<uno::XInterface> const xThis(m_wThis);
+ if (!xThis.is())
+ { // fdo#72695: if UNO object is already dead, don't revive it with event
+ return;
+ }
if(!GetRegisteredIn() || !m_pTableCursor)
{
m_pTableCursor.reset(nullptr);
- lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
+ lang::EventObject const ev(xThis);
m_ChartListeners.disposeAndClear(ev);
}
else
{
- lcl_SendChartEvent(*this, m_ChartListeners);
+ lcl_SendChartEvent(xThis.get(), m_ChartListeners);
}
}
More information about the Libreoffice-commits
mailing list