[Libreoffice-commits] core.git: 4 commits - svl/inc svl/source sw/inc sw/source
Michael Stahl
mstahl at redhat.com
Fri Oct 30 18:57:54 UTC 2015
svl/inc/pch/precompiled_svl.hxx | 3 -
svl/source/items/aeitem.cxx | 92 +++++--------------------------------
svl/source/misc/inettype.cxx | 39 ++++++---------
sw/inc/pch/precompiled_sw.hxx | 1
sw/source/filter/html/htmlgrin.cxx | 8 +--
sw/source/filter/html/swhtml.cxx | 10 ++--
sw/source/filter/html/swhtml.hxx | 8 +--
sw/source/filter/html/wrthtml.hxx | 1
8 files changed, 42 insertions(+), 120 deletions(-)
New commits:
commit acc6d29b0c865e19f0348fd650038b3472a2a2c2
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Oct 30 19:25:02 2015 +0100
svl: remove mostly superfluous abstraction of vector
If only we could call the member vector's reserve method then copying
would be faster, oh actually we could also use std::copy to get rid of
the loop, ... why not just call the copy constructor?
Change-Id: I59bb331e6157d692cb62f44f1fd4e8318bf92902
diff --git a/svl/source/items/aeitem.cxx b/svl/source/items/aeitem.cxx
index 5f30d90..f2428af 100644
--- a/svl/source/items/aeitem.cxx
+++ b/svl/source/items/aeitem.cxx
@@ -26,40 +26,13 @@
TYPEINIT1_AUTOFACTORY(SfxAllEnumItem, SfxEnumItem)
-
struct SfxAllEnumValue_Impl
{
sal_uInt16 nValue;
OUString aText;
};
-class SfxAllEnumValueArr : boost::noncopyable
-{
-public:
- const SfxAllEnumValue_Impl &operator[](size_t i) const {
- return m_Values[i];
- }
-
- bool empty() const {
- return m_Values.empty();
- }
-
- void Insert(sal_uInt16 n, SfxAllEnumValue_Impl const& value) {
- m_Values.insert(m_Values.begin() + n, value);
- }
-
- void Erase(sal_uInt16 n) {
- m_Values.erase(m_Values.begin() + n);
- }
-
- size_t size() const {
- return m_Values.size();
- }
-
-private:
- std::vector<SfxAllEnumValue_Impl> m_Values;
-};
-
+class SfxAllEnumValueArr : public std::vector<SfxAllEnumValue_Impl> {};
SfxAllEnumItem::SfxAllEnumItem() :
@@ -69,8 +42,6 @@ SfxAllEnumItem::SfxAllEnumItem() :
{
}
-
-
SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which, sal_uInt16 nVal):
SfxEnumItem(which, nVal),
pValues( 0 ),
@@ -79,8 +50,6 @@ SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which, sal_uInt16 nVal):
InsertValue( nVal );
}
-
-
SfxAllEnumItem::SfxAllEnumItem( sal_uInt16 which, SvStream &rStream ):
SfxEnumItem(which, rStream),
pValues( 0 ),
@@ -89,9 +58,6 @@ SfxAllEnumItem::SfxAllEnumItem( sal_uInt16 which, SvStream &rStream ):
InsertValue( GetValue() );
}
-
-
-
SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which):
SfxEnumItem(which, 0),
pValues( 0 ),
@@ -99,9 +65,6 @@ SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which):
{
}
-
-
-
SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
SfxEnumItem(rCopy),
pValues(0),
@@ -110,15 +73,7 @@ SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
if ( !rCopy.pValues )
return;
- pValues = new SfxAllEnumValueArr;
-
- for ( size_t nPos = 0; nPos < rCopy.pValues->size(); ++nPos )
- {
- SfxAllEnumValue_Impl aVal;
- aVal.nValue = (*rCopy.pValues)[nPos].nValue;
- aVal.aText = (*rCopy.pValues)[nPos].aText;
- pValues->Insert( nPos, aVal );
- }
+ pValues = new SfxAllEnumValueArr(*rCopy.pValues);
if( rCopy.pDisabledValues )
{
@@ -126,53 +81,39 @@ SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
}
}
-
-
SfxAllEnumItem::~SfxAllEnumItem()
{
delete pValues;
delete pDisabledValues;
}
-
-
sal_uInt16 SfxAllEnumItem::GetValueCount() const
{
return pValues ? pValues->size() : 0;
}
-
-
OUString SfxAllEnumItem::GetValueTextByPos( sal_uInt16 nPos ) const
{
DBG_ASSERT( pValues && nPos < pValues->size(), "enum overflow" );
return (*pValues)[nPos].aText;
}
-
-
sal_uInt16 SfxAllEnumItem::GetValueByPos( sal_uInt16 nPos ) const
{
DBG_ASSERT( pValues && nPos < pValues->size(), "enum overflow" );
return (*pValues)[nPos].nValue;
}
-
-
SfxPoolItem* SfxAllEnumItem::Clone( SfxItemPool * ) const
{
return new SfxAllEnumItem(*this);
}
-
-
SfxPoolItem* SfxAllEnumItem::Create( SvStream & rStream, sal_uInt16 ) const
{
return new SfxAllEnumItem( Which(), rStream );
}
-
-
/**
* In contrast to @see SfxEnumItemInterface::GetPosByValue(sal_uInt16) const
* this internal method returns the position the value would be for non-present values.
@@ -190,13 +131,11 @@ sal_uInt16 SfxAllEnumItem::_GetPosByValue( sal_uInt16 nVal ) const
return nPos;
}
-
/**
* In contrast to @see SfxEnumItemInterface::GetPosByValue(sal_uInt16) const
* this method always returns nValue, as long as not at least one value has
* been inserted using the SfxAllEnumItem::InsertValue() methods
-*/
-
+ */
sal_uInt16 SfxAllEnumItem::GetPosByValue( sal_uInt16 nValue ) const
{
if ( !pValues || pValues->empty() )
@@ -205,8 +144,6 @@ sal_uInt16 SfxAllEnumItem::GetPosByValue( sal_uInt16 nValue ) const
return SfxEnumItem::GetPosByValue( nValue );
}
-
-
void SfxAllEnumItem::InsertValue( sal_uInt16 nValue, const OUString &rValue )
{
SfxAllEnumValue_Impl aVal;
@@ -218,11 +155,9 @@ void SfxAllEnumItem::InsertValue( sal_uInt16 nValue, const OUString &rValue )
// remove when exists
RemoveValue( nValue );
// then insert
- pValues->Insert( _GetPosByValue(nValue), aVal ); // FIXME: Duplicates?
+ pValues->insert(pValues->begin() + _GetPosByValue(nValue), aVal); // FIXME: Duplicates?
}
-
-
void SfxAllEnumItem::InsertValue( sal_uInt16 nValue )
{
SfxAllEnumValue_Impl aVal;
@@ -231,7 +166,7 @@ void SfxAllEnumItem::InsertValue( sal_uInt16 nValue )
if ( !pValues )
pValues = new SfxAllEnumValueArr;
- pValues->Insert( _GetPosByValue(nValue), aVal ); // FIXME: Duplicates?
+ pValues->insert(pValues->begin() + _GetPosByValue(nValue), aVal); // FIXME: Duplicates?
}
void SfxAllEnumItem::DisableValue( sal_uInt16 nValue )
@@ -260,7 +195,7 @@ void SfxAllEnumItem::RemoveValue( sal_uInt16 nValue )
{
sal_uInt16 nPos = GetPosByValue(nValue);
DBG_ASSERT( nPos != USHRT_MAX, "removing value not in enum" );
- pValues->Erase( nPos );
+ pValues->erase( pValues->begin() + nPos );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 872f449377f24c97877ae3fe9c35549ef3c0c531
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Oct 30 19:16:46 2015 +0100
svl: replace boost::ptr_vector with std::vector
Change-Id: I7377f9e99b0567a942cdb36f6964ffedacce6a68
diff --git a/svl/inc/pch/precompiled_svl.hxx b/svl/inc/pch/precompiled_svl.hxx
index 8ecbcce..50b15a9 100644
--- a/svl/inc/pch/precompiled_svl.hxx
+++ b/svl/inc/pch/precompiled_svl.hxx
@@ -18,7 +18,6 @@
#include <algorithm>
#include <boost/noncopyable.hpp>
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
#include <memory>
#include <cassert>
#include <cmath>
diff --git a/svl/source/items/aeitem.cxx b/svl/source/items/aeitem.cxx
index b5896c5..5f30d90 100644
--- a/svl/source/items/aeitem.cxx
+++ b/svl/source/items/aeitem.cxx
@@ -20,7 +20,8 @@
#include <rtl/ustring.hxx>
#include <svl/aeitem.hxx>
#include <boost/noncopyable.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <vector>
TYPEINIT1_AUTOFACTORY(SfxAllEnumItem, SfxEnumItem)
@@ -36,27 +37,27 @@ class SfxAllEnumValueArr : boost::noncopyable
{
public:
const SfxAllEnumValue_Impl &operator[](size_t i) const {
- return mValues[i];
+ return m_Values[i];
}
bool empty() const {
- return mValues.empty();
+ return m_Values.empty();
}
- void Insert(sal_uInt16 n, SfxAllEnumValue_Impl *value) {
- mValues.insert(mValues.begin() + n, value);
+ void Insert(sal_uInt16 n, SfxAllEnumValue_Impl const& value) {
+ m_Values.insert(m_Values.begin() + n, value);
}
void Erase(sal_uInt16 n) {
- mValues.erase(mValues.begin() + n);
+ m_Values.erase(m_Values.begin() + n);
}
size_t size() const {
- return mValues.size();
+ return m_Values.size();
}
private:
- boost::ptr_vector<SfxAllEnumValue_Impl> mValues;
+ std::vector<SfxAllEnumValue_Impl> m_Values;
};
@@ -113,10 +114,10 @@ SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
for ( size_t nPos = 0; nPos < rCopy.pValues->size(); ++nPos )
{
- SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
- pVal->nValue = (*rCopy.pValues)[nPos].nValue;
- pVal->aText = (*rCopy.pValues)[nPos].aText;
- pValues->Insert( nPos, pVal );
+ SfxAllEnumValue_Impl aVal;
+ aVal.nValue = (*rCopy.pValues)[nPos].nValue;
+ aVal.aText = (*rCopy.pValues)[nPos].aText;
+ pValues->Insert( nPos, aVal );
}
if( rCopy.pDisabledValues )
@@ -208,29 +209,29 @@ sal_uInt16 SfxAllEnumItem::GetPosByValue( sal_uInt16 nValue ) const
void SfxAllEnumItem::InsertValue( sal_uInt16 nValue, const OUString &rValue )
{
- SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
- pVal->nValue = nValue;
- pVal->aText = rValue;
+ SfxAllEnumValue_Impl aVal;
+ aVal.nValue = nValue;
+ aVal.aText = rValue;
if ( !pValues )
pValues = new SfxAllEnumValueArr;
else if ( GetPosByValue( nValue ) != USHRT_MAX )
// remove when exists
RemoveValue( nValue );
// then insert
- pValues->Insert( _GetPosByValue(nValue), pVal ); // FIXME: Duplicates?
+ pValues->Insert( _GetPosByValue(nValue), aVal ); // FIXME: Duplicates?
}
void SfxAllEnumItem::InsertValue( sal_uInt16 nValue )
{
- SfxAllEnumValue_Impl *pVal = new SfxAllEnumValue_Impl;
- pVal->nValue = nValue;
- pVal->aText = OUString::number(nValue);
+ SfxAllEnumValue_Impl aVal;
+ aVal.nValue = nValue;
+ aVal.aText = OUString::number(nValue);
if ( !pValues )
pValues = new SfxAllEnumValueArr;
- pValues->Insert( _GetPosByValue(nValue), pVal ); // FIXME: Duplicates?
+ pValues->Insert( _GetPosByValue(nValue), aVal ); // FIXME: Duplicates?
}
void SfxAllEnumItem::DisableValue( sal_uInt16 nValue )
commit 9eda4d7f2f610a7f155146ab775114cf61822a71
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Oct 30 19:06:31 2015 +0100
svl: replace boost::ptr_map with std::map
Change-Id: I87863482a5331b47e71b3e8c9de6e58347aacf24
diff --git a/svl/inc/pch/precompiled_svl.hxx b/svl/inc/pch/precompiled_svl.hxx
index f497d3b..8ecbcce 100644
--- a/svl/inc/pch/precompiled_svl.hxx
+++ b/svl/inc/pch/precompiled_svl.hxx
@@ -18,7 +18,6 @@
#include <algorithm>
#include <boost/noncopyable.hpp>
#include <boost/numeric/conversion/cast.hpp>
-#include <boost/ptr_container/ptr_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <memory>
#include <cassert>
@@ -119,7 +118,6 @@
#include <mdds/multi_type_vector_custom_func1.hpp>
#include <mdds/multi_type_vector_trait.hpp>
#include <mdds/multi_type_vector_types.hpp>
-#include <o3tl/ptr_container.hxx>
#include <osl/diagnose.h>
#include <osl/endian.h>
#include <osl/file.h>
diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx
index 38a625a..9934f12 100644
--- a/svl/source/misc/inettype.cxx
+++ b/svl/source/misc/inettype.cxx
@@ -20,8 +20,8 @@
#include <sal/config.h>
#include <utility>
+#include <map>
-#include <o3tl/ptr_container.hxx>
#include <tools/wldcrd.hxx>
#include <tools/inetmime.hxx>
#include <rtl/instance.hxx>
@@ -29,8 +29,6 @@
#include <svl/inettype.hxx>
#include <svl/svl.hrc>
-#include <boost/ptr_container/ptr_map.hpp>
-
#include "getstringresource.hxx"
namespace
@@ -55,22 +53,24 @@ struct TypeNameMapEntry
OUString m_aExtension;
INetContentType m_eTypeID;
- TypeNameMapEntry():
- m_eTypeID(CONTENT_TYPE_UNKNOWN) {}
+ TypeNameMapEntry(INetContentType const eTypeID, OUString const*const pExtension)
+ : m_aExtension((pExtension) ? *pExtension : OUString())
+ , m_eTypeID(eTypeID)
+ {}
};
struct ExtensionMapEntry
{
INetContentType m_eTypeID;
- ExtensionMapEntry():
- m_eTypeID(CONTENT_TYPE_UNKNOWN) {}
+ ExtensionMapEntry(INetContentType const eTypeID)
+ : m_eTypeID(eTypeID) {}
};
class Registration
{
- typedef boost::ptr_map<OUString, TypeNameMapEntry> TypeNameMap;
- typedef boost::ptr_map<OUString, ExtensionMapEntry> ExtensionMap;
+ typedef std::map<OUString, TypeNameMapEntry> TypeNameMap;
+ typedef std::map<OUString, ExtensionMapEntry> ExtensionMap;
typedef std::map<INetContentType, TypeIDMapEntry*> TypeIDMap;
TypeIDMap m_aTypeIDMap; // map ContentType to TypeID
@@ -443,7 +443,7 @@ TypeNameMapEntry * Registration::getExtensionEntry(OUString const & rTypeName)
Registration &rRegistration = theRegistration::get();
TypeNameMap::iterator it = rRegistration.m_aTypeNameMap.find(aTheTypeName);
if (it != rRegistration.m_aTypeNameMap.end())
- return it->second;
+ return & it->second;
return 0;
}
@@ -468,21 +468,12 @@ INetContentType Registration::RegisterContentType(OUString const & rTypeName,
pTypeIDMapEntry->m_aSystemFileType = *pSystemFileType;
rRegistration.m_aTypeIDMap.insert( ::std::make_pair( eTypeID, pTypeIDMapEntry ) );
- std::unique_ptr<TypeNameMapEntry> pTypeNameMapEntry(new TypeNameMapEntry());
- if (pExtension)
- pTypeNameMapEntry->m_aExtension = *pExtension;
- pTypeNameMapEntry->m_eTypeID = eTypeID;
- o3tl::ptr_container::insert(
- rRegistration.m_aTypeNameMap, aTheTypeName,
- std::move(pTypeNameMapEntry));
+ rRegistration.m_aTypeNameMap.insert(std::make_pair(aTheTypeName,
+ TypeNameMapEntry(eTypeID, pExtension)));
if (pExtension)
{
- std::unique_ptr<ExtensionMapEntry> pExtensionMapEntry(new ExtensionMapEntry());
- pExtensionMapEntry->m_eTypeID = eTypeID;
- o3tl::ptr_container::insert(
- rRegistration.m_aExtensionMap, *pExtension,
- std::move(pExtensionMapEntry));
+ rRegistration.m_aExtensionMap.insert(std::make_pair(*pExtension, ExtensionMapEntry(eTypeID)));
}
return eTypeID;
@@ -496,7 +487,7 @@ INetContentType Registration::GetContentType(OUString const & rTypeName)
OUString aTheTypeName = rTypeName.toAsciiLowerCase();
TypeNameMap::iterator it = rRegistration.m_aTypeNameMap.find(aTheTypeName);
return it != rRegistration.m_aTypeNameMap.end()
- ? it->second->m_eTypeID
+ ? it->second.m_eTypeID
: CONTENT_TYPE_UNKNOWN;
}
@@ -530,7 +521,7 @@ INetContentType Registration::GetContentType4Extension(OUString const & rExtensi
ExtensionMap::iterator it = rRegistration.m_aExtensionMap.find(rExtension);
return it != rRegistration.m_aExtensionMap.end()
- ? it->second->m_eTypeID
+ ? it->second.m_eTypeID
: CONTENT_TYPE_UNKNOWN;
}
commit 87f15b9450be1078b7d0bf070475acff087c15dc
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Oct 30 18:45:21 2015 +0100
sw: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I95ce84f7e82dc03233878de4324f2cb5c282a8aa
diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx
index e6c764e..bcc8c96 100644
--- a/sw/inc/pch/precompiled_sw.hxx
+++ b/sw/inc/pch/precompiled_sw.hxx
@@ -620,7 +620,6 @@
#include <memory>
#include <numeric>
#include <o3tl/numeric.hxx>
-#include <o3tl/ptr_container.hxx>
#include <o3tl/sorted_vector.hxx>
#include <officecfg/Office/Common.hxx>
#include <officecfg/Office/Writer.hxx>
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index b30d571..6fc01a9 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -95,13 +95,13 @@ ImageMap *SwHTMLParser::FindImageMap( const OUString& rName ) const
{
OSL_ENSURE( rName[0] != '#', "FindImageMap: name begins with '#'!" );
- if( pImageMaps )
+ if (m_pImageMaps)
{
- for( auto &rIMap : *pImageMaps )
+ for (auto &rpIMap : *m_pImageMaps)
{
- if( rName.equalsIgnoreAsciiCase( rIMap.GetName() ) )
+ if (rName.equalsIgnoreAsciiCase(rpIMap->GetName()))
{
- return &rIMap;
+ return rpIMap.get();
}
}
}
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 061ce30..2d4c762 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -255,7 +255,7 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCrsr, SvStream& rIn,
pMarquee( 0 ),
pField( 0 ),
pImageMap( 0 ),
- pImageMaps( 0 ),
+ m_pImageMaps(nullptr),
pFootEndNoteImpl( 0 ),
nScriptStartLineNr( 0 ),
nBaseFontStMin( 0 ),
@@ -459,7 +459,7 @@ SwHTMLParser::~SwHTMLParser()
DeleteFootEndNoteImpl();
OSL_ENSURE( !pTable, "Es existiert noch eine offene Tabelle" );
- delete pImageMaps;
+ delete m_pImageMaps;
OSL_ENSURE( !pPendStack,
"SwHTMLParser::~SwHTMLParser: Hier sollte es keinen Pending-Stack mehr geben" );
@@ -1967,9 +1967,9 @@ void SwHTMLParser::NextToken( int nToken )
pImageMap = new ImageMap;
if( ParseMapOptions( pImageMap) )
{
- if( !pImageMaps )
- pImageMaps = new ImageMaps;
- pImageMaps->push_back( pImageMap );
+ if (!m_pImageMaps)
+ m_pImageMaps = new ImageMaps;
+ m_pImageMaps->push_back(std::unique_ptr<ImageMap>(pImageMap));
}
else
{
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 17cbadf..f588312 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -31,8 +31,8 @@
#include "calbck.hxx"
#include "htmlvsh.hxx"
-#include <boost/ptr_container/ptr_vector.hpp>
-
+#include <memory>
+#include <vector>
#include <deque>
class SfxMedium;
@@ -333,7 +333,7 @@ class HTMLTable;
class SwCSS1Parser;
class SwHTMLNumRuleInfo;
-typedef boost::ptr_vector<ImageMap> ImageMaps;
+typedef ::std::vector<std::unique_ptr<ImageMap>> ImageMaps;
#define HTML_CNTXT_PROTECT_STACK 0x0001
#define HTML_CNTXT_STRIP_PARA 0x0002
@@ -402,7 +402,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
SdrObject *pMarquee; // aktuelles Marquee
SwField *pField; // aktuelles Feld
ImageMap *pImageMap; // aktuelle Image-Map
- ImageMaps *pImageMaps;// alle gelesenen Image-Maps
+ ImageMaps *m_pImageMaps; ///< all Image-Maps that have been read
SwHTMLFootEndNote_Impl *pFootEndNoteImpl;
Size aHTMLPageSize; // die Seitengroesse der HTML-Vorlage
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index cb77d85..10e28df 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -19,7 +19,6 @@
#ifndef INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
#define INCLUDED_SW_SOURCE_FILTER_HTML_WRTHTML_HXX
-#include <boost/ptr_container/ptr_vector.hpp>
#include <memory>
#include <vector>
#include <set>
More information about the Libreoffice-commits
mailing list