include/svl/itemiter.hxx | 35 +- include/svl/itemset.hxx | 22 - solenv/gdb/libreoffice/svl.py | 82 ++---- svl/README | 4 svl/source/items/itemiter.cxx | 30 +- svl/source/items/itemset.cxx | 559 ++++++++++++++++++------------------------ xmloff/source/core/xmlimp.cxx | 2 7 files changed, 333 insertions(+), 401 deletions(-)
New commits: commit 931fe670df9b12ded7e6f50c5d209db43c0d5bd3 Author: Michael Stahl <[email protected]> Date: Wed Apr 8 17:27:44 2015 +0200 solenv: there are no more SvArrays in need of pretty printing Change-Id: Ic4d59228f3295e8400bcacf637ff4def7669b775 diff --git a/solenv/gdb/libreoffice/svl.py b/solenv/gdb/libreoffice/svl.py index 41a600c..0504965 100644 --- a/solenv/gdb/libreoffice/svl.py +++ b/solenv/gdb/libreoffice/svl.py @@ -77,84 +77,6 @@ class ItemSetPrinter(object): assert self.pos <= self.count assert len(self.whichids) == self.count -class SvArrayPrinter(object): - '''Prints macro-declared arrays from svl module''' - - def __init__(self, typename, value): - self.typename = typename - self.value = value - - def to_string(self): - if int(self.value['nA']): - return "%s of length %d" % (self.typename, self.value['nA']) - else: - return "empty " + self.typename - - def children(self): - return self._iterator(self.value['pData'], self.value['nA']) - - def display_hint(self): - return 'array' - - class _iterator(six.Iterator): - - def __init__(self, data, count): - self.data = data - self.count = count - self.pos = 0 - self._check_invariant() - - def __iter__(self): - return self - - def __next__(self): - if self.pos == self.count: - raise StopIteration() - - pos = self.pos - elem = self.data[pos] - self.pos = self.pos + 1 - - self._check_invariant() - return (str(pos), elem) - - def _check_invariant(self): - assert self.count >= 0 - if self.count > 0: - assert self.data - assert self.pos >= 0 - assert self.pos <= self.count - - @staticmethod - def query(type): - if type.code == gdb.TYPE_CODE_REF: - type = type.target() - type = type.unqualified().strip_typedefs() - - if not type.tag: - return False - - ushort = gdb.lookup_type('sal_uInt16') - conforming = True - for field in type.fields(): - if field.name == 'pData': - conforming = field.type.code == gdb.TYPE_CODE_PTR - elif field.name == 'nFree': - conforming = field.type == ushort - elif field.name == 'nA': - conforming = field.type == ushort - else: - conforming = False - if not conforming: - return False - - try: - gdb.lookup_type('FnForEach_' + type.tag) - except RuntimeError: - return False - - return True - printer = None def build_pretty_printers(): @@ -163,8 +85,6 @@ def build_pretty_printers(): printer = printing.Printer("libreoffice/svl") printer.add('SfxItemSet', ItemSetPrinter) - # macro-based arrays from svl module - printer.add('SvArray', SvArrayPrinter, SvArrayPrinter.query) def register_pretty_printers(obj): printing.register_pretty_printer(printer, obj) commit b34199bc156527b6aa16858587b8e3cadb647b8c Author: Michael Stahl <[email protected]> Date: Wed Apr 8 17:26:49 2015 +0200 solenv: add GDB pretty printer for SfxItemSet Change-Id: Ibd74c58efa7f1a24de409820655fb98b4fc13df3 diff --git a/solenv/gdb/libreoffice/svl.py b/solenv/gdb/libreoffice/svl.py index 31b4507..41a600c 100644 --- a/solenv/gdb/libreoffice/svl.py +++ b/solenv/gdb/libreoffice/svl.py @@ -12,6 +12,71 @@ import six from libreoffice.util import printing +class ItemSetPrinter(object): + '''Prints SfxItemSets''' + + def __init__(self, typename, value): + self.typename = typename + self.value = value + + def to_string(self): + whichranges = self.which_ranges() + return "SfxItemSet of pool %s with parent %s and Which ranges: %s" \ + % (self.value['m_pPool'], self.value['m_pParent'], whichranges) + + def which_ranges(self): + whichranges = self.value['m_pWhichRanges'] + index = 0 + whiches = [] + while (whichranges[index]): + whiches.append((int(whichranges[index]), int(whichranges[index+1]))) + index = index + 2 + return whiches + + def children(self): + whichranges = self.which_ranges() + size = 0 + whichids = [] + for (whichfrom, whichto) in whichranges: + size += whichto - whichfrom + 1 + whichids += [which for which in range(whichfrom, whichto+1)] + return self._iterator(self.value['m_pItems'], size, whichids) + + class _iterator(six.Iterator): + + def __init__(self, data, count, whichids): + self.data = data + self.whichids = whichids + self.count = count + self.pos = 0 + self._check_invariant() + + def __iter__(self): + return self + + def __next__(self): + if self.pos == self.count: + raise StopIteration() + + which = self.whichids[self.pos] + elem = self.data[self.pos] + self.pos = self.pos + 1 + + self._check_invariant() + if (elem == -1): + elem = "(Invalid)" + elif (elem != 0): + # let's try how well that works... + elem = elem.cast(elem.dynamic_type).dereference() + return (str(which), elem) + + def _check_invariant(self): + assert self.count >= 0 + assert self.data + assert self.pos >= 0 + assert self.pos <= self.count + assert len(self.whichids) == self.count + class SvArrayPrinter(object): '''Prints macro-declared arrays from svl module''' @@ -97,6 +162,7 @@ def build_pretty_printers(): printer = printing.Printer("libreoffice/svl") + printer.add('SfxItemSet', ItemSetPrinter) # macro-based arrays from svl module printer.add('SvArray', SvArrayPrinter, SvArrayPrinter.query) commit 4077b267eba6710925f0cff6186e4dad9d932b7c Author: Michael Stahl <[email protected]> Date: Wed Apr 8 15:39:00 2015 +0200 svl: move SfxItemSet methods together Change-Id: I3f47273f7b648e8c8d261217ba3f9ea8d366b61b diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index e6917ea..22e4318 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -1605,7 +1605,33 @@ int SfxItemSet::PutDirect(const SfxPoolItem &rItem) return sal_False; } +sal_Int32 SfxItemSet::getHash() const +{ + return stringify().hashCode(); +} + +OString SfxItemSet::stringify() const +{ + SvMemoryStream aStream; + SfxItemSet aSet(*this); + aSet.InvalidateDefaultItems(); + aSet.Store(aStream, true); + aStream.Flush(); + return OString( + static_cast<char const *>(aStream.GetData()), aStream.GetEndOfData()); +} +void SfxItemSet::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("sfxItemSet")); + SfxItemIter aIter(*this); + for (const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem()) + pItem->dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); +} + + +// ----------------------------------------------- class SfxAllItemSet SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool ) : SfxItemSet(rPool, (const sal_uInt16*) 0), @@ -1843,31 +1869,4 @@ SfxItemSet *SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const return bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*m_pPool); } - - -sal_Int32 SfxItemSet::getHash() const -{ - return stringify().hashCode(); -} - -OString SfxItemSet::stringify() const -{ - SvMemoryStream aStream; - SfxItemSet aSet(*this); - aSet.InvalidateDefaultItems(); - aSet.Store(aStream, true); - aStream.Flush(); - return OString( - static_cast<char const *>(aStream.GetData()), aStream.GetEndOfData()); -} - -void SfxItemSet::dumpAsXml(xmlTextWriterPtr pWriter) const -{ - xmlTextWriterStartElement(pWriter, BAD_CAST("sfxItemSet")); - SfxItemIter aIter(*this); - for (const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem()) - pItem->dumpAsXml(pWriter); - xmlTextWriterEndElement(pWriter); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit b269f2af94cceafdc5d2df0279eb176f7b08b390 Author: Michael Stahl <[email protected]> Date: Wed Apr 8 15:37:13 2015 +0200 svl: translate some comment in itemset.cxx Change-Id: I0d306854ed295826418ad88ea5c0c72b949eeb22 diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index f1450ad..e6917ea 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -109,8 +109,6 @@ SfxItemSet::SfxItemSet memset(static_cast<void*>(m_pItems), 0, nSize * sizeof(SfxPoolItem*)); } - - SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2) : m_pPool( &rPool ) , m_pParent(nullptr) @@ -121,8 +119,6 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich InitRanges_Impl(nWhich1, nWhich2); } - - void SfxItemSet::InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2) { m_pWhichRanges = new sal_uInt16[ 3 ]; @@ -134,8 +130,6 @@ void SfxItemSet::InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2) memset(static_cast<void*>(m_pItems), 0, nRg * sizeof(SfxPoolItem*)); } - - void SfxItemSet::InitRanges_Impl(va_list pArgs, sal_uInt16 nWh1, sal_uInt16 nWh2, sal_uInt16 nNull) { sal_uInt16 nSize = InitializeRanges_Impl(m_pWhichRanges, pArgs, nWh1, nWh2, nNull); @@ -143,8 +137,6 @@ void SfxItemSet::InitRanges_Impl(va_list pArgs, sal_uInt16 nWh1, sal_uInt16 nWh2 memset(static_cast<void*>(m_pItems), 0, sizeof(SfxPoolItem*) * nSize); } - - SfxItemSet::SfxItemSet(SfxItemPool& rPool, USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ...) : m_pPool( &rPool ) @@ -169,8 +161,6 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool, } } - - void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable) { sal_uInt16 nCnt = 0; @@ -189,9 +179,6 @@ void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable) memcpy( m_pWhichRanges, pWhichPairTable, sizeof( sal_uInt16 ) * cnt ); } - - - SfxItemSet::SfxItemSet( SfxItemPool& rPool, const sal_uInt16* pWhichPairTable ) : m_pPool(&rPool) , m_pParent(nullptr) @@ -199,7 +186,7 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, const sal_uInt16* pWhichPairTable ) , m_pWhichRanges(nullptr) , m_nCount(0) { - // pWhichPairTable == 0 ist f"ur das SfxAllEnumItemSet + // pWhichPairTable == 0 is for the SfxAllEnumItemSet if ( pWhichPairTable ) InitRanges_Impl(pWhichPairTable); } @@ -246,8 +233,6 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ) memcpy( m_pWhichRanges, rASet.m_pWhichRanges, sizeof( sal_uInt16 ) * cnt); } - - SfxItemSet::~SfxItemSet() { sal_uInt16 nCount = TotalCount(); @@ -271,14 +256,12 @@ SfxItemSet::~SfxItemSet() } } - // FIXME: could be delete[] (SfxPoolItem **)m_pItems; delete[] m_pItems; if (m_pWhichRanges != m_pPool->GetFrozenIdRanges()) delete[] m_pWhichRanges; m_pWhichRanges = nullptr; // for invariant-testing } - /** * Delete single Items or all Items (nWhich == 0) */ @@ -376,8 +359,6 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) return nDel; } - - void SfxItemSet::ClearInvalidItems( bool bHardDefault ) { sal_uInt16* pPtr = m_pWhichRanges; @@ -428,8 +409,6 @@ void SfxItemSet::InvalidateAllItems() memset(static_cast<void*>(m_pItems), -1, m_nCount * sizeof(SfxPoolItem*)); } - - SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const @@ -486,8 +465,6 @@ bool SfxItemSet::HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem) const return bRet; } - - const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich ) { if ( !nWhich ) @@ -563,8 +540,6 @@ const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich return 0; } - - bool SfxItemSet::Put( const SfxItemSet& rSet, bool bInvalidAsDefault ) { bool bRet = false; @@ -595,7 +570,6 @@ bool SfxItemSet::Put( const SfxItemSet& rSet, bool bInvalidAsDefault ) return bRet; } - /** * This method takes the Items from the 'rSet' and adds to '*this'. * Which ranges in '*this' that are non-existent in 'rSet' will not @@ -676,7 +650,6 @@ void SfxItemSet::PutExtended } } - /** * Expands the ranges of settable items by 'nFrom' to 'nTo'. Keeps state of * items which are new ranges too. @@ -694,7 +667,6 @@ void SfxItemSet::MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo ) SetRanges( aRanges ); } - /** * Modifies the ranges of settable items. Keeps state of items which * are new ranges too. @@ -783,7 +755,6 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges ) } } - /** * The SfxItemSet takes over exactly those SfxPoolItems that are * set in rSet and are in their own Which range. All others are removed. @@ -883,9 +854,6 @@ const SfxPoolItem* SfxItemSet::GetItem return 0; } - - - const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const { // Search the Range in which the Which is located in: @@ -942,8 +910,6 @@ void SfxItemSet::Changed( const SfxPoolItem&, const SfxPoolItem& ) { } - - sal_uInt16 SfxItemSet::TotalCount() const { sal_uInt16 nRet = 0; @@ -956,7 +922,6 @@ sal_uInt16 SfxItemSet::TotalCount() const return nRet; } - /** * Only retain the Items that are also present in rSet * (nevermind their value). @@ -1037,8 +1002,6 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet ) } } - - void SfxItemSet::Differentiate( const SfxItemSet& rSet ) { if( !Count() || !rSet.Count() )// None set? @@ -1108,7 +1071,6 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet ) } } - /** * Decision table for MergeValue(s) * @@ -1307,8 +1269,6 @@ void SfxItemSet::MergeValues( const SfxItemSet& rSet, bool bIgnoreDefaults ) } } - - void SfxItemSet::MergeValue( const SfxPoolItem& rAttr, bool bIgnoreDefaults ) { SfxItemArray ppFnd = m_pItems; @@ -1328,8 +1288,6 @@ void SfxItemSet::MergeValue( const SfxPoolItem& rAttr, bool bIgnoreDefaults ) } } - - void SfxItemSet::InvalidateItem( sal_uInt16 nWhich ) { SfxItemArray ppFnd = m_pItems; @@ -1361,8 +1319,6 @@ void SfxItemSet::InvalidateItem( sal_uInt16 nWhich ) } } - - sal_uInt16 SfxItemSet::GetWhichByPos( sal_uInt16 nPos ) const { sal_uInt16 n = 0; @@ -1379,7 +1335,6 @@ sal_uInt16 SfxItemSet::GetWhichByPos( sal_uInt16 nPos ) const return 0; } - /** * Saves the SfxItemSet instance to the supplied Stream. * The surrogates as well as the ones with 'bDirect == true' are saved @@ -1438,7 +1393,6 @@ SvStream &SfxItemSet::Store return rStream; } - /** * This method loads an SfxItemSet from a stream. * If the SfxItemPool was loaded without RefCounts the loaded Item @@ -1517,8 +1471,6 @@ SvStream &SfxItemSet::Load return rStream; } - - bool SfxItemSet::operator==(const SfxItemSet &rCmp) const { // Values we can get quickly need to be the same @@ -1585,8 +1537,6 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const return true; } - - SfxItemSet *SfxItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const { if (pToPool && pToPool != m_pPool) @@ -1612,8 +1562,6 @@ SfxItemSet *SfxItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const : new SfxItemSet(*m_pPool, m_pWhichRanges); } - - int SfxItemSet::PutDirect(const SfxPoolItem &rItem) { SfxItemArray ppFnd = m_pItems; @@ -1672,10 +1620,6 @@ SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool ) memset( m_pWhichRanges, 0, (nInitCount + 1) * sizeof(sal_uInt16) ); } - - - - SfxAllItemSet::SfxAllItemSet(const SfxItemSet &rCopy) : SfxItemSet(rCopy), aDefault(0), @@ -1683,9 +1627,6 @@ SfxAllItemSet::SfxAllItemSet(const SfxItemSet &rCopy) { } - - - /** * Explicitly define this ctor to avoid auto-generation by the compiler. * The compiler does not take the ctor with the 'const SfxItemSet&'! @@ -1697,7 +1638,6 @@ SfxAllItemSet::SfxAllItemSet(const SfxAllItemSet &rCopy) { } - /** * This internal function creates a new WhichRanges array, which is copied * from the 'nOldSize'-USHORTs long 'pUS'. It has new USHORTs at the end instead @@ -1725,7 +1665,6 @@ static sal_uInt16 *AddRanges_Impl( return pNew; } - /** * This internal function creates a new ItemArray, which is copied from 'pItems', * but has room for a new ItemPointer at 'nPos'. @@ -1759,7 +1698,6 @@ static SfxItemArray AddItem_Impl(SfxItemArray pItems, sal_uInt16 nOldSize, sal_u return pNew; } - /** * Putting with automatic extension of the WhichId with the ID of the Item. */ @@ -1883,7 +1821,6 @@ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhi return &rNew; } - /** * Disable Item * Using a VoidItem with Which value 0 @@ -1893,8 +1830,6 @@ void SfxItemSet::DisableItem(sal_uInt16 nWhich) Put( SfxVoidItem(0), nWhich ); } - - SfxItemSet *SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const { if (pToPool && pToPool != m_pPool) @@ -1915,8 +1850,6 @@ sal_Int32 SfxItemSet::getHash() const return stringify().hashCode(); } - - OString SfxItemSet::stringify() const { SvMemoryStream aStream; commit ff6448194adb34dd86a6623362656037ed68b9e0 Author: Michael Stahl <[email protected]> Date: Wed Apr 8 15:17:04 2015 +0200 svl: prefix members of SfxItemIter Change-Id: I0d2bcf306a789f1eaa0760c69ced427c0ec70ef8 diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx index 626ff43..691a734 100644 --- a/include/svl/itemiter.hxx +++ b/include/svl/itemiter.hxx @@ -28,31 +28,38 @@ class SfxItemPool; class SVL_DLLPUBLIC SfxItemIter { - // Item-Feld - Start & Ende - const SfxItemSet& _rSet; - sal_uInt16 _nStt, _nEnd, _nAkt; + const SfxItemSet& m_rSet; + sal_uInt16 m_nStart; + sal_uInt16 m_nEnd; + sal_uInt16 m_nCurrent; public: SfxItemIter( const SfxItemSet& rSet ); ~SfxItemIter(); - // falls es diese gibt, returne sie, sonst 0 + /// get item, or null if no items const SfxPoolItem* FirstItem() - { _nAkt = _nStt; - return _rSet.m_nCount ? *(_rSet.m_pItems+_nAkt) : nullptr; } + { + m_nCurrent = m_nStart; + return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr; + } const SfxPoolItem* LastItem() - { _nAkt = _nEnd; - return _rSet.m_nCount ? *(_rSet.m_pItems+_nAkt) : nullptr; } + { + m_nCurrent = m_nEnd; + return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr; + } const SfxPoolItem* GetCurItem() - { return _rSet.m_nCount ? *(_rSet.m_pItems+_nAkt) : nullptr; } + { + return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr; + } const SfxPoolItem* NextItem(); - bool IsAtStart() const { return _nAkt == _nStt; } - bool IsAtEnd() const { return _nAkt == _nEnd; } + bool IsAtStart() const { return m_nCurrent == m_nStart; } + bool IsAtEnd() const { return m_nCurrent == m_nEnd; } - sal_uInt16 GetCurPos() const { return _nAkt; } - sal_uInt16 GetFirstPos() const { return _nStt; } - sal_uInt16 GetLastPos() const { return _nEnd; } + sal_uInt16 GetCurPos() const { return m_nCurrent; } + sal_uInt16 GetFirstPos() const { return m_nStart; } + sal_uInt16 GetLastPos() const { return m_nEnd; } }; #endif diff --git a/svl/source/items/itemiter.cxx b/svl/source/items/itemiter.cxx index e34af13..7b026e6 100644 --- a/svl/source/items/itemiter.cxx +++ b/svl/source/items/itemiter.cxx @@ -23,28 +23,28 @@ #include <svl/itemset.hxx> SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet ) - : _rSet( rItemSet ) + : m_rSet( rItemSet ) { - if (!_rSet.m_nCount) + if (!m_rSet.m_nCount) { - _nStt = 1; - _nEnd = 0; + m_nStart = 1; + m_nEnd = 0; } else { - SfxItemArray ppFnd = _rSet.m_pItems; + SfxItemArray ppFnd = m_rSet.m_pItems; // Find the first Item that is set - for ( _nStt = 0; !*(ppFnd + _nStt ); ++_nStt ) + for (m_nStart = 0; !*(ppFnd + m_nStart ); ++m_nStart) ; // empty loop - if ( 1 < _rSet.Count() ) - for( _nEnd = _rSet.TotalCount(); !*( ppFnd + --_nEnd); ) + if (1 < m_rSet.Count()) + for (m_nEnd = m_rSet.TotalCount(); !*(ppFnd + --m_nEnd); ) ; // empty loop else - _nEnd = _nStt; + m_nEnd = m_nStart; } - _nAkt = _nStt; + m_nCurrent = m_nStart; } SfxItemIter::~SfxItemIter() @@ -53,14 +53,14 @@ SfxItemIter::~SfxItemIter() const SfxPoolItem* SfxItemIter::NextItem() { - SfxItemArray ppFnd = _rSet.m_pItems; + SfxItemArray ppFnd = m_rSet.m_pItems; - if( _nAkt < _nEnd ) + if (m_nCurrent < m_nEnd) { do { - _nAkt++; - } while( _nAkt < _nEnd && !*(ppFnd + _nAkt ) ); - return *(ppFnd+_nAkt); + m_nCurrent++; + } while (m_nCurrent < m_nEnd && !*(ppFnd + m_nCurrent )); + return *(ppFnd+m_nCurrent); } return 0; } commit 4b3a535ae311546066471cf9c2584fc4bfd65cc6 Author: Michael Stahl <[email protected]> Date: Wed Apr 8 15:02:47 2015 +0200 svl: prefix members of SfxItemSet Change-Id: I801aaa8ad9a4ff08dedd2f92b09d98c870c725b8 diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx index a779449..626ff43 100644 --- a/include/svl/itemiter.hxx +++ b/include/svl/itemiter.hxx @@ -39,12 +39,12 @@ public: // falls es diese gibt, returne sie, sonst 0 const SfxPoolItem* FirstItem() { _nAkt = _nStt; - return _rSet._nCount ? *(_rSet._aItems+_nAkt) : 0; } + return _rSet.m_nCount ? *(_rSet.m_pItems+_nAkt) : nullptr; } const SfxPoolItem* LastItem() { _nAkt = _nEnd; - return _rSet._nCount ? *(_rSet._aItems+_nAkt) : 0; } + return _rSet.m_nCount ? *(_rSet.m_pItems+_nAkt) : nullptr; } const SfxPoolItem* GetCurItem() - { return _rSet._nCount ? *(_rSet._aItems+_nAkt) : 0; } + { return _rSet.m_nCount ? *(_rSet.m_pItems+_nAkt) : nullptr; } const SfxPoolItem* NextItem(); bool IsAtStart() const { return _nAkt == _nStt; } diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index af85023..75f7250 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -41,11 +41,11 @@ class SVL_DLLPUBLIC SfxItemSet { friend class SfxItemIter; - SfxItemPool* _pPool; // pool, which is used - const SfxItemSet* _pParent; // derivation - SfxItemArray _aItems; // field of items - sal_uInt16* _pWhichRanges; // array of Which Ranges - sal_uInt16 _nCount; // number of items + SfxItemPool* m_pPool; ///< pool that stores the items + const SfxItemSet* m_pParent; ///< derivation + SfxItemArray m_pItems; ///< array of items + sal_uInt16* m_pWhichRanges; ///< array of Which Ranges + sal_uInt16 m_nCount; ///< number of items friend class SfxItemPoolCache; friend class SfxAllItemSet; @@ -57,7 +57,7 @@ private: SVL_DLLPRIVATE void InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2); public: - SfxItemArray GetItems_Impl() const { return _aItems; } + SfxItemArray GetItems_Impl() const { return m_pItems; } private: const SfxItemSet& operator=(const SfxItemSet &) SAL_DELETED_FUNCTION; @@ -80,7 +80,7 @@ public: virtual SfxItemSet * Clone(bool bItems = true, SfxItemPool *pToPool = 0) const; // Get number of items - sal_uInt16 Count() const { return _nCount; } + sal_uInt16 Count() const { return m_nCount; } sal_uInt16 TotalCount() const; const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const; @@ -123,11 +123,11 @@ public: void Differentiate( const SfxItemSet& rSet ); void MergeValue( const SfxPoolItem& rItem, bool bOverwriteDefaults = false ); - SfxItemPool* GetPool() const { return _pPool; } - const sal_uInt16* GetRanges() const { return _pWhichRanges; } + SfxItemPool* GetPool() const { return m_pPool; } + const sal_uInt16* GetRanges() const { return m_pWhichRanges; } void SetRanges( const sal_uInt16 *pRanges ); void MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo ); - const SfxItemSet* GetParent() const { return _pParent; } + const SfxItemSet* GetParent() const { return m_pParent; } SvStream & Load( SvStream &, bool bDirect = false, const SfxItemPool *pRefPool = 0 ); @@ -141,7 +141,7 @@ public: inline void SfxItemSet::SetParent( const SfxItemSet* pNew ) { - _pParent = pNew; + m_pParent = pNew; } class SVL_DLLPUBLIC SfxAllItemSet: public SfxItemSet diff --git a/svl/README b/svl/README index 1eb3d80..2665c1a 100644 --- a/svl/README +++ b/svl/README @@ -44,7 +44,7 @@ set's SfxItemPool, and for poolable items only a single instance that compares equal under the predicate operator== will be stored in the pool, regardless of how many sets contain it, thus conserving memory. -There are members _pWhichRanges for the valid ranges (as pairs of WhichIds), -_nCount for the number of items contained, and _aItems for the pointers to +There are members m_pWhichRanges for the valid ranges (as pairs of WhichIds), +m_nCount for the number of items contained, and m_pItems for the pointers to the actual items. diff --git a/svl/source/items/itemiter.cxx b/svl/source/items/itemiter.cxx index 960a915..e34af13 100644 --- a/svl/source/items/itemiter.cxx +++ b/svl/source/items/itemiter.cxx @@ -25,14 +25,14 @@ SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet ) : _rSet( rItemSet ) { - if ( !_rSet._nCount ) + if (!_rSet.m_nCount) { _nStt = 1; _nEnd = 0; } else { - SfxItemArray ppFnd = _rSet._aItems; + SfxItemArray ppFnd = _rSet.m_pItems; // Find the first Item that is set for ( _nStt = 0; !*(ppFnd + _nStt ); ++_nStt ) @@ -53,7 +53,7 @@ SfxItemIter::~SfxItemIter() const SfxPoolItem* SfxItemIter::NextItem() { - SfxItemArray ppFnd = _rSet._aItems; + SfxItemArray ppFnd = _rSet.m_pItems; if( _nAkt < _nEnd ) { diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index d2c3ed1..f1450ad 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -51,7 +51,7 @@ const sal_Char *DbgCheckItemSet( const void* pVoid ) sal_uInt16 nCount = 0, n = 0; for ( sal_uInt16 nWh = aIter.FirstWhich(); nWh; nWh = aIter.NextWhich(), ++n ) { - const SfxPoolItem *pItem = pSet->_aItems[n]; + const SfxPoolItem *pItem = pSet->m_pItems[n]; if ( pItem ) { ++nCount; @@ -66,7 +66,7 @@ const sal_Char *DbgCheckItemSet( const void* pVoid ) } } - assert(pSet->_nCount == nCount); + assert(pSet->m_nCount == nCount); return 0; } @@ -86,9 +86,9 @@ SfxItemSet::SfxItemSet added to this SfxItemSet */ bool bTotalRanges /* Take over complete pool ranges? */ ) -: _pPool( &rPool ), - _pParent( 0 ), - _nCount( 0 ) + : m_pPool( &rPool ) + , m_pParent(nullptr) + , m_nCount(0) { // DBG_ASSERT( bTotalRanges || abs( &bTotalRanges - this ) < 1000, // "please use suitable ranges" ); @@ -99,22 +99,22 @@ SfxItemSet::SfxItemSet (void) bTotalRanges; // avoid warnings #endif - _pWhichRanges = const_cast<sal_uInt16*>(_pPool->GetFrozenIdRanges()); - assert( _pWhichRanges && "don't create ItemSets with full range before FreezeIdRanges()" ); - if ( !_pWhichRanges ) - _pPool->FillItemIdRanges_Impl( _pWhichRanges ); + m_pWhichRanges = const_cast<sal_uInt16*>(m_pPool->GetFrozenIdRanges()); + assert( m_pWhichRanges && "don't create ItemSets with full range before FreezeIdRanges()" ); + if (!m_pWhichRanges) + m_pPool->FillItemIdRanges_Impl( m_pWhichRanges ); const sal_uInt16 nSize = TotalCount(); - _aItems = new const SfxPoolItem* [ nSize ]; - memset( (void*) _aItems, 0, nSize * sizeof( SfxPoolItem* ) ); + m_pItems = new const SfxPoolItem* [ nSize ]; + memset(static_cast<void*>(m_pItems), 0, nSize * sizeof(SfxPoolItem*)); } -SfxItemSet::SfxItemSet( SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2 ): - _pPool( &rPool ), - _pParent( 0 ), - _nCount( 0 ) +SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2) + : m_pPool( &rPool ) + , m_pParent(nullptr) + , m_nCount(0) { assert(nWhich1 <= nWhich2); @@ -125,32 +125,32 @@ SfxItemSet::SfxItemSet( SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhic void SfxItemSet::InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2) { - _pWhichRanges = new sal_uInt16[ 3 ]; - *(_pWhichRanges+0) = nWh1; - *(_pWhichRanges+1) = nWh2; - *(_pWhichRanges+2) = 0; + m_pWhichRanges = new sal_uInt16[ 3 ]; + *(m_pWhichRanges+0) = nWh1; + *(m_pWhichRanges+1) = nWh2; + *(m_pWhichRanges+2) = 0; const sal_uInt16 nRg = nWh2 - nWh1 + 1; - _aItems = new const SfxPoolItem* [ nRg ]; - memset( (void*) _aItems, 0, nRg * sizeof( SfxPoolItem* ) ); + m_pItems = new const SfxPoolItem* [ nRg ]; + memset(static_cast<void*>(m_pItems), 0, nRg * sizeof(SfxPoolItem*)); } void SfxItemSet::InitRanges_Impl(va_list pArgs, sal_uInt16 nWh1, sal_uInt16 nWh2, sal_uInt16 nNull) { - sal_uInt16 nSize = InitializeRanges_Impl( _pWhichRanges, pArgs, nWh1, nWh2, nNull ); - _aItems = new const SfxPoolItem* [ nSize ]; - memset( (void*) _aItems, 0, sizeof( SfxPoolItem* ) * nSize ); + sal_uInt16 nSize = InitializeRanges_Impl(m_pWhichRanges, pArgs, nWh1, nWh2, nNull); + m_pItems = new const SfxPoolItem* [ nSize ]; + memset(static_cast<void*>(m_pItems), 0, sizeof(SfxPoolItem*) * nSize); } -SfxItemSet::SfxItemSet( SfxItemPool& rPool, - USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ... ): - _pPool( &rPool ), - _pParent( 0 ), - _pWhichRanges( 0 ), - _nCount( 0 ) +SfxItemSet::SfxItemSet(SfxItemPool& rPool, + USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ...) + : m_pPool( &rPool ) + , m_pParent(nullptr) + , m_pWhichRanges(nullptr) + , m_nCount(0) { assert(nWh1 <= nWh2); @@ -181,54 +181,54 @@ void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable) pPtr += 2; } - _aItems = new const SfxPoolItem* [ nCnt ]; - memset( (void*) _aItems, 0, sizeof( SfxPoolItem* ) * nCnt ); + m_pItems = new const SfxPoolItem* [ nCnt ]; + memset(static_cast<void*>(m_pItems), 0, sizeof(SfxPoolItem*) * nCnt); std::ptrdiff_t cnt = pPtr - pWhichPairTable +1; - _pWhichRanges = new sal_uInt16[ cnt ]; - memcpy( _pWhichRanges, pWhichPairTable, sizeof( sal_uInt16 ) * cnt ); + m_pWhichRanges = new sal_uInt16[ cnt ]; + memcpy( m_pWhichRanges, pWhichPairTable, sizeof( sal_uInt16 ) * cnt ); } SfxItemSet::SfxItemSet( SfxItemPool& rPool, const sal_uInt16* pWhichPairTable ) - : _pPool(&rPool) - , _pParent(0) - , _aItems(0) - , _pWhichRanges(0) - , _nCount(0) + : m_pPool(&rPool) + , m_pParent(nullptr) + , m_pItems(nullptr) + , m_pWhichRanges(nullptr) + , m_nCount(0) { // pWhichPairTable == 0 ist f"ur das SfxAllEnumItemSet if ( pWhichPairTable ) InitRanges_Impl(pWhichPairTable); } -SfxItemSet::SfxItemSet( const SfxItemSet& rASet ): - _pPool( rASet._pPool ), - _pParent( rASet._pParent ), - _nCount( rASet._nCount ) +SfxItemSet::SfxItemSet( const SfxItemSet& rASet ) + : m_pPool( rASet.m_pPool ) + , m_pParent( rASet.m_pParent ) + , m_nCount( rASet.m_nCount ) { // Calculate the attribute count sal_uInt16 nCnt = 0; - sal_uInt16* pPtr = rASet._pWhichRanges; + sal_uInt16* pPtr = rASet.m_pWhichRanges; while( *pPtr ) { nCnt += ( *(pPtr+1) - *pPtr ) + 1; pPtr += 2; } - _aItems = new const SfxPoolItem* [ nCnt ]; + m_pItems = new const SfxPoolItem* [ nCnt ]; // Copy attributes - SfxItemArray ppDst = _aItems, ppSrc = rASet._aItems; + SfxItemArray ppDst = m_pItems, ppSrc = rASet.m_pItems; for( sal_uInt16 n = nCnt; n; --n, ++ppDst, ++ppSrc ) if ( 0 == *ppSrc || // Current Default? IsInvalidItem(*ppSrc) || // DontCare? IsStaticDefaultItem(*ppSrc) ) // Defaults that are not to be pooled? // Just copy the pointer *ppDst = *ppSrc; - else if ( _pPool->IsItemFlag( **ppSrc, SFX_ITEM_POOLABLE ) ) + else if (m_pPool->IsItemFlag( **ppSrc, SFX_ITEM_POOLABLE )) { // Just copy the pointer and increase RefCount *ppDst = *ppSrc; @@ -238,12 +238,12 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ): *ppDst = (*ppSrc)->Clone(); else // !IsPoolable() => assign via Pool - *ppDst = &_pPool->Put( **ppSrc ); + *ppDst = &m_pPool->Put( **ppSrc ); // Copy the WhichRanges - std::ptrdiff_t cnt = pPtr - rASet._pWhichRanges+1; - _pWhichRanges = new sal_uInt16[ cnt ]; - memcpy( _pWhichRanges, rASet._pWhichRanges, sizeof( sal_uInt16 ) * cnt); + std::ptrdiff_t cnt = pPtr - rASet.m_pWhichRanges+1; + m_pWhichRanges = new sal_uInt16[ cnt ]; + memcpy( m_pWhichRanges, rASet.m_pWhichRanges, sizeof( sal_uInt16 ) * cnt); } @@ -253,7 +253,7 @@ SfxItemSet::~SfxItemSet() sal_uInt16 nCount = TotalCount(); if( Count() ) { - SfxItemArray ppFnd = _aItems; + SfxItemArray ppFnd = m_pItems; for( sal_uInt16 nCnt = nCount; nCnt; --nCnt, ++ppFnd ) if( *ppFnd && !IsInvalidItem(*ppFnd) ) { @@ -266,16 +266,16 @@ SfxItemSet::~SfxItemSet() else if ( !IsDefaultItem(*ppFnd) ) // Delete from Pool - _pPool->Remove( **ppFnd ); + m_pPool->Remove( **ppFnd ); } } } - // FIXME: could be delete[] (SfxPoolItem **)_aItems; - delete[] _aItems; - if ( _pWhichRanges != _pPool->GetFrozenIdRanges() ) - delete[] _pWhichRanges; - _pWhichRanges = 0; // for invariant-testing + // FIXME: could be delete[] (SfxPoolItem **)m_pItems; + delete[] m_pItems; + if (m_pWhichRanges != m_pPool->GetFrozenIdRanges()) + delete[] m_pWhichRanges; + m_pWhichRanges = nullptr; // for invariant-testing } @@ -288,11 +288,11 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) return 0; sal_uInt16 nDel = 0; - SfxItemArray ppFnd = _aItems; + SfxItemArray ppFnd = m_pItems; if( nWhich ) { - const sal_uInt16* pPtr = _pWhichRanges; + const sal_uInt16* pPtr = m_pWhichRanges; while( *pPtr ) { // Within this range? @@ -303,7 +303,7 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) if( *ppFnd ) { // Due to the assertions in the sub calls, we need to do the following - --_nCount; + --m_nCount; const SfxPoolItem *pItemToClear = *ppFnd; *ppFnd = 0; @@ -311,14 +311,14 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) { if ( nWhich <= SFX_WHICH_MAX ) { - const SfxPoolItem& rNew = _pParent - ? _pParent->Get( nWhich, true ) - : _pPool->GetDefaultItem( nWhich ); + const SfxPoolItem& rNew = m_pParent + ? m_pParent->Get( nWhich, true ) + : m_pPool->GetDefaultItem( nWhich ); Changed( *pItemToClear, rNew ); } if ( pItemToClear->Which() ) - _pPool->Remove( *pItemToClear ); + m_pPool->Remove( *pItemToClear ); } ++nDel; } @@ -332,16 +332,16 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) } else { - nDel = _nCount; + nDel = m_nCount; - sal_uInt16* pPtr = _pWhichRanges; + sal_uInt16* pPtr = m_pWhichRanges; while( *pPtr ) { for( nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd ) if( *ppFnd ) { // Due to the assertions in the sub calls, we need to do this - --_nCount; + --m_nCount; const SfxPoolItem *pItemToClear = *ppFnd; *ppFnd = 0; @@ -349,9 +349,9 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) { if ( nWhich <= SFX_WHICH_MAX ) { - const SfxPoolItem& rNew = _pParent - ? _pParent->Get( nWhich, true ) - : _pPool->GetDefaultItem( nWhich ); + const SfxPoolItem& rNew = m_pParent + ? m_pParent->Get( nWhich, true ) + : m_pPool->GetDefaultItem( nWhich ); Changed( *pItemToClear, rNew ); } @@ -366,7 +366,7 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) else { // remove item from pool - _pPool->Remove( *pItemToClear ); + m_pPool->Remove( *pItemToClear ); } } } @@ -380,14 +380,14 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich ) void SfxItemSet::ClearInvalidItems( bool bHardDefault ) { - sal_uInt16* pPtr = _pWhichRanges; - SfxItemArray ppFnd = _aItems; + sal_uInt16* pPtr = m_pWhichRanges; + SfxItemArray ppFnd = m_pItems; if ( bHardDefault ) while( *pPtr ) { for ( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd ) if ( IsInvalidItem(*ppFnd) ) - *ppFnd = &_pPool->Put( _pPool->GetDefaultItem(nWhich) ); + *ppFnd = &m_pPool->Put( m_pPool->GetDefaultItem(nWhich) ); pPtr += 2; } else @@ -397,7 +397,7 @@ void SfxItemSet::ClearInvalidItems( bool bHardDefault ) if( IsInvalidItem(*ppFnd) ) { *ppFnd = 0; - --_nCount; + --m_nCount; } pPtr += 2; } @@ -405,15 +405,16 @@ void SfxItemSet::ClearInvalidItems( bool bHardDefault ) void SfxItemSet::InvalidateDefaultItems() { - sal_uInt16* pPtr = _pWhichRanges; - SfxItemArray ppFnd = _aItems; + sal_uInt16* pPtr = m_pWhichRanges; + SfxItemArray ppFnd = m_pItems; while( *pPtr ) { for ( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd ) - if ( *ppFnd && *ppFnd != reinterpret_cast<SfxPoolItem *>(-1) && **ppFnd == _pPool->GetDefaultItem( nWhich ) ) + if (*ppFnd && *ppFnd != reinterpret_cast<SfxPoolItem *>(-1) + && **ppFnd == m_pPool->GetDefaultItem(nWhich)) { - _pPool->Remove( **ppFnd ); + m_pPool->Remove( **ppFnd ); *ppFnd = reinterpret_cast<SfxPoolItem*>(-1); } pPtr += 2; @@ -422,9 +423,9 @@ void SfxItemSet::InvalidateDefaultItems() void SfxItemSet::InvalidateAllItems() { - assert( !_nCount && "There are still Items set" ); - - memset( (void*)_aItems, -1, ( _nCount = TotalCount() ) * sizeof( SfxPoolItem*) ); + assert( !m_nCount && "There are still Items set" ); + m_nCount = TotalCount(); + memset(static_cast<void*>(m_pItems), -1, m_nCount * sizeof(SfxPoolItem*)); } @@ -438,8 +439,8 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich, SfxItemState eRet = SfxItemState::UNKNOWN; do { - SfxItemArray ppFnd = pAktSet->_aItems; - const sal_uInt16* pPtr = pAktSet->_pWhichRanges; + SfxItemArray ppFnd = pAktSet->m_pItems; + const sal_uInt16* pPtr = pAktSet->m_pWhichRanges; if (pPtr) { while ( *pPtr ) @@ -473,7 +474,7 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich, pPtr += 2; } } - } while( bSrchInParent && 0 != ( pAktSet = pAktSet->_pParent )); + } while (bSrchInParent && nullptr != (pAktSet = pAktSet->m_pParent)); return eRet; } @@ -492,8 +493,8 @@ const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich if ( !nWhich ) return 0; //FIXME: Only because of Outliner bug - SfxItemArray ppFnd = _aItems; - const sal_uInt16* pPtr = _pWhichRanges; + SfxItemArray ppFnd = m_pItems; + const sal_uInt16* pPtr = m_pWhichRanges; while( *pPtr ) { if( *pPtr <= nWhich && nWhich <= *(pPtr+1) ) @@ -509,14 +510,14 @@ const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich // Will 'dontcare' or 'disabled' be overwritten with some real value? if ( rItem.Which() && ( IsInvalidItem(*ppFnd) || !(*ppFnd)->Which() ) ) { - *ppFnd = &_pPool->Put( rItem, nWhich ); + *ppFnd = &m_pPool->Put( rItem, nWhich ); return *ppFnd; } // Turns into disabled? if( !rItem.Which() ) { - *ppFnd = rItem.Clone(_pPool); + *ppFnd = rItem.Clone(m_pPool); return 0; } else @@ -526,32 +527,32 @@ const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich return 0; // Add the new one, remove the old one - const SfxPoolItem& rNew = _pPool->Put( rItem, nWhich ); + const SfxPoolItem& rNew = m_pPool->Put( rItem, nWhich ); const SfxPoolItem* pOld = *ppFnd; *ppFnd = &rNew; if(nWhich <= SFX_WHICH_MAX) Changed( *pOld, rNew ); - _pPool->Remove( *pOld ); + m_pPool->Remove( *pOld ); } } else { - ++_nCount; + ++m_nCount; if( !rItem.Which() ) - *ppFnd = rItem.Clone(_pPool); + *ppFnd = rItem.Clone(m_pPool); else { - const SfxPoolItem& rNew = _pPool->Put( rItem, nWhich ); + const SfxPoolItem& rNew = m_pPool->Put( rItem, nWhich ); *ppFnd = &rNew; if (nWhich <= SFX_WHICH_MAX ) { - const SfxPoolItem& rOld = _pParent - ? _pParent->Get( nWhich, true ) - : _pPool->GetDefaultItem( nWhich ); + const SfxPoolItem& rOld = m_pParent + ? m_pParent->Get( nWhich, true ) + : m_pPool->GetDefaultItem( nWhich ); Changed( rOld, rNew ); } } } - SFX_ASSERT( !_pPool->IsItemFlag(nWhich, SFX_ITEM_POOLABLE) || + SFX_ASSERT( !m_pPool->IsItemFlag(nWhich, SFX_ITEM_POOLABLE) || rItem.ISA(SfxSetItem) || **ppFnd == rItem, nWhich, "putted Item unequal" ); return *ppFnd; @@ -569,8 +570,8 @@ bool SfxItemSet::Put( const SfxItemSet& rSet, bool bInvalidAsDefault ) bool bRet = false; if( rSet.Count() ) { - SfxItemArray ppFnd = rSet._aItems; - const sal_uInt16* pPtr = rSet._pWhichRanges; + SfxItemArray ppFnd = rSet.m_pItems; + const sal_uInt16* pPtr = rSet.m_pWhichRanges; while ( *pPtr ) { for ( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd ) @@ -618,8 +619,8 @@ void SfxItemSet::PutExtended ) { // don't "optimize" with "if( rSet.Count()" because of dont-care + defaults - SfxItemArray ppFnd = rSet._aItems; - const sal_uInt16* pPtr = rSet._pWhichRanges; + SfxItemArray ppFnd = rSet.m_pItems; + const sal_uInt16* pPtr = rSet.m_pWhichRanges; while ( *pPtr ) { for ( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd ) @@ -688,7 +689,7 @@ void SfxItemSet::MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo ) return; // merge new range - SfxUShortRanges aRanges( _pWhichRanges ); + SfxUShortRanges aRanges( m_pWhichRanges ); aRanges += SfxUShortRanges( nFrom, nTo ); SetRanges( aRanges ); } @@ -701,9 +702,9 @@ void SfxItemSet::MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo ) void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges ) { // Identical Ranges? - if ( _pWhichRanges == pNewRanges ) + if (m_pWhichRanges == pNewRanges) return; - const sal_uInt16* pOld = _pWhichRanges; + const sal_uInt16* pOld = m_pWhichRanges; const sal_uInt16* pNew = pNewRanges; while ( *pOld == *pNew ) { @@ -716,7 +717,7 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges ) sal_uLong nSize = Capacity_Impl(pNewRanges); SfxItemArray aNewItems = new const SfxPoolItem* [ nSize ]; sal_uInt16 nNewCount = 0; - if ( _nCount == 0 ) + if (m_nCount == 0) memset( aNewItems, 0, nSize * sizeof( SfxPoolItem* ) ); else { @@ -756,29 +757,29 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges ) sal_uInt16 nOldTotalCount = TotalCount(); for ( sal_uInt16 nItem = 0; nItem < nOldTotalCount; ++nItem ) { - const SfxPoolItem *pItem = _aItems[nItem]; + const SfxPoolItem *pItem = m_pItems[nItem]; if ( pItem && !IsInvalidItem(pItem) && pItem->Which() ) - _pPool->Remove(*pItem); + m_pPool->Remove(*pItem); } } // replace old items-array and ranges - delete[] _aItems; - _aItems = aNewItems; - _nCount = nNewCount; + delete[] m_pItems; + m_pItems = aNewItems; + m_nCount = nNewCount; if( pNewRanges == GetPool()->GetFrozenIdRanges() ) { - delete[] _pWhichRanges; - _pWhichRanges = const_cast<sal_uInt16*>(pNewRanges); + delete[] m_pWhichRanges; + m_pWhichRanges = const_cast<sal_uInt16*>(pNewRanges); } else { sal_uInt16 nCount = Count_Impl(pNewRanges) + 1; - if ( _pWhichRanges != _pPool->GetFrozenIdRanges() ) - delete[] _pWhichRanges; - _pWhichRanges = new sal_uInt16[ nCount ]; - memcpy( _pWhichRanges, pNewRanges, sizeof( sal_uInt16 ) * nCount ); + if (m_pWhichRanges != m_pPool->GetFrozenIdRanges()) + delete[] m_pWhichRanges; + m_pWhichRanges = new sal_uInt16[ nCount ]; + memcpy( m_pWhichRanges, pNewRanges, sizeof( sal_uInt16 ) * nCount ); } } @@ -819,7 +820,7 @@ bool SfxItemSet::Set ) { bool bRet = false; - if ( _nCount ) + if (m_nCount) ClearItem(); if ( bDeep ) { @@ -864,7 +865,9 @@ const SfxPoolItem* SfxItemSet::GetItem SfxItemState eState = GetItemState( nWhich, bSrchInParent, &pItem ); if ( bSrchInParent && SfxItemState::DEFAULT == eState && nWhich <= SFX_WHICH_MAX ) - pItem = &_pPool->GetDefaultItem(nWhich); + { + pItem = &m_pPool->GetDefaultItem(nWhich); + } if ( pItem ) { @@ -891,8 +894,8 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const { if( pAktSet->Count() ) { - SfxItemArray ppFnd = pAktSet->_aItems; - const sal_uInt16* pPtr = pAktSet->_pWhichRanges; + SfxItemArray ppFnd = pAktSet->m_pItems; + const sal_uInt16* pPtr = pAktSet->m_pWhichRanges; while( *pPtr ) { if( *pPtr <= nWhich && nWhich <= *(pPtr+1) ) @@ -903,10 +906,10 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const { if( reinterpret_cast<SfxPoolItem*>(-1) == *ppFnd ) { //FIXME: The following code is duplicated further down - SFX_ASSERT(_pPool, nWhich, "no Pool, but status is ambiguous"); + SFX_ASSERT(m_pPool, nWhich, "no Pool, but status is ambiguous"); //!((SfxAllItemSet *)this)->aDefault.SetWhich(nWhich); //!return aDefault; - return _pPool->GetDefaultItem( nWhich ); + return m_pPool->GetDefaultItem( nWhich ); } #ifdef DBG_UTIL const SfxPoolItem *pItem = *ppFnd; @@ -924,11 +927,11 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const //TODO: Search until end of Range: What are we supposed to do now? To the Parent or Default?? // if( !*pPtr ) // Until the end of the search Range? // break; - } while( bSrchInParent && 0 != ( pAktSet = pAktSet->_pParent )); + } while (bSrchInParent && nullptr != (pAktSet = pAktSet->m_pParent)); // Get the Default from the Pool and return - SFX_ASSERT(_pPool, nWhich, "no Pool, but status is ambiguous"); - const SfxPoolItem *pItem = &_pPool->GetDefaultItem( nWhich ); + SFX_ASSERT(m_pPool, nWhich, "no Pool, but status is ambiguous"); + const SfxPoolItem *pItem = &m_pPool->GetDefaultItem( nWhich ); return *pItem; } @@ -944,7 +947,7 @@ void SfxItemSet::Changed( const SfxPoolItem&, const SfxPoolItem& ) sal_uInt16 SfxItemSet::TotalCount() const { sal_uInt16 nRet = 0; - sal_uInt16* pPtr = _pWhichRanges; + sal_uInt16* pPtr = m_pWhichRanges; while( *pPtr ) { nRet += ( *(pPtr+1) - *pPtr ) + 1; @@ -960,7 +963,7 @@ sal_uInt16 SfxItemSet::TotalCount() const */ void SfxItemSet::Intersect( const SfxItemSet& rSet ) { - assert(_pPool && "Not implemented without Pool"); + assert(m_pPool && "Not implemented without Pool"); if( !Count() ) // None set? return; @@ -973,8 +976,8 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet ) // Test whether the Which Ranges are different bool bEqual = true; - sal_uInt16* pWh1 = _pWhichRanges; - sal_uInt16* pWh2 = rSet._pWhichRanges; + sal_uInt16* pWh1 = m_pWhichRanges; + sal_uInt16* pWh2 = rSet.m_pWhichRanges; sal_uInt16 nSize = 0; for( sal_uInt16 n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n ) @@ -992,8 +995,8 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet ) // If the Ranges are identical, we can easily process it if( bEqual ) { - SfxItemArray ppFnd1 = _aItems; - SfxItemArray ppFnd2 = rSet._aItems; + SfxItemArray ppFnd1 = m_pItems; + SfxItemArray ppFnd2 = rSet.m_pItems; for( ; nSize; --nSize, ++ppFnd1, ++ppFnd2 ) if( *ppFnd1 && !*ppFnd2 ) @@ -1004,16 +1007,16 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet ) sal_uInt16 nWhich = (*ppFnd1)->Which(); if(nWhich <= SFX_WHICH_MAX) { - const SfxPoolItem& rNew = _pParent - ? _pParent->Get( nWhich, true ) - : _pPool->GetDefaultItem( nWhich ); + const SfxPoolItem& rNew = m_pParent + ? m_pParent->Get( nWhich, true ) + : m_pPool->GetDefaultItem( nWhich ); Changed( **ppFnd1, rNew ); } - _pPool->Remove( **ppFnd1 ); + m_pPool->Remove( **ppFnd1 ); } *ppFnd1 = 0; - --_nCount; + --m_nCount; } } else @@ -1043,8 +1046,8 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet ) // Test whether the Which Ranges are different bool bEqual = true; - sal_uInt16* pWh1 = _pWhichRanges; - sal_uInt16* pWh2 = rSet._pWhichRanges; + sal_uInt16* pWh1 = m_pWhichRanges; + sal_uInt16* pWh2 = rSet.m_pWhichRanges; sal_uInt16 nSize = 0; for( sal_uInt16 n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n ) @@ -1062,8 +1065,8 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet ) // If the Ranges are identical, we can easily process it if( bEqual ) { - SfxItemArray ppFnd1 = _aItems; - SfxItemArray ppFnd2 = rSet._aItems; + SfxItemArray ppFnd1 = m_pItems; + SfxItemArray ppFnd2 = rSet.m_pItems; for( ; nSize; --nSize, ++ppFnd1, ++ppFnd2 ) if( *ppFnd1 && *ppFnd2 ) @@ -1074,16 +1077,16 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet ) sal_uInt16 nWhich = (*ppFnd1)->Which(); if(nWhich <= SFX_WHICH_MAX) { - const SfxPoolItem& rNew = _pParent - ? _pParent->Get( nWhich, true ) - : _pPool->GetDefaultItem( nWhich ); + const SfxPoolItem& rNew = m_pParent + ? m_pParent->Get( nWhich, true ) + : m_pPool->GetDefaultItem( nWhich ); Changed( **ppFnd1, rNew ); } - _pPool->Remove( **ppFnd1 ); + m_pPool->Remove( **ppFnd1 ); } *ppFnd1 = 0; - --_nCount; + --m_nCount; } } else @@ -1256,8 +1259,8 @@ void SfxItemSet::MergeValues( const SfxItemSet& rSet, bool bIgnoreDefaults ) // Test if the which Ranges are different bool bEqual = true; - sal_uInt16* pWh1 = _pWhichRanges; - sal_uInt16* pWh2 = rSet._pWhichRanges; + sal_uInt16* pWh1 = m_pWhichRanges; + sal_uInt16* pWh2 = rSet.m_pWhichRanges; sal_uInt16 nSize = 0; for( sal_uInt16 n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n ) @@ -1275,11 +1278,11 @@ void SfxItemSet::MergeValues( const SfxItemSet& rSet, bool bIgnoreDefaults ) // If the Ranges match, they are easier to process! if( bEqual ) { - SfxItemArray ppFnd1 = _aItems; - SfxItemArray ppFnd2 = rSet._aItems; + SfxItemArray ppFnd1 = m_pItems; + SfxItemArray ppFnd2 = rSet.m_pItems; for( ; nSize; --nSize, ++ppFnd1, ++ppFnd2 ) - MergeItem_Impl( _pPool, _nCount, ppFnd1, *ppFnd2, bIgnoreDefaults ); + MergeItem_Impl(m_pPool, m_nCount, ppFnd1, *ppFnd2, bIgnoreDefaults); } else { @@ -1308,8 +1311,8 @@ void SfxItemSet::MergeValues( const SfxItemSet& rSet, bool bIgnoreDefaults ) void SfxItemSet::MergeValue( const SfxPoolItem& rAttr, bool bIgnoreDefaults ) { - SfxItemArray ppFnd = _aItems; - const sal_uInt16* pPtr = _pWhichRanges; + SfxItemArray ppFnd = m_pItems; + const sal_uInt16* pPtr = m_pWhichRanges; const sal_uInt16 nWhich = rAttr.Which(); while( *pPtr ) { @@ -1317,7 +1320,7 @@ void SfxItemSet::MergeValue( const SfxPoolItem& rAttr, bool bIgnoreDefaults ) if( *pPtr <= nWhich && nWhich <= *(pPtr+1) ) { ppFnd += nWhich - *pPtr; - MergeItem_Impl( _pPool, _nCount, ppFnd, &rAttr, bIgnoreDefaults ); + MergeItem_Impl(m_pPool, m_nCount, ppFnd, &rAttr, bIgnoreDefaults); break; } ppFnd += *(pPtr+1) - *pPtr + 1; @@ -1329,8 +1332,8 @@ void SfxItemSet::MergeValue( const SfxPoolItem& rAttr, bool bIgnoreDefaults ) void SfxItemSet::InvalidateItem( sal_uInt16 nWhich ) { - SfxItemArray ppFnd = _aItems; - const sal_uInt16* pPtr = _pWhichRanges; + SfxItemArray ppFnd = m_pItems; + const sal_uInt16* pPtr = m_pWhichRanges; while( *pPtr ) { if( *pPtr <= nWhich && nWhich <= *(pPtr+1) ) @@ -1342,14 +1345,14 @@ void SfxItemSet::InvalidateItem( sal_uInt16 nWhich ) { if( reinterpret_cast<SfxPoolItem*>(-1) != *ppFnd ) // Not yet dontcare! { - _pPool->Remove( **ppFnd ); + m_pPool->Remove( **ppFnd ); *ppFnd = reinterpret_cast<SfxPoolItem*>(-1); } } else { *ppFnd = reinterpret_cast<SfxPoolItem*>(-1); - ++_nCount; + ++m_nCount; } break; } @@ -1363,7 +1366,7 @@ void SfxItemSet::InvalidateItem( sal_uInt16 nWhich ) sal_uInt16 SfxItemSet::GetWhichByPos( sal_uInt16 nPos ) const { sal_uInt16 n = 0; - sal_uInt16* pPtr = _pWhichRanges; + sal_uInt16* pPtr = m_pWhichRanges; while( *pPtr ) { n = ( *(pPtr+1) - *pPtr ) + 1; @@ -1383,7 +1386,7 @@ sal_uInt16 SfxItemSet::GetWhichByPos( sal_uInt16 nPos ) const * to the stream in the following way: * * sal_uInt16 ... Count of the set Items - * Count* _pPool->StoreItem() + * Count* m_pPool->StoreItem() * * @see SfxItemPool::StoreItem() const * @see SfxItemSet::Load(SvStream&,bool,const SfxItemPool*) @@ -1395,14 +1398,14 @@ SvStream &SfxItemSet::Store false: Surrogates */ ) const { - assert(_pPool); + assert(m_pPool); // Remember position of the count (to be able to correct it, if need be) sal_uLong nCountPos = rStream.Tell(); - rStream.WriteUInt16( _nCount ); + rStream.WriteUInt16( m_nCount ); // If there's nothing to save, don't construct an ItemIter - if ( _nCount ) + if (m_nCount) { // Keep record of how many Items are really saved sal_uInt16 nWrittenCount = 0; // Count of Items streamed in 'rStream' @@ -1416,13 +1419,13 @@ SvStream &SfxItemSet::Store // Let Items (if need be as a Surrogate) be saved via Pool SAL_WARN_IF(IsInvalidItem(pItem), "svl.items", "can't store invalid items"); if ( !IsInvalidItem(pItem) && - _pPool->StoreItem( rStream, *pItem, bDirect ) ) + m_pPool->StoreItem( rStream, *pItem, bDirect ) ) // Item was streamed in 'rStream' ++nWrittenCount; } // Fewer written than read (e.g. old format) - if ( nWrittenCount != _nCount ) + if (nWrittenCount != m_nCount) { // Store real count in the stream sal_uLong nPos = rStream.Tell(); @@ -1459,11 +1462,11 @@ SvStream &SfxItemSet::Load (e.g. when inserting documents) */ ) { - assert(_pPool); + assert(m_pPool); // No RefPool => Resolve Surrogates with ItemSet's Pool if ( !pRefPool ) - pRefPool = _pPool; + pRefPool = m_pPool; // Load Item count and as many Items sal_uInt16 nCount = 0; @@ -1482,15 +1485,15 @@ SvStream &SfxItemSet::Load { // Load Surrogate/Item and resolve Surrogate const SfxPoolItem *pItem = - _pPool->LoadItem( rStream, bDirect, pRefPool ); + m_pPool->LoadItem( rStream, bDirect, pRefPool ); // Did we load an Item or resolve a Surrogate? if ( pItem ) { // Find position for Item pointer in the set sal_uInt16 nWhich = pItem->Which(); - SfxItemArray ppFnd = _aItems; - const sal_uInt16* pPtr = _pWhichRanges; + SfxItemArray ppFnd = m_pItems; + const sal_uInt16* pPtr = m_pWhichRanges; while ( *pPtr ) { // In this Range?? @@ -1500,7 +1503,7 @@ SvStream &SfxItemSet::Load ppFnd += nWhich - *pPtr; SFX_ASSERT( !*ppFnd, nWhich, "Item is present twice"); *ppFnd = pItem; - ++_nCount; + ++m_nCount; break; } @@ -1519,8 +1522,8 @@ SvStream &SfxItemSet::Load bool SfxItemSet::operator==(const SfxItemSet &rCmp) const { // Values we can get quickly need to be the same - if ( _pParent != rCmp._pParent || - _pPool != rCmp._pPool || + if ( m_pParent != rCmp.m_pParent || + m_pPool != rCmp.m_pPool || Count() != rCmp.Count() ) return false; @@ -1531,9 +1534,10 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const return false; // Are the Ranges themselves unequal? - for ( sal_uInt16 nRange = 0; _pWhichRanges[nRange]; nRange += 2 ) - if ( _pWhichRanges[nRange] != rCmp._pWhichRanges[nRange] || - _pWhichRanges[nRange+1] != rCmp._pWhichRanges[nRange+1] ) + for (sal_uInt16 nRange = 0; m_pWhichRanges[nRange]; nRange += 2) + { + if (m_pWhichRanges[nRange] != rCmp.m_pWhichRanges[nRange] || + m_pWhichRanges[nRange+1] != rCmp.m_pWhichRanges[nRange+1]) { // We must use the slow method then SfxWhichIter aIter( *this ); @@ -1547,21 +1551,22 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const rCmp.GetItemState( nWh, false, &pItem2 ) || ( pItem1 != pItem2 && ( !pItem1 || IsInvalidItem(pItem1) || - ( _pPool->IsItemFlag(*pItem1, SFX_ITEM_POOLABLE) && + (m_pPool->IsItemFlag(*pItem1, SFX_ITEM_POOLABLE) && *pItem1 != *pItem2 ) ) ) ) return false; } return true; } + } // Are all pointers the same? - if ( 0 == memcmp( _aItems, rCmp._aItems, nCount1 * sizeof(_aItems[0]) ) ) + if (0 == memcmp( m_pItems, rCmp.m_pItems, nCount1 * sizeof(m_pItems[0]) )) return true; // We need to compare each one separately then - const SfxPoolItem **ppItem1 = (const SfxPoolItem**) _aItems; - const SfxPoolItem **ppItem2 = (const SfxPoolItem**) rCmp._aItems; + const SfxPoolItem **ppItem1 = m_pItems; + const SfxPoolItem **ppItem2 = rCmp.m_pItems; for ( sal_uInt16 nPos = 0; nPos < nCount1; ++nPos ) { // If the pointers of the poolable Items are not the same, the Items @@ -1569,7 +1574,7 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const if ( *ppItem1 != *ppItem2 && ( ( !*ppItem1 || !*ppItem2 ) || ( IsInvalidItem(*ppItem1) || IsInvalidItem(*ppItem2) ) || - ( _pPool->IsItemFlag(**ppItem1, SFX_ITEM_POOLABLE) ) || + (m_pPool->IsItemFlag(**ppItem1, SFX_ITEM_POOLABLE)) || **ppItem1 != **ppItem2 ) ) return false; @@ -1584,9 +1589,9 @@ bool SfxItemSet::operator==(const SfxItemSet &rCmp) const SfxItemSet *SfxItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const { - if ( pToPool && pToPool != _pPool ) + if (pToPool && pToPool != m_pPool) { - SfxItemSet *pNewSet = new SfxItemSet( *pToPool, _pWhichRanges ); + SfxItemSet *pNewSet = new SfxItemSet(*pToPool, m_pWhichRanges); if ( bItems ) { SfxWhichIter aIter(*pNewSet); @@ -1604,18 +1609,18 @@ SfxItemSet *SfxItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const else return bItems ? new SfxItemSet(*this) - : new SfxItemSet(*_pPool, _pWhichRanges); + : new SfxItemSet(*m_pPool, m_pWhichRanges); } int SfxItemSet::PutDirect(const SfxPoolItem &rItem) { - SfxItemArray ppFnd = _aItems; - const sal_uInt16* pPtr = _pWhichRanges; + SfxItemArray ppFnd = m_pItems; + const sal_uInt16* pPtr = m_pWhichRanges; const sal_uInt16 nWhich = rItem.Which(); #ifdef DBG_UTIL - IsPoolDefaultItem(&rItem) || _pPool->GetSurrogate(&rItem); + IsPoolDefaultItem(&rItem) || m_pPool->GetSurrogate(&rItem); // Only cause assertion in the callees #endif while( *pPtr ) @@ -1629,14 +1634,14 @@ int SfxItemSet::PutDirect(const SfxPoolItem &rItem) { if( rItem == **ppFnd ) return sal_False; // Already present! - _pPool->Remove( *pOld ); + m_pPool->Remove( *pOld ); } else - ++_nCount; + ++m_nCount; // Add the new one if( IsPoolDefaultItem(&rItem) ) - *ppFnd = &_pPool->Put( rItem ); + *ppFnd = &m_pPool->Put( rItem ); else { *ppFnd = &rItem; @@ -1660,11 +1665,11 @@ SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool ) nFree(nInitCount) { // Initially no Items - _aItems = 0; + m_pItems = nullptr; // Allocate nInitCount pairs at USHORTs for Ranges - _pWhichRanges = new sal_uInt16[ nInitCount + 1 ]; - memset( _pWhichRanges, 0, ( nInitCount + 1 ) * sizeof(sal_uInt16) ); + m_pWhichRanges = new sal_uInt16[ nInitCount + 1 ]; + memset( m_pWhichRanges, 0, (nInitCount + 1) * sizeof(sal_uInt16) ); } @@ -1760,11 +1765,11 @@ static SfxItemArray AddItem_Impl(SfxItemArray pItems, sal_uInt16 nOldSize, sal_u */ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich ) { - sal_uInt16 nPos = 0; // Position for 'rItem' in '_aItems' + sal_uInt16 nPos = 0; // Position for 'rItem' in 'm_pItems' const sal_uInt16 nItemCount = TotalCount(); // Let's see first whether there's a suitable Range already - sal_uInt16 *pPtr = _pWhichRanges; + sal_uInt16 *pPtr = m_pWhichRanges; while ( *pPtr ) { // WhichId is within this Range? @@ -1775,7 +1780,7 @@ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhi break; } - // Carry over the position of the Item in _aItems + // Carry over the position of the Item in m_pItems nPos += *(pPtr+1) - *pPtr + 1; // To the next Range @@ -1786,7 +1791,7 @@ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhi if ( !*pPtr ) { // Let's see if we can attach it somewhere - pPtr = _pWhichRanges; + pPtr = m_pWhichRanges; nPos = 0; while ( *pPtr ) { @@ -1797,7 +1802,7 @@ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhi (*pPtr)--; // Make room before first Item of this Range - _aItems = AddItem_Impl(_aItems, nItemCount, nPos); + m_pItems = AddItem_Impl(m_pItems, nItemCount, nPos); break; } @@ -1809,11 +1814,11 @@ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhi // Make room after last Item of this Range nPos += nWhich - *pPtr; - _aItems = AddItem_Impl(_aItems, nItemCount, nPos); + m_pItems = AddItem_Impl(m_pItems, nItemCount, nPos); break; } - // Carry over position of the Item in _aItems + // Carry over position of the Item in m_pItems nPos += *(pPtr+1) - *pPtr + 1; // To the next Range @@ -1824,54 +1829,56 @@ const SfxPoolItem* SfxAllItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhi // No extensible Range found? if ( !*pPtr ) { - // No room left in _pWhichRanges? => Expand! - std::ptrdiff_t nSize = pPtr - _pWhichRanges; + // No room left in m_pWhichRanges? => Expand! + std::ptrdiff_t nSize = pPtr - m_pWhichRanges; if( !nFree ) { - _pWhichRanges = AddRanges_Impl(_pWhichRanges, nSize, nInitCount); + m_pWhichRanges = AddRanges_Impl(m_pWhichRanges, nSize, nInitCount); nFree += nInitCount; } // Attach new WhichRange - pPtr = _pWhichRanges + nSize; + pPtr = m_pWhichRanges + nSize; *pPtr++ = nWhich; *pPtr = nWhich; nFree -= 2; // Expand ItemArray nPos = nItemCount; - _aItems = AddItem_Impl(_aItems, nItemCount, nPos); + m_pItems = AddItem_Impl(m_pItems, nItemCount, nPos); } // Add new Item to Pool - const SfxPoolItem& rNew = _pPool->Put( rItem, nWhich ); + const SfxPoolItem& rNew = m_pPool->Put( rItem, nWhich ); // Remember old Item bool bIncrementCount = false; - const SfxPoolItem* pOld = *( _aItems + nPos ); + const SfxPoolItem* pOld = *( m_pItems + nPos ); if ( reinterpret_cast< SfxPoolItem* >( -1 ) == pOld ) // state "dontcare" pOld = NULL; if ( !pOld ) { bIncrementCount = true; - pOld = _pParent ? - &_pParent->Get( nWhich, true ) - : nWhich <= SFX_WHICH_MAX ? &_pPool->GetDefaultItem( nWhich ) : 0; + pOld = (m_pParent) + ? &m_pParent->Get( nWhich, true ) + : ((nWhich <= SFX_WHICH_MAX) + ? &m_pPool->GetDefaultItem(nWhich) + : nullptr); } // Add new Item to ItemSet - *(_aItems + nPos) = &rNew; + *(m_pItems + nPos) = &rNew; // Send Changed Notification if ( pOld ) { Changed( *pOld, rNew ); if ( !IsDefaultItem(pOld) ) - _pPool->Remove( *pOld ); + m_pPool->Remove( *pOld ); } if ( bIncrementCount ) - ++_nCount; + ++m_nCount; return &rNew; } @@ -1890,7 +1897,7 @@ void SfxItemSet::DisableItem(sal_uInt16 nWhich) SfxItemSet *SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const { - if ( pToPool && pToPool != _pPool ) + if (pToPool && pToPool != m_pPool) { SfxAllItemSet *pNewSet = new SfxAllItemSet( *pToPool ); if ( bItems ) @@ -1898,7 +1905,7 @@ SfxItemSet *SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPool ) const return pNewSet; } else - return bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*_pPool); + return bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*m_pPool); } commit e3efae3ebc593b234058908c82d0f62a30736f40 Author: Michael Stahl <[email protected]> Date: Wed Apr 8 14:22:40 2015 +0200 xmloff: also print what is duplicate Change-Id: I87b5122b8f1f4e26ba16ebc1228fb77f8b7800d9 diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 48b54c4..922f490 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -1435,7 +1435,7 @@ void SvXMLImport::AddStyleDisplayName( sal_uInt16 nFamily, ::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) ); SAL_WARN_IF( !aRes.second, "xmloff.core", - "duplicate style name" ); + "duplicate style name of family " << nFamily << ": \"" << rName << "\""); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
