[Libreoffice-commits] core.git: 5 commits - compilerplugins/clang sc/inc sc/source vcl/source
Michael Stahl
mstahl at redhat.com
Fri Nov 6 11:54:43 PST 2015
compilerplugins/clang/badstatics.cxx | 59 ++++++++++++++--
sc/inc/chartlis.hxx | 10 +-
sc/inc/datauno.hxx | 3
sc/inc/detdata.hxx | 4 -
sc/inc/dpobject.hxx | 1
sc/inc/dpsave.hxx | 9 +-
sc/source/core/data/documen5.cxx | 5 -
sc/source/core/data/document.cxx | 5 -
sc/source/core/data/dpsave.cxx | 89 ++++++++++--------------
sc/source/core/tool/chartlis.cxx | 103 +++++++++++++++-------------
sc/source/filter/excel/xepivot.cxx | 9 +-
sc/source/filter/excel/xepivotxml.cxx | 2
sc/source/filter/xml/XMLExportDataPilot.cxx | 10 +-
sc/source/ui/unoobj/cellsuno.cxx | 5 -
sc/source/ui/unoobj/dapiuno.cxx | 17 +---
vcl/source/filter/wmf/winmtf.cxx | 10 +-
vcl/source/filter/wmf/winmtf.hxx | 2
17 files changed, 193 insertions(+), 150 deletions(-)
New commits:
commit 7d68b8e52f0571bccff9c53df2bb65c1c8aee744
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 6 17:52:52 2015 +0100
sc: replace boost::ptr_map with std::map<std::unique_ptr>
Change-Id: Ia2ac921664fd5b7336125a2f62bca932542b2286
diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index 64ff7c7..3bc0fb8 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -27,8 +27,8 @@
#include "token.hxx"
#include "externalrefmgr.hxx"
-#include <boost/ptr_container/ptr_map.hpp>
#include <memory>
+#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
@@ -127,10 +127,10 @@ public:
class SC_DLLPUBLIC ScChartListenerCollection
{
public:
- typedef boost::ptr_map<OUString, ScChartListener> ListenersType;
+ typedef std::map<OUString, std::unique_ptr<ScChartListener>> ListenersType;
typedef std::unordered_set<OUString, OUStringHash> StringSetType;
private:
- ListenersType maListeners;
+ ListenersType m_Listeners;
enum UpdateStatus
{
SC_CLCUPDATE_NONE,
@@ -164,8 +164,8 @@ public:
void removeByName(const OUString& rName);
- const ListenersType& getListeners() const { return maListeners;}
- ListenersType& getListeners() { return maListeners;}
+ const ListenersType& getListeners() const { return m_Listeners; }
+ ListenersType& getListeners() { return m_Listeners; }
StringSetType& getNonOleObjectNames() { return maNonOleObjectNames;}
/**
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index e7d554c..9345d20 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -487,10 +487,9 @@ void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode,
return;
ScChartListenerCollection::ListenersType& rListeners = pChartListenerCollection->getListeners();
- ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : rListeners)
{
- ScChartListener* pChartListener = it->second;
+ ScChartListener *const pChartListener = it.second.get();
ScRangeListRef aRLR( pChartListener->GetRangeList() );
ScRangeListRef aNewRLR( new ScRangeList );
bool bChanged = false;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 054dc9f..06d0fd7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3900,10 +3900,9 @@ void ScDocument::CalcAfterLoad( bool bStartListening )
if (pChartListenerCollection)
{
const ScChartListenerCollection::ListenersType& rListeners = pChartListenerCollection->getListeners();
- ScChartListenerCollection::ListenersType::const_iterator it = rListeners.begin(), itEnd = rListeners.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : rListeners)
{
- const ScChartListener* p = it->second;
+ const ScChartListener *const p = it.second.get();
InterpretDirtyCells(*p->GetRangeList());
}
}
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 5173a0f..d2e50bd 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -423,14 +423,15 @@ ScChartListenerCollection::~ScChartListenerCollection()
// ScChartListener::EndListeningTo may cause ScChartListenerCollection::StartTimer
// to be called if an empty ScNoteCell is deleted
- maListeners.clear();
+ m_Listeners.clear();
}
void ScChartListenerCollection::StartAllListeners()
{
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
- it->second->StartListeningTo();
+ for (auto const& it : m_Listeners)
+ {
+ it.second->StartListeningTo();
+ }
}
void ScChartListenerCollection::insert(ScChartListener* pListener)
@@ -438,31 +439,31 @@ void ScChartListenerCollection::insert(ScChartListener* pListener)
if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING)
meModifiedDuringUpdate = SC_CLCUPDATE_MODIFIED;
OUString aName = pListener->GetName();
- maListeners.insert(aName, pListener);
+ m_Listeners.insert(std::make_pair(aName, std::unique_ptr<ScChartListener>(pListener)));
}
void ScChartListenerCollection::removeByName(const OUString& rName)
{
if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING)
meModifiedDuringUpdate = SC_CLCUPDATE_MODIFIED;
- maListeners.erase(rName);
+ m_Listeners.erase(rName);
}
ScChartListener* ScChartListenerCollection::findByName(const OUString& rName)
{
- ListenersType::iterator it = maListeners.find(rName);
- return it == maListeners.end() ? nullptr : it->second;
+ ListenersType::iterator const it = m_Listeners.find(rName);
+ return it == m_Listeners.end() ? nullptr : it->second.get();
}
const ScChartListener* ScChartListenerCollection::findByName(const OUString& rName) const
{
- ListenersType::const_iterator it = maListeners.find(rName);
- return it == maListeners.end() ? nullptr : it->second;
+ ListenersType::const_iterator const it = m_Listeners.find(rName);
+ return it == m_Listeners.end() ? nullptr : it->second.get();
}
bool ScChartListenerCollection::hasListeners() const
{
- return !maListeners.empty();
+ return !m_Listeners.empty();
}
OUString ScChartListenerCollection::getUniqueName(const OUString& rPrefix) const
@@ -472,7 +473,7 @@ OUString ScChartListenerCollection::getUniqueName(const OUString& rPrefix) const
OUStringBuffer aBuf(rPrefix);
aBuf.append(nNum);
OUString aTestName = aBuf.makeStringAndClear();
- if (maListeners.find(aTestName) == maListeners.end())
+ if (m_Listeners.find(aTestName) == m_Listeners.end())
return aTestName;
}
return OUString();
@@ -509,7 +510,7 @@ public:
void operator() (ScChartListener* p)
{
OUString aName = p->GetName();
- mrListeners.insert(aName, p);
+ mrListeners.insert(std::make_pair(aName, std::unique_ptr<ScChartListener>(p)));
}
};
@@ -524,28 +525,33 @@ void ScChartListenerCollection::FreeUnused()
// First, filter each listener into 'used' and 'unused' categories.
{
- while(!maListeners.empty())
+ while (!m_Listeners.empty())
{
- ScChartListener* p = maListeners.begin()->second;
+ std::unique_ptr<ScChartListener> p(std::move(m_Listeners.begin()->second));
if (p->IsUno())
{
// We don't delete UNO charts; they are to be deleted separately via FreeUno().
- aUsed.transfer(maListeners.begin(), maListeners);
+ aUsed.insert(std::make_pair(m_Listeners.begin()->first, std::move(p)));
+ m_Listeners.erase(m_Listeners.begin());
continue;
}
if (p->IsUsed())
{
p->SetUsed(false);
- aUsed.transfer(maListeners.begin(), maListeners);
+ aUsed.insert(std::make_pair(m_Listeners.begin()->first, std::move(p)));
+ m_Listeners.erase(m_Listeners.begin());
}
else
- aUnused.transfer(maListeners.begin(), maListeners);
+ {
+ aUnused.insert(std::make_pair(m_Listeners.begin()->first, std::move(p)));
+ m_Listeners.erase(m_Listeners.begin());
+ }
}
}
- std::swap(aUsed, maListeners);
+ std::swap(aUsed, m_Listeners);
}
void ScChartListenerCollection::FreeUno( const uno::Reference< chart::XChartDataChangeEventListener >& rListener,
@@ -558,10 +564,9 @@ void ScChartListenerCollection::FreeUno( const uno::Reference< chart::XChartData
// First, filter each listener into 'used' and 'unused' categories.
{
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : m_Listeners)
{
- ScChartListener* p = it->second;
+ ScChartListener *const p = it.second.get();
if (p->IsUno() && p->GetUnoListener() == rListener && p->GetUnoSource() == rSource)
aUnused.push_back(p);
else
@@ -571,10 +576,14 @@ void ScChartListenerCollection::FreeUno( const uno::Reference< chart::XChartData
// Release all pointers currently managed by the ptr_map container.
// coverity[leaked_storage] - no leak, because because we will take care of them below
- maListeners.release().release();
+ for (auto & it : m_Listeners)
+ {
+ it.second.release();
+ }
+ m_Listeners.clear();
// Re-insert the listeners we need to keep.
- std::for_each(aUsed.begin(), aUsed.end(), InsertChartListener(maListeners));
+ std::for_each(aUsed.begin(), aUsed.end(), InsertChartListener(m_Listeners));
// Now, delete the ones no longer needed.
std::for_each(aUnused.begin(), aUnused.end(), boost::checked_deleter<ScChartListener>());
@@ -600,13 +609,12 @@ void ScChartListenerCollection::UpdateDirtyCharts()
{
// During ScChartListener::Update() the most nasty things can happen due to
// UNO listeners, e.g. reentrant calls via BASIC to insert() and FreeUno()
- // and similar that modify maListeners and invalidate iterators.
+ // and similar that modify m_Listeners and invalidate iterators.
meModifiedDuringUpdate = SC_CLCUPDATE_RUNNING;
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : m_Listeners)
{
- ScChartListener* p = it->second;
+ ScChartListener *const p = it.second.get();
if (p->IsDirty())
p->Update();
@@ -621,9 +629,10 @@ void ScChartListenerCollection::UpdateDirtyCharts()
void ScChartListenerCollection::SetDirty()
{
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
- it->second->SetDirty(true);
+ for (auto const& it : m_Listeners)
+ {
+ it.second->SetDirty(true);
+ }
StartTimer();
}
@@ -632,10 +641,9 @@ void ScChartListenerCollection::SetDiffDirty(
const ScChartListenerCollection& rCmp, bool bSetChartRangeLists )
{
bool bDirty = false;
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : m_Listeners)
{
- ScChartListener* pCL = it->second;
+ ScChartListener *const pCL = it.second.get();
OSL_ASSERT(pCL);
const ScChartListener* pCLCmp = rCmp.findByName(pCL->GetName());
if (!pCLCmp || *pCL != *pCLCmp)
@@ -665,10 +673,9 @@ void ScChartListenerCollection::SetDiffDirty(
void ScChartListenerCollection::SetRangeDirty( const ScRange& rRange )
{
bool bDirty = false;
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : m_Listeners)
{
- ScChartListener* pCL = it->second;
+ ScChartListener *const pCL = it.second.get();
const ScRangeListRef& rList = pCL->GetRangeList();
if ( rList.Is() && rList->Intersects( rRange ) )
{
@@ -691,31 +698,33 @@ void ScChartListenerCollection::SetRangeDirty( const ScRange& rRange )
void ScChartListenerCollection::UpdateScheduledSeriesRanges()
{
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
- it->second->UpdateScheduledSeriesRanges();
+ for (auto const& it : m_Listeners)
+ {
+ it.second->UpdateScheduledSeriesRanges();
+ }
}
void ScChartListenerCollection::UpdateChartsContainingTab( SCTAB nTab )
{
ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
- ListenersType::iterator it = maListeners.begin(), itEnd = maListeners.end();
- for (; it != itEnd; ++it)
- it->second->UpdateChartIntersecting(aRange);
+ for (auto const& it : m_Listeners)
+ {
+ it.second->UpdateChartIntersecting(aRange);
+ }
}
bool ScChartListenerCollection::operator==( const ScChartListenerCollection& r ) const
{
// Do not use ScStrCollection::operator==() here that uses IsEqual und Compare.
// Use ScChartListener::operator==() instead.
- if (pDoc != r.pDoc || maListeners.size() != r.maListeners.size())
+ if (pDoc != r.pDoc || m_Listeners.size() != r.m_Listeners.size())
return false;
- ListenersType::const_iterator it = maListeners.begin(), itEnd = maListeners.end();
- ListenersType::const_iterator it2 = r.maListeners.begin();
+ ListenersType::const_iterator it = m_Listeners.begin(), itEnd = m_Listeners.end();
+ ListenersType::const_iterator it2 = r.m_Listeners.begin();
for (; it != itEnd; ++it, ++it2)
{
- if (*it != *it2)
+ if (it->first != it2->first || *it->second != *it2->second)
return false;
}
return true;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index eb9ed61..145ed0c 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3341,10 +3341,9 @@ void ScCellRangesBase::ForceChartListener_Impl()
return;
ScChartListenerCollection::ListenersType& rListeners = pColl->getListeners();
- ScChartListenerCollection::ListenersType::iterator it = rListeners.begin(), itEnd = rListeners.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : rListeners)
{
- ScChartListener* p = it->second;
+ ScChartListener *const p = it.second.get();
OSL_ASSERT(p);
if (p->GetUnoSource() == static_cast<chart::XChartData*>(this) && p->IsDirty())
p->Update();
commit 37856f59d2351951b95cf5eb3a5e4f0c011a8762
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 6 17:03:25 2015 +0100
sc: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: Iea907bd407d0a6d1d7fa8a5a98ae7a9b4bbed642
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 77cdcf5..4d7467a 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -22,8 +22,7 @@
#include <list>
#include <memory>
-
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <vector>
#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
@@ -241,10 +240,10 @@ class ScDPSaveData
typedef std::unordered_map<OUString, size_t, OUStringHash> DupNameCountType;
public:
typedef std::unordered_map<OUString, size_t, OUStringHash> DimOrderType;
- typedef boost::ptr_vector<ScDPSaveDimension> DimsType;
+ typedef std::vector<std::unique_ptr<ScDPSaveDimension>> DimsType;
private:
- DimsType aDimList;
+ DimsType m_DimList;
DupNameCountType maDupNameCounts; /// keep track of number of duplicates in each name.
ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions
sal_uInt16 nColumnGrandMode;
@@ -273,7 +272,7 @@ public:
SC_DLLPUBLIC void SetGrandTotalName(const OUString& rName);
SC_DLLPUBLIC const OUString* GetGrandTotalName() const;
- const DimsType& GetDimensions() const { return aDimList;}
+ const DimsType& GetDimensions() const { return m_DimList; }
/**
* Get sort order map to sort row and column dimensions in order of
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index f9d1526..e15dd88 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -28,7 +28,9 @@
#include <sal/types.h>
#include <osl/diagnose.h>
+#include <o3tl/make_unique.hxx>
#include <comphelper/string.hxx>
+#include <comphelper/stl_types.hxx>
#include <com/sun/star/sheet/GeneralFunction.hpp>
#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
@@ -825,7 +827,10 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
else
pDimensionData = nullptr;
- aDimList = r.aDimList.clone();
+ for (auto const& it : r.m_DimList)
+ {
+ m_DimList.push_back(o3tl::make_unique<ScDPSaveDimension>(*it));
+ }
if (r.mpGrandTotalName)
mpGrandTotalName.reset(new OUString(*r.mpGrandTotalName));
@@ -856,10 +861,7 @@ bool ScDPSaveData::operator== ( const ScDPSaveData& r ) const
if ( !pDimensionData || !r.pDimensionData || !( *pDimensionData == *r.pDimensionData ) )
return false;
- if ( aDimList.size() != r.aDimList.size() )
- return false;
-
- if (aDimList != r.aDimList)
+ if (!(::comphelper::ContainerUniquePtrEquals(m_DimList, r.m_DimList)))
return false;
if (mpGrandTotalName)
@@ -927,8 +929,7 @@ void ScDPSaveData::GetAllDimensionsByOrientation(
sheet::DataPilotFieldOrientation eOrientation, std::vector<const ScDPSaveDimension*>& rDims) const
{
std::vector<const ScDPSaveDimension*> aDims;
- DimsType::const_iterator it = aDimList.begin(), itEnd = aDimList.end();
- for (; it != itEnd; ++it)
+ for (auto const& it : m_DimList)
{
const ScDPSaveDimension& rDim = *it;
if (rDim.GetOrientation() != static_cast<sal_uInt16>(eOrientation))
@@ -946,15 +947,14 @@ void ScDPSaveData::AddDimension(ScDPSaveDimension* pDim)
return;
CheckDuplicateName(*pDim);
- aDimList.push_back(pDim);
+ m_DimList.push_back(std::unique_ptr<ScDPSaveDimension>(pDim));
DimensionsChanged();
}
ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const OUString& rName)
{
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
if (iter->GetName() == rName && !iter->IsDataLayout() )
return const_cast<ScDPSaveDimension*>(&(*iter));
@@ -965,8 +965,7 @@ ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const OUString& rName)
ScDPSaveDimension* ScDPSaveData::GetExistingDimensionByName(const OUString& rName) const
{
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
if (iter->GetName() == rName && !iter->IsDataLayout() )
return const_cast<ScDPSaveDimension*>(&(*iter));
@@ -976,8 +975,7 @@ ScDPSaveDimension* ScDPSaveData::GetExistingDimensionByName(const OUString& rNam
ScDPSaveDimension* ScDPSaveData::GetNewDimensionByName(const OUString& rName)
{
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
if (iter->GetName() == rName && !iter->IsDataLayout() )
return DuplicateDimension(rName);
@@ -997,8 +995,7 @@ ScDPSaveDimension* ScDPSaveData::GetDataLayoutDimension()
ScDPSaveDimension* ScDPSaveData::GetExistingDataLayoutDimension() const
{
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
if ( iter->IsDataLayout() )
return const_cast<ScDPSaveDimension*>(&(*iter));
@@ -1021,13 +1018,12 @@ ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const OUString& rName)
void ScDPSaveData::RemoveDimensionByName(const OUString& rName)
{
- boost::ptr_vector<ScDPSaveDimension>::iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto iter = m_DimList.begin(); iter != m_DimList.end(); ++iter)
{
- if (iter->GetName() != rName || iter->IsDataLayout())
+ if ((*iter)->GetName() != rName || (*iter)->IsDataLayout())
continue;
- aDimList.erase(iter);
+ m_DimList.erase(iter);
RemoveDuplicateNameCount(rName);
DimensionsChanged();
return;
@@ -1046,8 +1042,7 @@ ScDPSaveDimension* ScDPSaveData::GetInnermostDimension(sal_uInt16 nOrientation)
// return the innermost dimension for the given orientation,
// excluding data layout dimension
- boost::ptr_vector<ScDPSaveDimension>::const_reverse_iterator iter;
- for (iter = aDimList.rbegin(); iter != aDimList.rend(); ++iter)
+ for (auto const& iter : m_DimList)
{
if (iter->GetOrientation() == nOrientation && !iter->IsDataLayout())
return const_cast<ScDPSaveDimension*>(&(*iter));
@@ -1058,8 +1053,7 @@ ScDPSaveDimension* ScDPSaveData::GetInnermostDimension(sal_uInt16 nOrientation)
ScDPSaveDimension* ScDPSaveData::GetFirstDimension(sheet::DataPilotFieldOrientation eOrientation)
{
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
if (iter->GetOrientation() == eOrientation && !iter->IsDataLayout())
return const_cast<ScDPSaveDimension*>(&(*iter));
@@ -1071,8 +1065,7 @@ long ScDPSaveData::GetDataDimensionCount() const
{
long nDataCount = 0;
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
if (iter->GetOrientation() == sheet::DataPilotFieldOrientation_DATA)
++nDataCount;
@@ -1087,29 +1080,29 @@ void ScDPSaveData::SetPosition( ScDPSaveDimension* pDim, long nNew )
sal_uInt16 nOrient = pDim->GetOrientation();
- boost::ptr_vector<ScDPSaveDimension>::iterator it;
- for ( it = aDimList.begin(); it != aDimList.end(); ++it)
+ for (auto it = m_DimList.begin(); it != m_DimList.end(); ++it)
{
- if (pDim == &(*it))
+ if (pDim == it->get())
{
// Tell ptr_vector to give up ownership of this element. Don't
// delete this instance as it is re-inserted into the container
// later.
- aDimList.release(it).release();
+ it->release();
+ m_DimList.erase(it);
break;
}
}
- boost::ptr_vector<ScDPSaveDimension>::iterator iterInsert = aDimList.begin();
- while ( nNew > 0 && iterInsert != aDimList.end())
+ auto iterInsert = m_DimList.begin();
+ while ( nNew > 0 && iterInsert != m_DimList.end())
{
- if (iterInsert->GetOrientation() == nOrient )
+ if ((*iterInsert)->GetOrientation() == nOrient )
--nNew;
++iterInsert;
}
- aDimList.insert(iterInsert,pDim);
+ m_DimList.insert(iterInsert, std::unique_ptr<ScDPSaveDimension>(pDim));
DimensionsChanged();
}
@@ -1210,15 +1203,15 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
uno::Reference<container::XIndexAccess> xIntDims = new ScNameToIndexAccess( xDimsName );
long nIntCount = xIntDims->getCount();
- boost::ptr_vector<ScDPSaveDimension>::iterator iter = aDimList.begin();
- for (long i = 0; iter != aDimList.end(); ++iter, ++i)
+ auto iter = m_DimList.begin();
+ for (long i = 0; iter != m_DimList.end(); ++iter, ++i)
{
- OUString aName = iter->GetName();
+ OUString aName = (*iter)->GetName();
OUString aCoreName = ScDPUtil::getSourceDimensionName(aName);
SAL_INFO("sc.core", aName);
- bool bData = iter->IsDataLayout();
+ bool bData = (*iter)->IsDataLayout();
//TODO: getByName for ScDPSource, including DataLayoutDimension !!!!!!!!
@@ -1245,7 +1238,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
if (bFound)
{
- if (iter->GetDupFlag())
+ if ((*iter)->GetDupFlag())
{
uno::Reference<util::XCloneable> xCloneable(xIntDim, uno::UNO_QUERY);
OSL_ENSURE(xCloneable.is(), "cannot clone dimension");
@@ -1256,12 +1249,12 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
if (xNewName.is())
{
xNewName->setName(aName);
- iter->WriteToSource(xNew);
+ (*iter)->WriteToSource(xNew);
}
}
}
else
- iter->WriteToSource( xIntDim );
+ (*iter)->WriteToSource( xIntDim );
}
}
OSL_ENSURE(bFound, "WriteToSource: Dimension not found");
@@ -1285,8 +1278,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
bool ScDPSaveData::IsEmpty() const
{
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
if (iter->GetOrientation() != sheet::DataPilotFieldOrientation_HIDDEN && !iter->IsDataLayout())
return false;
@@ -1361,8 +1353,7 @@ void ScDPSaveData::BuildAllDimensionMembers(ScDPTableData* pData)
NameIndexMap::const_iterator itrEnd = aMap.end();
- boost::ptr_vector<ScDPSaveDimension>::iterator iter;
- for (iter = aDimList.begin(); iter != aDimList.end(); ++iter)
+ for (auto const& iter : m_DimList)
{
const OUString& rDimName = iter->GetName();
if (rDimName.isEmpty())
@@ -1406,8 +1397,7 @@ void ScDPSaveData::SyncAllDimensionMembers(ScDPTableData* pData)
NameIndexMap::const_iterator itMapEnd = aMap.end();
- DimsType::iterator it = aDimList.begin(), itEnd = aDimList.end();
- for (it = aDimList.begin(); it != itEnd; ++it)
+ for (auto const& it : m_DimList)
{
const OUString& rDimName = it->GetName();
if (rDimName.isEmpty())
@@ -1447,8 +1437,7 @@ bool ScDPSaveData::HasInvisibleMember(const OUString& rDimName) const
void ScDPSaveData::Dump() const
{
- DimsType::const_iterator itDim = aDimList.begin(), itDimEnd = aDimList.end();
- for (; itDim != itDimEnd; ++itDim)
+ for (auto const& itDim : m_DimList)
{
const ScDPSaveDimension& rDim = *itDim;
rDim.Dump();
@@ -1498,7 +1487,7 @@ ScDPSaveDimension* ScDPSaveData::AppendNewDimension(const OUString& rName, bool
return nullptr;
ScDPSaveDimension* pNew = new ScDPSaveDimension(rName, bDataLayout);
- aDimList.push_back(pNew);
+ m_DimList.push_back(std::unique_ptr<ScDPSaveDimension>(pNew));
if (!maDupNameCounts.count(rName))
maDupNameCounts.insert(DupNameCountType::value_type(rName, 0));
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 416329b..a0ca2ba 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -1205,19 +1205,22 @@ XclExpPivotTable::XclExpPivotTable( const XclExpRoot& rRoot, const ScDPObject& r
for( sal_uInt16 nFieldIdx = 0, nFieldCount = mrPCache.GetFieldCount(); nFieldIdx < nFieldCount; ++nFieldIdx )
maFieldList.AppendNewRecord( new XclExpPTField( *this, nFieldIdx ) );
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
const ScDPSaveData::DimsType& rDimList = pSaveData->GetDimensions();
/* 2) First process all data dimensions, they are needed for extended
settings of row/column/page fields (sorting/auto show). */
- for (iter = rDimList.begin(); iter != rDimList.end(); ++iter)
+ for (auto const& iter : rDimList)
+ {
if (iter->GetOrientation() == DataPilotFieldOrientation_DATA)
SetDataFieldPropertiesFromDim(*iter);
+ }
/* 3) Row/column/page/hidden fields. */
- for (iter = rDimList.begin(); iter != rDimList.end(); ++iter)
+ for (auto const& iter : rDimList)
+ {
if (iter->GetOrientation() != DataPilotFieldOrientation_DATA)
SetFieldPropertiesFromDim(*iter);
+ }
// Finalize -------------------------------------------------------
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index 917af8d..1fd6f7d 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -451,7 +451,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
for (size_t i = 0, n = rDims.size(); i < n; ++i)
{
- const ScDPSaveDimension& rDim = rDims[i];
+ const ScDPSaveDimension& rDim = *rDims[i];
long nPos = -1; // position in cache
if (rDim.IsDataLayout())
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 5c53380..eff5e31 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -720,10 +720,12 @@ void ScXMLExportDataPilot::WriteDimension(ScDPSaveDimension* pDim, const ScDPDim
void ScXMLExportDataPilot::WriteDimensions(ScDPSaveData* pDPSave)
{
- const boost::ptr_vector<ScDPSaveDimension> &rDimensions = pDPSave->GetDimensions();
- boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
- for (iter = rDimensions.begin(); iter != rDimensions.end(); ++iter)
- WriteDimension(const_cast<ScDPSaveDimension*>(&(*iter)), pDPSave->GetExistingDimensionData());
+ const ScDPSaveData::DimsType& rDimensions = pDPSave->GetDimensions();
+ for (auto const& iter : rDimensions)
+ {
+ WriteDimension(const_cast<ScDPSaveDimension*>(iter.get()),
+ pDPSave->GetExistingDimensionData());
+ }
}
void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const OUString* pGrandTotal)
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 04cdd88..f6422ca 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -1486,8 +1486,7 @@ ScDPSaveDimension* ScDataPilotChildObjBase::GetDPDimension( ScDPObject** ppDPObj
const ScDPSaveData::DimsType& rDims = pSaveData->GetDimensions();
sal_Int32 nFoundIdx = 0;
- ScDPSaveData::DimsType::const_iterator it;
- for (it = rDims.begin(); it != rDims.end(); ++it)
+ for (auto const& it : rDims)
{
if (it->IsDataLayout())
continue;
@@ -1496,7 +1495,7 @@ ScDPSaveDimension* ScDataPilotChildObjBase::GetDPDimension( ScDPObject** ppDPObj
if (aSrcName == maFieldId.maFieldName)
{
if( nFoundIdx == maFieldId.mnFieldIdx )
- return const_cast<ScDPSaveDimension*>(&(*it));
+ return const_cast<ScDPSaveDimension*>(it.get());
++nFoundIdx;
}
}
@@ -1769,9 +1768,8 @@ Sequence<OUString> SAL_CALL ScDataPilotFieldsObj::getElementNames()
Sequence< OUString > aSeq( lcl_GetFieldCount( pDPObj->GetSource(), maOrient ) );
OUString* pAry = aSeq.getArray();
- const boost::ptr_vector<ScDPSaveDimension>& rDimensions = pDPObj->GetSaveData()->GetDimensions();
- boost::ptr_vector<ScDPSaveDimension>::const_iterator it;
- for (it = rDimensions.begin(); it != rDimensions.end(); ++it)
+ const ScDPSaveData::DimsType& rDimensions = pDPObj->GetSaveData()->GetDimensions();
+ for (auto const& it : rDimensions)
{
if(maOrient.hasValue() && (it->GetOrientation() == maOrient.get< DataPilotFieldOrientation >()))
{
@@ -2067,14 +2065,13 @@ void ScDataPilotFieldObj::setOrientation(DataPilotFieldOrientation eNew)
// look for existing duplicate with orientation "hidden"
sal_Int32 nFound = 0;
- const boost::ptr_vector<ScDPSaveDimension>& rDimensions = pSaveData->GetDimensions();
- boost::ptr_vector<ScDPSaveDimension>::const_iterator it;
- for ( it = rDimensions.begin(); it != rDimensions.end() && !pNewDim; ++it )
+ const ScDPSaveData::DimsType& rDimensions = pSaveData->GetDimensions();
+ for (auto const& it : rDimensions)
{
if ( !it->IsDataLayout() && (it->GetName() == maFieldId.maFieldName) )
{
if ( it->GetOrientation() == DataPilotFieldOrientation_HIDDEN )
- pNewDim = const_cast<ScDPSaveDimension*>(&(*it)); // use this one
+ pNewDim = const_cast<ScDPSaveDimension*>(it.get()); // use this one
else
++nFound; // count existing non-hidden occurrences
}
commit ce6401c263b9f098c1fad636656749db6c6f22a1
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 6 16:24:33 2015 +0100
sc: remove some unused boost includes
Change-Id: I32f258c2152a4a40a796161a91c76d81e0a3ba47
diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index 388b546c..a009fbb 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -46,7 +46,8 @@
#include <cppuhelper/implbase.hxx>
#include <svl/itemprop.hxx>
#include <svl/lstner.hxx>
-#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <vector>
class ScDBData;
class ScDocShell;
diff --git a/sc/inc/detdata.hxx b/sc/inc/detdata.hxx
index ab7fb71..271b936 100644
--- a/sc/inc/detdata.hxx
+++ b/sc/inc/detdata.hxx
@@ -20,9 +20,11 @@
#ifndef INCLUDED_SC_INC_DETDATA_HXX
#define INCLUDED_SC_INC_DETDATA_HXX
-#include <boost/ptr_container/ptr_vector.hpp>
#include "global.hxx"
+#include <memory>
+#include <vector>
+
enum ScDetOpType
{
SCDETOP_ADDSUCC,
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 178c742..db2a689 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -34,7 +34,6 @@
#include <set>
#include <vector>
-#include <boost/ptr_container/ptr_list.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/ptr_container/ptr_map.hpp>
commit 22c1e08fda61e424a3bdb7305a9b9025c5e80d90
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Nov 5 22:09:12 2015 +0100
vcl: WinMtfOutput: replace the other mutable static with a member too
Change-Id: Ied1e1c12f2fe19734f27c005e60db07e674e3639
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index 93c6b1a..a34beda 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -944,12 +944,11 @@ sal_uInt32 WinMtfOutput::SetRasterOp( sal_uInt32 nRasterOp )
if ( nRasterOp != mnRop )
{
mnRop = nRasterOp;
- static WinMtfLineStyle aNopLineStyle;
if ( mbNopMode && ( nRasterOp != R2_NOP ) )
{ // changing modes from R2_NOP so set pen and brush
maFillStyle = m_NopFillStyle;
- maLineStyle = aNopLineStyle;
+ maLineStyle = m_NopLineStyle;
mbNopMode = false;
}
switch( nRasterOp )
@@ -968,7 +967,7 @@ sal_uInt32 WinMtfOutput::SetRasterOp( sal_uInt32 nRasterOp )
if( !mbNopMode )
{
m_NopFillStyle = maFillStyle;
- aNopLineStyle = maLineStyle;
+ m_NopLineStyle = maLineStyle;
maFillStyle = WinMtfFillStyle( Color( COL_TRANSPARENT ), true );
maLineStyle = WinMtfLineStyle( Color( COL_TRANSPARENT ), true );
mbNopMode = true;
diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
index bb1bbf2..095dfbe 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -543,6 +543,7 @@ class WinMtfOutput
WinMtfLineStyle maLatestLineStyle;
WinMtfLineStyle maLineStyle;
+ WinMtfLineStyle m_NopLineStyle;
WinMtfFillStyle maLatestFillStyle;
WinMtfFillStyle maFillStyle;
WinMtfFillStyle m_NopFillStyle;
commit 10afa00c8ce4f0de9191cd182409a3a5d8e55bb8
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Nov 5 13:16:50 2015 +0100
compilerplugins: enhance "badstatics" plugin to find members
Finds static variables of types that have bad non-static members.
Change-Id: I81ee940580c0f043feb543840ea4d3dd27734202
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index 136e1db..c41b12d 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -25,23 +25,68 @@ public:
}
}
+ /*static*/ std::pair<bool, FieldDecl const*> isBadStaticType(
+ QualType const& rType, FieldDecl const*const pCurrentFieldDecl)
+ {
+ QualType const pCanonical(rType.getUnqualifiedType().getCanonicalType());
+ RecordType const*const pRecordType(pCanonical->getAs<RecordType>());
+ if (!pRecordType) {
+ return std::make_pair(false, nullptr);
+ }
+ auto const type(pCanonical.getAsString());
+ if ( type == "class Image"
+ || type == "class Bitmap"
+ || type == "class BitmapEx"
+ )
+ {
+ return std::make_pair(true, pCurrentFieldDecl);
+ }
+ RecordDecl const*const pDefinition(pRecordType->getDecl()->getDefinition());
+ assert(pDefinition);
+ CXXRecordDecl const*const pDecl(dyn_cast<CXXRecordDecl>(pDefinition));
+ assert(pDecl);
+ for (auto it = pDecl->field_begin(); it != pDecl->field_end(); ++it) {
+ auto const ret(isBadStaticType((*it)->getType(), *it));
+ if (ret.first) {
+ return ret;
+ }
+ }
+ for (auto it = pDecl->bases_begin(); it != pDecl->bases_end(); ++it) {
+ auto const ret(isBadStaticType((*it).getType(), pCurrentFieldDecl));
+ if (ret.first) {
+ return ret;
+ }
+ }
+ for (auto it = pDecl->vbases_begin(); it != pDecl->vbases_end(); ++it) {
+ auto const ret(isBadStaticType((*it).getType(), pCurrentFieldDecl));
+ if (ret.first) {
+ return ret;
+ }
+ }
+ return std::make_pair(false, nullptr);
+ }
+
bool VisitVarDecl(VarDecl const*const pVarDecl)
{
if (ignoreLocation(pVarDecl)) {
return true;
}
- if (pVarDecl->hasGlobalStorage()) {
- auto const type(pVarDecl->getType().getUnqualifiedType().getCanonicalType().getAsString());
- if ( type == "class Image"
- || type == "class Bitmap"
- || type == "class BitmapEx"
- )
- {
+ if (pVarDecl->hasGlobalStorage()
+ && pVarDecl->isThisDeclarationADefinition())
+ {
+ auto const ret(isBadStaticType(pVarDecl->getType(), nullptr));
+ if (ret.first) {
report(DiagnosticsEngine::Warning,
"bad static variable causes crash on shutdown",
pVarDecl->getLocation())
<< pVarDecl->getSourceRange();
+ if (ret.second != nullptr) {
+ report(DiagnosticsEngine::Remark,
+ "... due to this member",
+ ret.second->getLocation())
+ << ret.second->getSourceRange();
+ }
}
}
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index c9f8750..93c6b1a 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -944,12 +944,11 @@ sal_uInt32 WinMtfOutput::SetRasterOp( sal_uInt32 nRasterOp )
if ( nRasterOp != mnRop )
{
mnRop = nRasterOp;
- static WinMtfFillStyle aNopFillStyle;
static WinMtfLineStyle aNopLineStyle;
if ( mbNopMode && ( nRasterOp != R2_NOP ) )
{ // changing modes from R2_NOP so set pen and brush
- maFillStyle = aNopFillStyle;
+ maFillStyle = m_NopFillStyle;
maLineStyle = aNopLineStyle;
mbNopMode = false;
}
@@ -968,7 +967,7 @@ sal_uInt32 WinMtfOutput::SetRasterOp( sal_uInt32 nRasterOp )
meRasterOp = ROP_OVERPAINT;
if( !mbNopMode )
{
- aNopFillStyle = maFillStyle;
+ m_NopFillStyle = maFillStyle;
aNopLineStyle = maLineStyle;
maFillStyle = WinMtfFillStyle( Color( COL_TRANSPARENT ), true );
maLineStyle = WinMtfLineStyle( Color( COL_TRANSPARENT ), true );
diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
index 0126970..bb1bbf2 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -545,6 +545,7 @@ class WinMtfOutput
WinMtfLineStyle maLineStyle;
WinMtfFillStyle maLatestFillStyle;
WinMtfFillStyle maFillStyle;
+ WinMtfFillStyle m_NopFillStyle;
vcl::Font maLatestFont;
vcl::Font maFont;
sal_uInt32 mnLatestTextAlign;
More information about the Libreoffice-commits
mailing list