[Libreoffice-commits] core.git: 14 commits - sw/inc sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Tue Jun 30 01:44:40 PDT 2015
sw/inc/unochart.hxx | 2
sw/inc/unotbl.hxx | 24 +--
sw/source/core/unocore/unochart.cxx | 131 +++++++------------
sw/source/core/unocore/unotbl.cxx | 240 ++++++++++--------------------------
4 files changed, 129 insertions(+), 268 deletions(-)
New commits:
commit a1b73b37c761a4bea51fb17f1158c98f579eb305
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 13:21:17 2015 +0200
getCells->GetCells(): not an UNO function
Change-Id: I89335201083bd68fa199ce52e78d7750c60f8895
diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx
index 580368a..3f59dd3 100644
--- a/sw/inc/unochart.hxx
+++ b/sw/inc/unochart.hxx
@@ -350,7 +350,7 @@ public:
void FillRangeDesc( SwRangeDescriptor &rRangeDesc ) const;
bool ExtendTo( bool bExtendCol, sal_Int32 nFirstNew, sal_Int32 nCount );
- std::vector< css::uno::Reference< css::table::XCell > > getCells();
+ std::vector< css::uno::Reference< css::table::XCell > > GetCells();
};
typedef cppu::WeakImplHelper
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 94fb3bd..e8009a8 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -471,7 +471,7 @@ public:
void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
{ m_bFirstRowAsLabel = bFirstRowAsLabel, m_bFirstColumnAsLabel = bFirstColumnAsLabel; }
virtual ~SwXCellRange() {};
- std::vector< css::uno::Reference< css::table::XCell > > getCells();
+ std::vector< css::uno::Reference< css::table::XCell > > GetCells();
TYPEINFO_OVERRIDE();
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index b95ec32..ed8d35a 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2135,7 +2135,7 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::generateLabel(
return 0;
}
-std::vector< css::uno::Reference< css::table::XCell > > SwChartDataSequence::getCells()
+std::vector< css::uno::Reference< css::table::XCell > > SwChartDataSequence::GetCells()
{
if (bDisposed)
throw lang::DisposedException();
@@ -2148,14 +2148,14 @@ std::vector< css::uno::Reference< css::table::XCell > > SwChartDataSequence::get
SwRangeDescriptor aDesc;
if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat, *pTableCrsr)))
return {};
- return SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getCells();
+ return SwXCellRange(pTableCrsr, *pTableFormat, aDesc).GetCells();
}
uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- auto vCells(getCells());
+ auto vCells(GetCells());
uno::Sequence< OUString > vTextData(vCells.size());
std::transform(vCells.begin(),
vCells.end(),
@@ -2169,7 +2169,7 @@ uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData()
throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- auto vCells(getCells());
+ auto vCells(GetCells());
uno::Sequence< uno::Any > vAnyData(vCells.size());
std::transform(vCells.begin(),
vCells.end(),
@@ -2183,7 +2183,7 @@ uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData()
throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- auto vCells(getCells());
+ auto vCells(GetCells());
uno::Sequence< double > vNumData(vCells.size());
std::transform(vCells.begin(),
vCells.end(),
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 1b5616d..fd3e489 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3180,7 +3180,7 @@ SwXCellRange::SwXCellRange(sw::UnoCursorPointer pCrsr, SwFrameFormat& rFrameForm
aRgDesc.Normalize();
}
-std::vector< uno::Reference< table::XCell > > SwXCellRange::getCells()
+std::vector< uno::Reference< table::XCell > > SwXCellRange::GetCells()
{
SwFrameFormat* const pFormat = GetFrameFormat();
const sal_Int32 nRowCount(getRowCount());
@@ -3512,7 +3512,7 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
- auto vCells(getCells());
+ auto vCells(GetCells());
auto pCurrentCell(vCells.begin());
for(auto& rRow : aRowSeq)
{
@@ -3542,7 +3542,7 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno
return;
if(rArray.getLength() != nRowCount)
throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rArray.getLength()), static_cast<cppu::OWeakObject*>(this));
- auto vCells(getCells());
+ auto vCells(GetCells());
auto pCurrentCell(vCells.begin());
for(const auto& rColSeq : rArray)
{
@@ -3578,7 +3578,7 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData() throw( uno::Run
return xDataRange->getData();
}
uno::Sequence< uno::Sequence< double > > vRows(nRowCount);
- auto vCells(getCells());
+ auto vCells(GetCells());
auto pCurrentCell(vCells.begin());
for(auto& rRow : vRows)
{
@@ -3609,7 +3609,7 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData
lcl_EnsureCoreConnected(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());
+ auto vCells(GetCells());
auto pCurrentCell(vCells.begin());
for(const auto& rRow : rData)
{
@@ -3651,7 +3651,7 @@ uno::Sequence<OUString> SwXCellRange::getLabelDescriptions(bool bRow)
if(!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
return {}; // without labels we have no descriptions
auto xLabelRange(getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
- auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->getCells());
+ auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
uno::Sequence<OUString> vResult(vCells.size());
std::transform(vCells.begin(), vCells.end(), vResult.begin(),
[](uno::Reference<table::XCell> xCell) -> OUString { return uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->getString(); });
@@ -3677,7 +3677,7 @@ void SwXCellRange::setLabelDescriptions(const uno::Sequence<OUString>& rDesc, bo
if(!nRight && !nBottom)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
auto xLabelRange(getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
- auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->getCells());
+ 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));
auto pDescIterator(rDesc.begin());
commit 7c17cb0a52a14f4788d6f293d968e95f87c514e1
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 13:01:53 2015 +0200
use initializer-lists
Change-Id: I801bb81a7c241b40377617d8f3567e62b79e3976
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index ceb9602..b95ec32 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1492,10 +1492,7 @@ sal_Bool SAL_CALL SwChartDataProvider::supportsService(const OUString& rServiceN
uno::Sequence< OUString > SAL_CALL SwChartDataProvider::getSupportedServiceNames( )
throw (uno::RuntimeException, std::exception)
{
- SolarMutexGuard aGuard;
- uno::Sequence< OUString > aRes(1);
- aRes.getArray()[0] = "com.sun.star.chart2.data.DataProvider";
- return aRes;
+ return { "com.sun.star.chart2.data.DataProvider"};
}
void SwChartDataProvider::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
@@ -1880,10 +1877,7 @@ sal_Bool SAL_CALL SwChartDataSource::supportsService(const OUString& rServiceNam
uno::Sequence< OUString > SAL_CALL SwChartDataSource::getSupportedServiceNames( )
throw (uno::RuntimeException, std::exception)
{
- SolarMutexGuard aGuard;
- uno::Sequence< OUString > aRes(1);
- aRes.getArray()[0] = "com.sun.star.chart2.data.DataSource";
- return aRes;
+ return { "com.sun.star.chart2.data.DataSource" };
}
SwChartDataSequence::SwChartDataSequence(
@@ -2301,10 +2295,7 @@ sal_Bool SAL_CALL SwChartDataSequence::supportsService(const OUString& rServiceN
uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getSupportedServiceNames( )
throw (uno::RuntimeException, std::exception)
{
- SolarMutexGuard aGuard;
- uno::Sequence< OUString > aRes(1);
- aRes.getArray()[0] = "com.sun.star.chart2.data.DataSequence";
- return aRes;
+ return { "com.sun.star.chart2.data.DataSequence" };
}
void SwChartDataSequence::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
@@ -2798,11 +2789,7 @@ sal_Bool SAL_CALL SwChartLabeledDataSequence::supportsService(
uno::Sequence< OUString > SAL_CALL SwChartLabeledDataSequence::getSupportedServiceNames( )
throw (uno::RuntimeException, std::exception)
{
- SolarMutexGuard aGuard;
- uno::Sequence< OUString > aRes(1);
- aRes.getArray()[0] = "com.sun.star.chart2.data.LabeledDataSequence";
-
- return aRes;
+ return { "com.sun.star.chart2.data.LabeledDataSequence" };
}
void SAL_CALL SwChartLabeledDataSequence::disposing(
commit 1ad4751b7b687a8e6127c1ae99af47a7bc763e84
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 12:55:31 2015 +0200
now use GetAny() here
Change-Id: I23b6f2c53841a4f105d911d72c4d7fe1c077ed82
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 11c32ac..ceb9602 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2009,34 +2009,6 @@ sal_Int64 SAL_CALL SwChartDataSequence::getSomething( const uno::Sequence< sal_I
return 0;
}
-uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData()
- throw (uno::RuntimeException, std::exception)
-{
- SolarMutexGuard aGuard;
- if (bDisposed)
- throw lang::DisposedException();
-
- SwFrameFormat* pTableFormat = GetFrameFormat();
- if(!pTableFormat)
- return {};
- SwTable* pTable = SwTable::FindTable(pTableFormat);
- if(pTable->IsTableComplex())
- return {};
- SwRangeDescriptor aDesc;
- if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat,*pTableCrsr)))
- return {};
- auto vData(SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getDataArray());
- if(!vData.getLength())
- return {};
- std::vector< uno::Any > vResult;
- vResult.reserve(vData.getLength()*vData[0].getLength());
- for(auto& rRow : vData)
- std::copy(
- rRow.begin(),
- rRow.end(),
- std::back_inserter(vResult));
- return comphelper::containerToSequence(vResult);
-}
OUString SAL_CALL SwChartDataSequence::getSourceRangeRepresentation( )
throw (uno::RuntimeException, std::exception)
@@ -2199,6 +2171,20 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
return vTextData;
}
+uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ auto vCells(getCells());
+ uno::Sequence< uno::Any > vAnyData(vCells.size());
+ std::transform(vCells.begin(),
+ vCells.end(),
+ vAnyData.begin(),
+ [] (decltype(vCells)::value_type& xCell)
+ { return static_cast<SwXCell*>(xCell.get())->GetAny(); });
+ return vAnyData;
+}
+
uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData()
throw (uno::RuntimeException, std::exception)
{
commit f7d603a7af180a47721c95db5631d08ab9738769
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 12:49:34 2015 +0200
refactor out SwXCell:GetAny()
Change-Id: Ia79bb08fb77bda3de6714b160df7007218ab309a
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 23c2116..94fb3bd 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -155,6 +155,7 @@ public:
SwTableBox* FindBox(SwTable* pTable, SwTableBox* pBox);
SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
double GetForcedNumericalValue() const;
+ css::uno::Any GetAny() const;
};
class SwXTextTableRow SAL_FINAL : public cppu::WeakImplHelper
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index b3e404b..1b5616d 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1220,6 +1220,17 @@ double SwXCell::GetForcedNumericalValue() const
return fTmp;
}
+uno::Any SwXCell::GetAny() const
+{
+ SwTableBox* GetTableBox();
+ if(!pBox)
+ throw uno::RuntimeException();
+ // check if table box value item is set
+ auto pBoxFormat(pBox->GetFrameFormat());
+ const bool bIsNum = pBoxFormat->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
+ return bIsNum ? uno::makeAny(getValue()) : uno::makeAny(const_cast<SwXCell*>(this)->getString());
+}
+
OUString SwXCell::getImplementationName() throw( uno::RuntimeException, std::exception )
{ return OUString("SwXCell"); }
@@ -3509,13 +3520,9 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
for(auto& rCellAny : rRow)
{
auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
- SwTableBox* pBox = pCell ? pCell->GetTableBox() : nullptr;
- if(!pBox)
+ if(!pCell)
throw uno::RuntimeException();
- // check if table box value item is set
- SwFrameFormat* pBoxFormat(pBox->GetFrameFormat());
- const bool bIsNum = pBoxFormat->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
- rCellAny = bIsNum ? uno::makeAny(pCell->getValue()) : uno::makeAny(pCell->getString());
+ rCellAny = pCell->GetAny();
++pCurrentCell;
}
}
commit a54845ee5d1f9258a422e378a39dac18cc975447
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 12:30:15 2015 +0200
refactor out getCells() in for chart seqs too
Change-Id: I1d18f1b7bdda8d95c2d2dd4256ca05aa0c60d5f4
diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx
index 4bfd2e0..580368a 100644
--- a/sw/inc/unochart.hxx
+++ b/sw/inc/unochart.hxx
@@ -40,6 +40,7 @@
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/util/XModifyListener.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/table/XCell.hpp>
#include <cppuhelper/interfacecontainer.h>
#include <cppuhelper/implbase.hxx>
@@ -349,6 +350,7 @@ public:
void FillRangeDesc( SwRangeDescriptor &rRangeDesc ) const;
bool ExtendTo( bool bExtendCol, sal_Int32 nFirstNew, sal_Int32 nCount );
+ std::vector< css::uno::Reference< css::table::XCell > > getCells();
};
typedef cppu::WeakImplHelper
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index a68bc98..11c32ac 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2169,22 +2169,27 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::generateLabel(
return 0;
}
-uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
- throw (uno::RuntimeException, std::exception)
+std::vector< css::uno::Reference< css::table::XCell > > SwChartDataSequence::getCells()
{
- SolarMutexGuard aGuard;
if (bDisposed)
throw lang::DisposedException();
- SwFrameFormat* pTableFormat = GetFrameFormat();
+ auto pTableFormat(GetFrameFormat());
if(!pTableFormat)
return {};
- SwTable* pTable = SwTable::FindTable(pTableFormat);
+ auto pTable(SwTable::FindTable(pTableFormat));
if(pTable->IsTableComplex())
return {};
SwRangeDescriptor aDesc;
if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat, *pTableCrsr)))
return {};
- auto vCells(SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getCells());
+ return SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getCells();
+}
+
+uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
+ throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aGuard;
+ auto vCells(getCells());
uno::Sequence< OUString > vTextData(vCells.size());
std::transform(vCells.begin(),
vCells.end(),
@@ -2198,18 +2203,7 @@ uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData()
throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
- if (bDisposed)
- throw lang::DisposedException();
- SwFrameFormat* pTableFormat = GetFrameFormat();
- if(!pTableFormat)
- return {};
- SwTable* pTable = SwTable::FindTable(pTableFormat);
- if(pTable->IsTableComplex())
- return {};
- SwRangeDescriptor aDesc;
- if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat,*pTableCrsr)))
- return {};
- auto vCells(SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getCells());
+ auto vCells(getCells());
uno::Sequence< double > vNumData(vCells.size());
std::transform(vCells.begin(),
vCells.end(),
commit 9ee481cce4f26cbde09efa46bc0b2c52e53eb2bf
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 12:15:15 2015 +0200
kill ugly GetDataSequence, now unused
Change-Id: Ib72d52c8641b9edfbc534a490fc27d20ff17f349
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index c4820ce..23c2116 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -543,14 +543,6 @@ public:
sal_uInt16 getColumnCount();
const SwUnoCrsr* GetTableCrsr() const;
-
- // for SwChartDataSequence
- void GetDataSequence(
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > *pAnySeq,
- ::com::sun::star::uno::Sequence< OUString > *pTextSeq,
- ::com::sun::star::uno::Sequence< double > *pDblSeq,
- bool bForceNumberResults = false ) throw (::com::sun::star::uno::RuntimeException, std::exception);
-
};
class SwXTableRows SAL_FINAL : public cppu::WeakImplHelper
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index d1c69e1..b3e404b 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3490,75 +3490,7 @@ void SwXCellRange::addVetoableChangeListener(const OUString& /*PropertyName*/, c
void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
{ throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
-void SwXCellRange::GetDataSequence(
- uno::Sequence< uno::Any > *pAnySeq, //-> first pointer != 0 is used
- uno::Sequence< OUString > *pTextSeq, //-> as output sequence
- uno::Sequence< double > *pDblSeq, //-> (previous data gets overwritten)
- bool bForceNumberResults ) //-> when 'true' requires to make an
- // extra effort to return a value different
- // from 0 even if the cell is formatted to text
- throw (uno::RuntimeException, std::exception)
-{
- SolarMutexGuard aGuard;
-
- // compare to SwXCellRange::getDataArray (note different return types though)
-
- const sal_Int32 nRowCount = getRowCount();
- const sal_Int32 nColCount = getColumnCount();
-
- if(!nRowCount || !nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
-
- const size_t nSize = static_cast<size_t>(nRowCount) * static_cast<size_t>(nColCount);
- OUString* pTextData(nullptr);
- if (pAnySeq || pDblSeq)
- {
- assert(false);
- }
- else if (pTextSeq)
- {
- pTextSeq->realloc(nSize);
- pTextData = pTextSeq->getArray();
- }
- else
- {
- OSL_FAIL( "argument missing" );
- return;
- }
-
- size_t nDtaCnt = 0;
- SwFrameFormat* pFormat = GetFrameFormat();
- if(!pFormat)
- return;
- double fNan;
- ::rtl::math::setNan(&fNan);
-
- uno::Reference< table::XCell > xCellRef;
- for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
- {
- for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
- {
- SwXCell * pXCell = lcl_CreateXCell(pFormat,
- aRgDesc.nLeft + nCol,
- aRgDesc.nTop + nRow);
- //! keep (additional) reference to object to prevent implicit destruction
- //! in following UNO calls (when object will get referenced)
- xCellRef = pXCell;
- SwTableBox * pBox = pXCell ? pXCell->GetTableBox() : 0;
- if(!pBox)
- throw uno::RuntimeException();
- pTextData[nDtaCnt++] = pXCell->getString();
- }
- }
- assert(nDtaCnt == nSize);
-}
-
///@see SwXCellRange::getData
-///@see SwXCellRange::GetDataSequence
uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
throw (uno::RuntimeException, std::exception)
{
commit 91dd43a4eaa6bd6434e538dee1a485842fbcbb4f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 12:10:32 2015 +0200
refactor getTextualData
Change-Id: I122a4fb8526af0c3c40e6a6cdacaa11fe531e15f
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 9f5472a..a68bc98 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2175,23 +2175,23 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
SolarMutexGuard aGuard;
if (bDisposed)
throw lang::DisposedException();
-
- uno::Sequence< OUString > aRes;
SwFrameFormat* pTableFormat = GetFrameFormat();
- if(pTableFormat)
- {
- SwTable* pTable = SwTable::FindTable( pTableFormat );
- if(!pTable->IsTableComplex())
- {
- SwRangeDescriptor aDesc;
- if (FillRangeDescriptor( aDesc, GetCellRangeName( *pTableFormat, *pTableCrsr ) ))
- {
- SwXCellRange aRange(pTableCrsr, *pTableFormat, aDesc );
- aRange.GetDataSequence( 0, &aRes, 0 );
- }
- }
- }
- return aRes;
+ if(!pTableFormat)
+ return {};
+ SwTable* pTable = SwTable::FindTable(pTableFormat);
+ if(pTable->IsTableComplex())
+ return {};
+ SwRangeDescriptor aDesc;
+ if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat, *pTableCrsr)))
+ return {};
+ auto vCells(SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getCells());
+ uno::Sequence< OUString > vTextData(vCells.size());
+ std::transform(vCells.begin(),
+ vCells.end(),
+ vTextData.begin(),
+ [] (decltype(vCells)::value_type& xCell)
+ { return static_cast<SwXCell*>(xCell.get())->getString(); });
+ return vTextData;
}
uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData()
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 32cfa1d..d1c69e1 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -682,12 +682,6 @@ static void lcl_SetTableSeparators(const uno::Any& rVal, SwTable* pTable, SwTabl
pDoc->SetTabCols(*pTable, aCols, aOldCols, pBox, bRow );
}
-static inline OUString lcl_getString( SwXCell &rCell )
-{
- // getString is a member function of the base class...
- return rCell.getString();
-}
-
/* non UNO function call to set string in SwXCell */
void sw_setString( SwXCell &rCell, const OUString &rText,
bool bKeepNumberFormat = false )
@@ -3557,7 +3551,7 @@ void SwXCellRange::GetDataSequence(
SwTableBox * pBox = pXCell ? pXCell->GetTableBox() : 0;
if(!pBox)
throw uno::RuntimeException();
- pTextData[nDtaCnt++] = lcl_getString(*pXCell);
+ pTextData[nDtaCnt++] = pXCell->getString();
}
}
assert(nDtaCnt == nSize);
@@ -3589,7 +3583,7 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
// check if table box value item is set
SwFrameFormat* pBoxFormat(pBox->GetFrameFormat());
const bool bIsNum = pBoxFormat->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
- rCellAny = bIsNum ? uno::makeAny(pCell->getValue()) : uno::makeAny(lcl_getString(*pCell));
+ rCellAny = bIsNum ? uno::makeAny(pCell->getValue()) : uno::makeAny(pCell->getString());
++pCurrentCell;
}
}
commit f828df4cad83760e2f722ec4b5e6e910c85f6598
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 11:55:38 2015 +0200
refactor getNumericalData,
- move some functions to be members, were sensible
Change-Id: Ie94029f215102c62e96d314809ca78b079f2a6e6
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index 9a1d41c..c4820ce 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -67,7 +67,6 @@ class SwXCell SAL_FINAL : public SwXCellBaseClass,
{
friend void sw_setString( SwXCell &rCell, const OUString &rText,
bool bKeepNumberFormat );
- friend double sw_getValue( SwXCell &rCell );
friend void sw_setValue( SwXCell &rCell, double nVal );
const SfxItemPropertySet* m_pPropSet;
@@ -117,8 +116,12 @@ public:
virtual OUString SAL_CALL getFormula( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setFormula( const OUString& aFormula ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual double SAL_CALL getValue( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual double SAL_CALL getValue( ) const throw(::com::sun::star::uno::RuntimeException, std::exception)
+ { return const_cast<SwXCell*>(this)->getValue(); };
virtual void SAL_CALL setValue( double nValue ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual ::com::sun::star::table::CellContentType SAL_CALL getType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual ::com::sun::star::table::CellContentType SAL_CALL getType( ) const throw(::com::sun::star::uno::RuntimeException, std::exception)
+ { return const_cast<SwXCell*>(this)->getType(); };
virtual sal_Int32 SAL_CALL getError( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
//XText
@@ -147,11 +150,11 @@ public:
virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- SwTableBox* GetTableBox()const {return pBox;}
- static SwXCell* CreateXCell(SwFrameFormat* pTableFormat, SwTableBox* pBox, SwTable *pTable = 0 );
- SwTableBox* FindBox(SwTable* pTable, SwTableBox* pBox);
-
+ SwTableBox* GetTableBox() const { return pBox; }
+ static SwXCell* CreateXCell(SwFrameFormat* pTableFormat, SwTableBox* pBox, SwTable *pTable = nullptr );
+ SwTableBox* FindBox(SwTable* pTable, SwTableBox* pBox);
SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
+ double GetForcedNumericalValue() const;
};
class SwXTextTableRow SAL_FINAL : public cppu::WeakImplHelper
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index 9245689..9f5472a 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2200,26 +2200,23 @@ uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData()
SolarMutexGuard aGuard;
if (bDisposed)
throw lang::DisposedException();
-
- uno::Sequence< double > aRes;
SwFrameFormat* pTableFormat = GetFrameFormat();
- if(pTableFormat)
- {
- SwTable* pTable = SwTable::FindTable( pTableFormat );
- if(!pTable->IsTableComplex())
- {
- SwRangeDescriptor aDesc;
- if (FillRangeDescriptor( aDesc, GetCellRangeName( *pTableFormat, *pTableCrsr ) ))
- {
- SwXCellRange aRange(pTableCrsr, *pTableFormat, aDesc );
-
- // get numerical values and make an effort to return the
- // numerical value for text formatted cells
- aRange.GetDataSequence( 0, 0, &aRes, true );
- }
- }
- }
- return aRes;
+ if(!pTableFormat)
+ return {};
+ SwTable* pTable = SwTable::FindTable(pTableFormat);
+ if(pTable->IsTableComplex())
+ return {};
+ SwRangeDescriptor aDesc;
+ if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat,*pTableCrsr)))
+ return {};
+ auto vCells(SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getCells());
+ uno::Sequence< double > vNumData(vCells.size());
+ std::transform(vCells.begin(),
+ vCells.end(),
+ vNumData.begin(),
+ [] (decltype(vCells)::value_type& xCell)
+ { return static_cast<SwXCell*>(xCell.get())->GetForcedNumericalValue(); });
+ return vNumData;
}
uno::Reference< util::XCloneable > SAL_CALL SwChartDataSequence::createClone( )
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index f178a59..32cfa1d 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -705,16 +705,6 @@ void sw_setString( SwXCell &rCell, const OUString &rText,
rCell.SwXText::setString(rText);
}
-/* non UNO function call to get value from SwXCell */
-double sw_getValue( SwXCell &rCell )
-{
- double fRet;
- if(rCell.IsValid() && !rCell.getString().isEmpty())
- fRet = rCell.pBox->GetFrameFormat()->GetTableBoxValue().GetValue();
- else
- ::rtl::math::setNan( &fRet );
- return fRet;
-}
/* non UNO function call to set value in SwXCell */
void sw_setValue( SwXCell &rCell, double nVal )
@@ -921,7 +911,12 @@ double SwXCell::getValue() throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
// #i112652# a table cell may contain NaN as a value, do not filter that
- return sw_getValue( *this );
+ double fRet;
+ if(IsValid() && !getString().isEmpty())
+ fRet = pBox->GetFrameFormat()->GetTableBoxValue().GetValue();
+ else
+ ::rtl::math::setNan( &fRet );
+ return fRet;
}
void SwXCell::setValue(double rValue) throw( uno::RuntimeException, std::exception )
@@ -1190,6 +1185,47 @@ SwTableBox* SwXCell::FindBox(SwTable* pTable, SwTableBox* pBox2)
return nullptr;
}
+double SwXCell::GetForcedNumericalValue() const
+{
+ if(table::CellContentType_TEXT != getType())
+ return getValue();
+ // now we'll try to get a useful numerical value
+ // from the text in the cell...
+ sal_uInt32 nFIndex;
+ SvNumberFormatter* pNumFormatter(const_cast<SvNumberFormatter*>(GetDoc()->GetNumberFormatter()));
+ // look for SwTableBoxNumFormat value in parents as well
+ const SfxPoolItem* pItem;
+ auto pBoxFormat(GetTableBox()->GetFrameFormat());
+ SfxItemState eState = pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
+
+ if (eState == SfxItemState::SET)
+ {
+ // please note that the language of the numberformat
+ // is implicitly coded into the below value as well
+ nFIndex = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
+
+ // since the current value indicates a text format but the call
+ // to 'IsNumberFormat' below won't work for text formats
+ // we need to get rid of the part that indicates the text format.
+ // According to ER this can be done like this:
+ nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
+ }
+ else
+ {
+ // system language is probably not the best possible choice
+ // but since we have to guess anyway (because the language of at
+ // the text is NOT the one used for the number format!)
+ // it is at least conform to what is used in
+ // SwTableShell::Execute when
+ // SID_ATTR_NUMBERFORMAT_VALUE is set...
+ LanguageType eLang = LANGUAGE_SYSTEM;
+ nFIndex = pNumFormatter->GetStandardIndex( eLang );
+ }
+ double fTmp;
+ pNumFormatter->IsNumberFormat(const_cast<SwXCell*>(this)->getString(), nFIndex, fTmp);
+ return fTmp;
+}
+
OUString SwXCell::getImplementationName() throw( uno::RuntimeException, std::exception )
{ return OUString("SwXCell"); }
@@ -3485,8 +3521,7 @@ void SwXCellRange::GetDataSequence(
const size_t nSize = static_cast<size_t>(nRowCount) * static_cast<size_t>(nColCount);
OUString* pTextData(nullptr);
- double* pDblData(nullptr);
- if (pAnySeq)
+ if (pAnySeq || pDblSeq)
{
assert(false);
}
@@ -3495,11 +3530,6 @@ void SwXCellRange::GetDataSequence(
pTextSeq->realloc(nSize);
pTextData = pTextSeq->getArray();
}
- else if (pDblSeq)
- {
- pDblSeq->realloc(nSize);
- pDblData = pDblSeq->getArray();
- }
else
{
OSL_FAIL( "argument missing" );
@@ -3527,59 +3557,7 @@ void SwXCellRange::GetDataSequence(
SwTableBox * pBox = pXCell ? pXCell->GetTableBox() : 0;
if(!pBox)
throw uno::RuntimeException();
- if (pTextData)
- pTextData[nDtaCnt++] = lcl_getString(*pXCell);
- else
- {
- double fVal = fNan;
- if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
- fVal = sw_getValue(*pXCell);
- else
- {
- OSL_ENSURE( table::CellContentType_TEXT == pXCell->getType(),
- "this branch of 'if' is only for text formatted cells" );
-
- // now we'll try to get a useful numerical value
- // from the text in the cell...
-
- sal_uInt32 nFIndex;
- SvNumberFormatter* pNumFormatter = m_pTableCrsr->GetDoc()->GetNumberFormatter();
-
- // look for SwTableBoxNumFormat value in parents as well
- const SfxPoolItem* pItem;
- SwFrameFormat *pBoxFormat = pXCell->GetTableBox()->GetFrameFormat();
- SfxItemState eState = pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
-
- if (eState == SfxItemState::SET)
- {
- // please note that the language of the numberformat
- // is implicitly coded into the below value as well
- nFIndex = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
-
- // since the current value indicates a text format but the call
- // to 'IsNumberFormat' below won't work for text formats
- // we need to get rid of the part that indicates the text format.
- // According to ER this can be done like this:
- nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
- }
- else
- {
- // system language is probably not the best possible choice
- // but since we have to guess anyway (because the language of at
- // the text is NOT the one used for the number format!)
- // it is at least conform to what is used in
- // SwTableShell::Execute when
- // SID_ATTR_NUMBERFORMAT_VALUE is set...
- LanguageType eLang = LANGUAGE_SYSTEM;
- nFIndex = pNumFormatter->GetStandardIndex( eLang );
- }
-
- double fTmp;
- if (pNumFormatter->IsNumberFormat( lcl_getString(*pXCell), nFIndex, fTmp ))
- fVal = fTmp;
- }
- pDblData[nDtaCnt++] = fVal;
- }
+ pTextData[nDtaCnt++] = lcl_getString(*pXCell);
}
}
assert(nDtaCnt == nSize);
@@ -3611,7 +3589,7 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray()
// check if table box value item is set
SwFrameFormat* pBoxFormat(pBox->GetFrameFormat());
const bool bIsNum = pBoxFormat->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
- rCellAny = bIsNum ? uno::makeAny(sw_getValue(*pCell)) : uno::makeAny(lcl_getString(*pCell));
+ rCellAny = bIsNum ? uno::makeAny(pCell->getValue()) : uno::makeAny(lcl_getString(*pCell));
++pCurrentCell;
}
}
commit 0685f902927a263fb724e47731654169dc87a3a6
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 09:32:05 2015 +0200
remove one client of getDataSequence
Change-Id: Iec8c3653497e213c085242085737dcc5985d70b3
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index afa0dda6..9245689 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/chart2/data/LabelOrigin.hpp>
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
#include <svl/zforlist.hxx>
@@ -2015,22 +2016,26 @@ uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData()
if (bDisposed)
throw lang::DisposedException();
- uno::Sequence< uno::Any > aRes;
SwFrameFormat* pTableFormat = GetFrameFormat();
- if(pTableFormat)
- {
- SwTable* pTable = SwTable::FindTable( pTableFormat );
- if(!pTable->IsTableComplex())
- {
- SwRangeDescriptor aDesc;
- if (FillRangeDescriptor( aDesc, GetCellRangeName( *pTableFormat, *pTableCrsr ) ))
- {
- SwXCellRange aRange(pTableCrsr, *pTableFormat, aDesc );
- aRange.GetDataSequence( &aRes, 0, 0 );
- }
- }
- }
- return aRes;
+ if(!pTableFormat)
+ return {};
+ SwTable* pTable = SwTable::FindTable(pTableFormat);
+ if(pTable->IsTableComplex())
+ return {};
+ SwRangeDescriptor aDesc;
+ if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat,*pTableCrsr)))
+ return {};
+ auto vData(SwXCellRange(pTableCrsr, *pTableFormat, aDesc).getDataArray());
+ if(!vData.getLength())
+ return {};
+ std::vector< uno::Any > vResult;
+ vResult.reserve(vData.getLength()*vData[0].getLength());
+ for(auto& rRow : vData)
+ std::copy(
+ rRow.begin(),
+ rRow.end(),
+ std::back_inserter(vResult));
+ return comphelper::containerToSequence(vResult);
}
OUString SAL_CALL SwChartDataSequence::getSourceRangeRepresentation( )
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 4c5436e..f178a59 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3484,13 +3484,11 @@ void SwXCellRange::GetDataSequence(
}
const size_t nSize = static_cast<size_t>(nRowCount) * static_cast<size_t>(nColCount);
- uno::Any* pAnyData(nullptr);
OUString* pTextData(nullptr);
double* pDblData(nullptr);
if (pAnySeq)
{
- pAnySeq->realloc(nSize);
- pAnyData = pAnySeq->getArray();
+ assert(false);
}
else if (pTextSeq)
{
@@ -3529,16 +3527,7 @@ void SwXCellRange::GetDataSequence(
SwTableBox * pBox = pXCell ? pXCell->GetTableBox() : 0;
if(!pBox)
throw uno::RuntimeException();
- if (pAnyData)
- {
- // check if table box value item is set
- bool bIsNum = pBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET;
- if (!bIsNum)
- pAnyData[nDtaCnt++] <<= lcl_getString(*pXCell);
- else
- pAnyData[nDtaCnt++] <<= sw_getValue(*pXCell);
- }
- else if (pTextData)
+ if (pTextData)
pTextData[nDtaCnt++] = lcl_getString(*pXCell);
else
{
commit 9437369a4b08bdb8fd2aed514606ccc3a73c7dae
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 08:17:52 2015 +0200
simplify
Change-Id: Icaf94870906ba2723de727d06037c343f26e87b8
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index c83083b..4c5436e 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3510,87 +3510,86 @@ void SwXCellRange::GetDataSequence(
size_t nDtaCnt = 0;
SwFrameFormat* pFormat = GetFrameFormat();
- if(pFormat)
- {
- double fNan;
- ::rtl::math::setNan( & fNan );
+ if(!pFormat)
+ return;
+ double fNan;
+ ::rtl::math::setNan(&fNan);
- uno::Reference< table::XCell > xCellRef;
- for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
+ uno::Reference< table::XCell > xCellRef;
+ for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
+ {
+ for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
{
- for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
+ SwXCell * pXCell = lcl_CreateXCell(pFormat,
+ aRgDesc.nLeft + nCol,
+ aRgDesc.nTop + nRow);
+ //! keep (additional) reference to object to prevent implicit destruction
+ //! in following UNO calls (when object will get referenced)
+ xCellRef = pXCell;
+ SwTableBox * pBox = pXCell ? pXCell->GetTableBox() : 0;
+ if(!pBox)
+ throw uno::RuntimeException();
+ if (pAnyData)
{
- SwXCell * pXCell = lcl_CreateXCell(pFormat,
- aRgDesc.nLeft + nCol,
- aRgDesc.nTop + nRow);
- //! keep (additional) reference to object to prevent implicit destruction
- //! in following UNO calls (when object will get referenced)
- xCellRef = pXCell;
- SwTableBox * pBox = pXCell ? pXCell->GetTableBox() : 0;
- if(!pBox)
- throw uno::RuntimeException();
- if (pAnyData)
- {
- // check if table box value item is set
- bool bIsNum = pBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET;
- if (!bIsNum)
- pAnyData[nDtaCnt++] <<= lcl_getString(*pXCell);
- else
- pAnyData[nDtaCnt++] <<= sw_getValue(*pXCell);
- }
- else if (pTextData)
- pTextData[nDtaCnt++] = lcl_getString(*pXCell);
+ // check if table box value item is set
+ bool bIsNum = pBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET;
+ if (!bIsNum)
+ pAnyData[nDtaCnt++] <<= lcl_getString(*pXCell);
+ else
+ pAnyData[nDtaCnt++] <<= sw_getValue(*pXCell);
+ }
+ else if (pTextData)
+ pTextData[nDtaCnt++] = lcl_getString(*pXCell);
+ else
+ {
+ double fVal = fNan;
+ if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
+ fVal = sw_getValue(*pXCell);
else
{
- double fVal = fNan;
- if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
- fVal = sw_getValue(*pXCell);
- else
- {
- OSL_ENSURE( table::CellContentType_TEXT == pXCell->getType(),
- "this branch of 'if' is only for text formatted cells" );
+ OSL_ENSURE( table::CellContentType_TEXT == pXCell->getType(),
+ "this branch of 'if' is only for text formatted cells" );
- // now we'll try to get a useful numerical value
- // from the text in the cell...
+ // now we'll try to get a useful numerical value
+ // from the text in the cell...
- sal_uInt32 nFIndex;
- SvNumberFormatter* pNumFormatter = m_pTableCrsr->GetDoc()->GetNumberFormatter();
+ sal_uInt32 nFIndex;
+ SvNumberFormatter* pNumFormatter = m_pTableCrsr->GetDoc()->GetNumberFormatter();
- // look for SwTableBoxNumFormat value in parents as well
- const SfxPoolItem* pItem;
- SwFrameFormat *pBoxFormat = pXCell->GetTableBox()->GetFrameFormat();
- SfxItemState eState = pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
-
- if (eState == SfxItemState::SET)
- {
- // please note that the language of the numberformat
- // is implicitly coded into the below value as well
- nFIndex = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
-
- // since the current value indicates a text format but the call
- // to 'IsNumberFormat' below won't work for text formats
- // we need to get rid of the part that indicates the text format.
- // According to ER this can be done like this:
- nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
- }
- else
- {
- // system language is probably not the best possible choice
- // but since we have to guess anyway (because the language of at
- // the text is NOT the one used for the number format!)
- // it is at least conform to what is used in
- // SwTableShell::Execute when
- // SID_ATTR_NUMBERFORMAT_VALUE is set...
- LanguageType eLang = LANGUAGE_SYSTEM;
- nFIndex = pNumFormatter->GetStandardIndex( eLang );
- }
+ // look for SwTableBoxNumFormat value in parents as well
+ const SfxPoolItem* pItem;
+ SwFrameFormat *pBoxFormat = pXCell->GetTableBox()->GetFrameFormat();
+ SfxItemState eState = pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
- double fTmp;
- if (pNumFormatter->IsNumberFormat( lcl_getString(*pXCell), nFIndex, fTmp ))
- fVal = fTmp;
+ if (eState == SfxItemState::SET)
+ {
+ // please note that the language of the numberformat
+ // is implicitly coded into the below value as well
+ nFIndex = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
+
+ // since the current value indicates a text format but the call
+ // to 'IsNumberFormat' below won't work for text formats
+ // we need to get rid of the part that indicates the text format.
+ // According to ER this can be done like this:
+ nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
}
- pDblData[nDtaCnt++] = fVal;
+ else
+ {
+ // system language is probably not the best possible choice
+ // but since we have to guess anyway (because the language of at
+ // the text is NOT the one used for the number format!)
+ // it is at least conform to what is used in
+ // SwTableShell::Execute when
+ // SID_ATTR_NUMBERFORMAT_VALUE is set...
+ LanguageType eLang = LANGUAGE_SYSTEM;
+ nFIndex = pNumFormatter->GetStandardIndex( eLang );
+ }
+
+ double fTmp;
+ if (pNumFormatter->IsNumberFormat( lcl_getString(*pXCell), nFIndex, fTmp ))
+ fVal = fTmp;
}
+ pDblData[nDtaCnt++] = fVal;
}
}
}
commit f98a687f1554ad7c6f4c16184086ad7b8ee4276d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 08:11:59 2015 +0200
remove dead code
Change-Id: If60fd90f1ffb8a58cc43e4c4a0f80f68b7511937
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 113d6b6..c83083b 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3540,7 +3540,7 @@ void SwXCellRange::GetDataSequence(
}
else if (pTextData)
pTextData[nDtaCnt++] = lcl_getString(*pXCell);
- else if (pDblData)
+ else
{
double fVal = fNan;
if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
@@ -3591,9 +3591,6 @@ void SwXCellRange::GetDataSequence(
}
pDblData[nDtaCnt++] = fVal;
}
- else {
- OSL_FAIL( "output sequence missing" );
- }
}
}
}
commit 57ac4a57d772546089332a1f302a4b1d8dac6961
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 08:11:12 2015 +0200
simplify
Change-Id: Ie9313bd8bb391d33e5f86fb86e0874b85594fedf
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 2558560..113d6b6 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3528,76 +3528,71 @@ void SwXCellRange::GetDataSequence(
xCellRef = pXCell;
SwTableBox * pBox = pXCell ? pXCell->GetTableBox() : 0;
if(!pBox)
- {
throw uno::RuntimeException();
+ if (pAnyData)
+ {
+ // check if table box value item is set
+ bool bIsNum = pBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET;
+ if (!bIsNum)
+ pAnyData[nDtaCnt++] <<= lcl_getString(*pXCell);
+ else
+ pAnyData[nDtaCnt++] <<= sw_getValue(*pXCell);
}
- else
+ else if (pTextData)
+ pTextData[nDtaCnt++] = lcl_getString(*pXCell);
+ else if (pDblData)
{
- if (pAnyData)
- {
- // check if table box value item is set
- bool bIsNum = pBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET;
- if (!bIsNum)
- pAnyData[nDtaCnt++] <<= lcl_getString(*pXCell);
- else
- pAnyData[nDtaCnt++] <<= sw_getValue(*pXCell);
- }
- else if (pTextData)
- pTextData[nDtaCnt++] = lcl_getString(*pXCell);
- else if (pDblData)
+ double fVal = fNan;
+ if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
+ fVal = sw_getValue(*pXCell);
+ else
{
- double fVal = fNan;
- if (!bForceNumberResults || table::CellContentType_TEXT != pXCell->getType())
- fVal = sw_getValue(*pXCell);
- else
- {
- OSL_ENSURE( table::CellContentType_TEXT == pXCell->getType(),
- "this branch of 'if' is only for text formatted cells" );
+ OSL_ENSURE( table::CellContentType_TEXT == pXCell->getType(),
+ "this branch of 'if' is only for text formatted cells" );
- // now we'll try to get a useful numerical value
- // from the text in the cell...
+ // now we'll try to get a useful numerical value
+ // from the text in the cell...
- sal_uInt32 nFIndex;
- SvNumberFormatter* pNumFormatter = m_pTableCrsr->GetDoc()->GetNumberFormatter();
+ sal_uInt32 nFIndex;
+ SvNumberFormatter* pNumFormatter = m_pTableCrsr->GetDoc()->GetNumberFormatter();
- // look for SwTableBoxNumFormat value in parents as well
- const SfxPoolItem* pItem;
- SwFrameFormat *pBoxFormat = pXCell->GetTableBox()->GetFrameFormat();
- SfxItemState eState = pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
+ // look for SwTableBoxNumFormat value in parents as well
+ const SfxPoolItem* pItem;
+ SwFrameFormat *pBoxFormat = pXCell->GetTableBox()->GetFrameFormat();
+ SfxItemState eState = pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
- if (eState == SfxItemState::SET)
- {
- // please note that the language of the numberformat
- // is implicitly coded into the below value as well
- nFIndex = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
-
- // since the current value indicates a text format but the call
- // to 'IsNumberFormat' below won't work for text formats
- // we need to get rid of the part that indicates the text format.
- // According to ER this can be done like this:
- nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
- }
- else
- {
- // system language is probably not the best possible choice
- // but since we have to guess anyway (because the language of at
- // the text is NOT the one used for the number format!)
- // it is at least conform to what is used in
- // SwTableShell::Execute when
- // SID_ATTR_NUMBERFORMAT_VALUE is set...
- LanguageType eLang = LANGUAGE_SYSTEM;
- nFIndex = pNumFormatter->GetStandardIndex( eLang );
- }
-
- double fTmp;
- if (pNumFormatter->IsNumberFormat( lcl_getString(*pXCell), nFIndex, fTmp ))
- fVal = fTmp;
+ if (eState == SfxItemState::SET)
+ {
+ // please note that the language of the numberformat
+ // is implicitly coded into the below value as well
+ nFIndex = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
+
+ // since the current value indicates a text format but the call
+ // to 'IsNumberFormat' below won't work for text formats
+ // we need to get rid of the part that indicates the text format.
+ // According to ER this can be done like this:
+ nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
}
- pDblData[nDtaCnt++] = fVal;
- }
- else {
- OSL_FAIL( "output sequence missing" );
+ else
+ {
+ // system language is probably not the best possible choice
+ // but since we have to guess anyway (because the language of at
+ // the text is NOT the one used for the number format!)
+ // it is at least conform to what is used in
+ // SwTableShell::Execute when
+ // SID_ATTR_NUMBERFORMAT_VALUE is set...
+ LanguageType eLang = LANGUAGE_SYSTEM;
+ nFIndex = pNumFormatter->GetStandardIndex( eLang );
+ }
+
+ double fTmp;
+ if (pNumFormatter->IsNumberFormat( lcl_getString(*pXCell), nFIndex, fTmp ))
+ fVal = fTmp;
}
+ pDblData[nDtaCnt++] = fVal;
+ }
+ else {
+ OSL_FAIL( "output sequence missing" );
}
}
}
commit 5ab8a7303e26b55b9b52f71a6a98a1f565ddefa5
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 07:55:26 2015 +0200
dont branch on the same conditional twice
Change-Id: Icda8e94140d56d71b568ac52feb303bcc861ea31
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index b255fab..2558560 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3484,20 +3484,29 @@ void SwXCellRange::GetDataSequence(
}
const size_t nSize = static_cast<size_t>(nRowCount) * static_cast<size_t>(nColCount);
+ uno::Any* pAnyData(nullptr);
+ OUString* pTextData(nullptr);
+ double* pDblData(nullptr);
if (pAnySeq)
- pAnySeq->realloc( nSize );
+ {
+ pAnySeq->realloc(nSize);
+ pAnyData = pAnySeq->getArray();
+ }
else if (pTextSeq)
- pTextSeq->realloc( nSize );
+ {
+ pTextSeq->realloc(nSize);
+ pTextData = pTextSeq->getArray();
+ }
else if (pDblSeq)
- pDblSeq->realloc( nSize );
+ {
+ pDblSeq->realloc(nSize);
+ pDblData = pDblSeq->getArray();
+ }
else
{
OSL_FAIL( "argument missing" );
return;
}
- uno::Any *pAnyData = pAnySeq ? pAnySeq->getArray() : 0;
- OUString *pTextData = pTextSeq ? pTextSeq->getArray() : 0;
- double *pDblData = pDblSeq ? pDblSeq->getArray() : 0;
size_t nDtaCnt = 0;
SwFrameFormat* pFormat = GetFrameFormat();
commit 0ae7f853ecdca838adbc369ccf4c0b862354ac86
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Jun 28 07:34:17 2015 +0200
should there be a size mismatch here, we already wrote out-of-bounds
Change-Id: I303e93635985fce53aaffc9af89cfa10cecadefb
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 68366e8..b255fab 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3593,13 +3593,7 @@ void SwXCellRange::GetDataSequence(
}
}
}
- OSL_ENSURE( nDtaCnt == nSize, "size mismatch. Invalid cell range?" );
- if (pAnySeq)
- pAnySeq->realloc( nDtaCnt );
- else if (pTextSeq)
- pTextSeq->realloc( nDtaCnt );
- else if (pDblSeq)
- pDblSeq->realloc( nDtaCnt );
+ assert(nDtaCnt == nSize);
}
///@see SwXCellRange::getData
More information about the Libreoffice-commits
mailing list