diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-02 14:28:47 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-03 20:28:17 -0400 |
commit | 1e68b77bb785e5ab9a68e0052436d8e7e8163728 (patch) | |
tree | 2fcdfea69494abbfe617df6d87344c2bf85534b7 | |
parent | 2cf292d9a7ee3667a35350fd949b0cbf4024a8b3 (diff) |
Removed another SV_DECL_PTRARR.
Change-Id: Ib3900d000c6a884c209a06b30e990963d92bc33f
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 196 | ||||
-rw-r--r-- | editeng/source/editeng/editobj2.hxx | 41 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 24 |
3 files changed, 136 insertions, 125 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index a2aaa17855cf..21f0cbfd9a4a 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -80,15 +80,10 @@ XEditAttribute::~XEditAttribute() pItem = 0; // belongs to the Pool. } -XEditAttribute* XEditAttributeList::FindAttrib( sal_uInt16 _nWhich, sal_uInt16 nChar ) const +bool XEditAttribute::IsFeature() const { - for ( sal_uInt16 n = Count(); n; ) - { - XEditAttribute* pAttr = GetObject( --n ); - if( ( pAttr->GetItem()->Which() == _nWhich ) && ( pAttr->GetStart() <= nChar ) && ( pAttr->GetEnd() > nChar ) ) - return pAttr; - } - return NULL; + sal_uInt16 nWhich = pItem->Which(); + return ((nWhich >= EE_FEATURE_START) && (nWhich <= EE_FEATURE_END)); } ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_START, EE_CHAR_END ) @@ -108,11 +103,12 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse aStyle = rCopyFrom.GetStyle(); eFamily = rCopyFrom.GetFamily(); - for ( sal_uInt16 n = 0; n < rCopyFrom.GetAttribs().Count(); n++ ) + for (size_t i = 0; i < rCopyFrom.aAttribs.size(); ++i) { - XEditAttribute* pAttr = rCopyFrom.GetAttribs().GetObject( n ); - XEditAttribute* pMyAttr = MakeXEditAttribute( rPoolToUse, *pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd() ); - aAttribs.Insert( pMyAttr, aAttribs.Count() ); + const XEditAttribute& rAttr = rCopyFrom.aAttribs[i]; + XEditAttribute* pMyAttr = MakeXEditAttribute( + rPoolToUse, *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd()); + aAttribs.push_back(pMyAttr); } if ( rCopyFrom.GetWrongList() ) @@ -121,13 +117,11 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse ContentInfo::~ContentInfo() { - for ( sal_uInt16 nAttr = 0; nAttr < aAttribs.Count(); nAttr++ ) - { - XEditAttribute* pAttr = aAttribs.GetObject(nAttr); - aParaAttribs.GetPool()->Remove( *pAttr->GetItem() ); - delete pAttr; - } - aAttribs.Remove( 0, aAttribs.Count() ); + XEditAttributesType::iterator it = aAttribs.begin(), itEnd = aAttribs.end(); + for (; it != itEnd; ++it) + aParaAttribs.GetPool()->Remove(*it->GetItem()); + aAttribs.clear(); + delete pWrongs; } @@ -147,22 +141,17 @@ bool ContentInfo::operator==( const ContentInfo& rCompare ) const { if( (aText == rCompare.aText) && (aStyle == rCompare.aStyle ) && - (aAttribs.Count() == rCompare.aAttribs.Count() ) && + (aAttribs.size() == rCompare.aAttribs.size()) && (eFamily == rCompare.eFamily ) && (aParaAttribs == rCompare.aParaAttribs ) ) { - const sal_uInt16 nCount = aAttribs.Count(); - if( nCount == rCompare.aAttribs.Count() ) + for (size_t i = 0, n = aAttribs.size(); i < n; ++i) { - sal_uInt16 n; - for( n = 0; n < nCount; n++ ) - { - if( !(*aAttribs.GetObject(n) == *rCompare.aAttribs.GetObject(n)) ) - return false; - } - - return true; + if (aAttribs[i] != rCompare.aAttribs[i]) + return false; } + + return true; } return false; @@ -775,14 +764,14 @@ sal_Bool BinTextObject::HasCharAttribs( sal_uInt16 _nWhich ) const { const ContentInfo& rC = aContents[--nPara]; - sal_uInt16 nAttribs = rC.GetAttribs().Count(); + size_t nAttribs = rC.aAttribs.size(); if ( nAttribs && !_nWhich ) return true; - for ( sal_uInt16 nAttr = nAttribs; nAttr; ) + for (size_t nAttr = nAttribs; nAttr; ) { - XEditAttribute* pX = rC.GetAttribs().GetObject( --nAttr ); - if ( pX->GetItem()->Which() == _nWhich ) + const XEditAttribute& rX = rC.aAttribs[--nAttr]; + if (rX.GetItem()->Which() == _nWhich) return true; } } @@ -793,14 +782,14 @@ void BinTextObject::GetCharAttribs( sal_uInt16 nPara, std::vector<EECharAttrib>& { rLst.clear(); const ContentInfo& rC = aContents[nPara]; - for ( sal_uInt16 nAttr = 0; nAttr < rC.GetAttribs().Count(); nAttr++ ) + for (size_t nAttr = 0; nAttr < rC.aAttribs.size(); ++nAttr) { - XEditAttribute* pAttr = rC.GetAttribs().GetObject( nAttr ); + const XEditAttribute& rAttr = rC.aAttribs[nAttr]; EECharAttrib aEEAttr; - aEEAttr.pAttr = pAttr->GetItem(); + aEEAttr.pAttr = rAttr.GetItem(); aEEAttr.nPara = nPara; - aEEAttr.nStart = pAttr->GetStart(); - aEEAttr.nEnd = pAttr->GetEnd(); + aEEAttr.nStart = rAttr.GetStart(); + aEEAttr.nEnd = rAttr.GetEnd(); rLst.push_back(aEEAttr); } } @@ -840,12 +829,12 @@ const SvxFieldItem* BinTextObject::GetField() const const ContentInfo& rC = aContents[0]; if (rC.GetText().Len() == 1) { - sal_uInt16 nAttribs = rC.GetAttribs().Count(); - for ( sal_uInt16 nAttr = nAttribs; nAttr; ) + size_t nAttribs = rC.aAttribs.size(); + for (size_t nAttr = nAttribs; nAttr; ) { - XEditAttribute* pX = rC.GetAttribs().GetObject( --nAttr ); - if ( pX->GetItem()->Which() == EE_FEATURE_FIELD ) - return (const SvxFieldItem*)pX->GetItem(); + const XEditAttribute& rX = rC.aAttribs[--nAttr]; + if (rX.GetItem()->Which() == EE_FEATURE_FIELD) + return static_cast<const SvxFieldItem*>(rX.GetItem()); } } } @@ -858,16 +847,16 @@ sal_Bool BinTextObject::HasField( TypeId aType ) const for (size_t nPara = 0; nPara < nParagraphs; ++nPara) { const ContentInfo& rC = aContents[nPara]; - sal_uInt16 nAttrs = rC.GetAttribs().Count(); - for ( sal_uInt16 nAttr = 0; nAttr < nAttrs; nAttr++ ) + size_t nAttrs = rC.aAttribs.size(); + for (size_t nAttr = 0; nAttr < nAttrs; ++nAttr) { - XEditAttribute* pAttr = rC.GetAttribs()[nAttr]; - if ( pAttr->GetItem()->Which() == EE_FEATURE_FIELD ) + const XEditAttribute& rAttr = rC.aAttribs[nAttr]; + if (rAttr.GetItem()->Which() == EE_FEATURE_FIELD) { if ( !aType ) return true; - const SvxFieldData* pFldData = ((const SvxFieldItem*)pAttr->GetItem())->GetField(); + const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField(); if ( pFldData && pFldData->IsA( aType ) ) return true; } @@ -897,13 +886,13 @@ sal_Bool BinTextObject::RemoveCharAttribs( sal_uInt16 _nWhich ) { ContentInfo& rC = aContents[--nPara]; - for ( sal_uInt16 nAttr = rC.GetAttribs().Count(); nAttr; ) + for (size_t nAttr = rC.aAttribs.size(); nAttr; ) { - XEditAttribute* pAttr = rC.GetAttribs().GetObject( --nAttr ); - if ( !_nWhich || ( pAttr->GetItem()->Which() == _nWhich ) ) + XEditAttribute& rAttr = rC.aAttribs[--nAttr]; + if ( !_nWhich || (rAttr.GetItem()->Which() == _nWhich) ) { - rC.GetAttribs().Remove( nAttr ); - DestroyAttrib( pAttr ); + pPool->Remove(*rAttr.GetItem()); + rC.aAttribs.erase(rC.aAttribs.begin()+nAttr); bChanged = true; } } @@ -1017,6 +1006,22 @@ void BinTextObject::ChangeStyleSheetName( SfxStyleFamily eFamily, ImpChangeStyleSheets( rOldName, eFamily, rNewName, eFamily ); } +namespace { + +class FindAttribByChar : public std::unary_function<XEditAttribute, bool> +{ + sal_uInt16 mnWhich; + sal_uInt16 mnChar; +public: + FindAttribByChar(sal_uInt16 nWhich, sal_uInt16 nChar) : mnWhich(nWhich), mnChar(nChar) {} + bool operator() (const XEditAttribute& rAttr) const + { + return (rAttr.GetItem()->Which() == mnWhich) && (rAttr.GetStart() <= mnChar) && (rAttr.GetEnd() > mnChar); + } +}; + +} + void BinTextObject::StoreData( SvStream& rOStream ) const { sal_uInt16 nVer = 602; @@ -1061,21 +1066,21 @@ void BinTextObject::StoreData( SvStream& rOStream ) const bSymbolPara = true; } } - for ( sal_uInt16 nA = 0; nA < rC.GetAttribs().Count(); nA++ ) + for (size_t nA = 0; nA < rC.aAttribs.size(); ++nA) { - XEditAttribute* pAttr = rC.GetAttribs().GetObject( nA ); + const XEditAttribute& rAttr = rC.aAttribs[nA]; - if ( pAttr->GetItem()->Which() == EE_CHAR_FONTINFO ) + if (rAttr.GetItem()->Which() == EE_CHAR_FONTINFO) { - const SvxFontItem& rFontItem = (const SvxFontItem&)*pAttr->GetItem(); + const SvxFontItem& rFontItem = (const SvxFontItem&)*rAttr.GetItem(); if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) ) || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) { // Not correctly converted - String aPart( rC.GetText(), pAttr->GetStart(), pAttr->GetEnd() - pAttr->GetStart() ); + String aPart( rC.GetText(), rAttr.GetStart(), rAttr.GetEnd() - rAttr.GetStart() ); rtl::OString aNew(rtl::OUStringToOString(aPart, rFontItem.GetCharSet())); - aBuffer.remove(pAttr->GetStart(), pAttr->GetEnd() - pAttr->GetStart()); - aBuffer.insert(pAttr->GetStart(), aNew); + aBuffer.remove(rAttr.GetStart(), rAttr.GetEnd() - rAttr.GetStart()); + aBuffer.insert(rAttr.GetStart(), aNew); } // Convert StarSymbol back to StarBats @@ -1084,7 +1089,7 @@ void BinTextObject::StoreData( SvStream& rOStream ) const { // Don't create a new Attrib with StarBats font, MBR changed the // SvxFontItem::Store() to store StarBats instead of StarSymbol! - for ( sal_uInt16 nChar = pAttr->GetStart(); nChar < pAttr->GetEnd(); nChar++ ) + for (sal_uInt16 nChar = rAttr.GetStart(); nChar < rAttr.GetEnd(); ++nChar) { sal_Unicode cOld = rC.GetText().GetChar( nChar ); char cConv = rtl::OUStringToOString(rtl::OUString(ConvertFontToSubsFontChar(hConv, cOld)), RTL_TEXTENCODING_SYMBOL).toChar(); @@ -1109,7 +1114,12 @@ void BinTextObject::StoreData( SvStream& rOStream ) const { for ( sal_uInt16 nChar = 0; nChar < rC.GetText().Len(); nChar++ ) { - if ( !rC.GetAttribs().FindAttrib( EE_CHAR_FONTINFO, nChar ) ) + const ContentInfo::XEditAttributesType& rAttribs = rC.aAttribs; + ContentInfo::XEditAttributesType::const_iterator it = + std::find_if(rAttribs.begin(), rAttribs.end(), + FindAttribByChar(EE_CHAR_FONTINFO, nChar)); + + if (it == rAttribs.end()) { sal_Unicode cOld = rC.GetText().GetChar( nChar ); char cConv = rtl::OUStringToOString(rtl::OUString(ConvertFontToSubsFontChar(hConv, cOld)), RTL_TEXTENCODING_SYMBOL).toChar(); @@ -1135,20 +1145,20 @@ void BinTextObject::StoreData( SvStream& rOStream ) const rC.GetParaAttribs().Store( rOStream ); // The number of attributes ... - sal_uInt16 nAttribs = rC.GetAttribs().Count(); - rOStream << nAttribs; + size_t nAttribs = rC.aAttribs.size(); + rOStream << static_cast<sal_uInt16>(nAttribs); // And the individual attributes // Items as Surregate => always 8 bytes per Attribute // Which = 2; Surregat = 2; Start = 2; End = 2; - for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ ) + for (size_t nAttr = 0; nAttr < nAttribs; ++nAttr) { - XEditAttribute* pX = rC.GetAttribs().GetObject( nAttr ); + const XEditAttribute& rX = rC.aAttribs[nAttr]; - rOStream << pX->GetItem()->Which(); - GetPool()->StoreSurrogate( rOStream, pX->GetItem() ); - rOStream << pX->GetStart(); - rOStream << pX->GetEnd(); + rOStream << rX.GetItem()->Which(); + GetPool()->StoreSurrogate(rOStream, rX.GetItem()); + rOStream << rX.GetStart(); + rOStream << rX.GetEnd(); } } @@ -1235,14 +1245,15 @@ void BinTextObject::CreateData( SvStream& rIStream ) pC->GetParaAttribs().Load( rIStream ); // The number of attributes ... - sal_uInt16 nAttribs; - rIStream >> nAttribs; + sal_uInt16 nTmp16; + rIStream >> nTmp16; + size_t nAttribs = nTmp16; // And the individual attributes // Items as Surregate => always 8 bytes per Attributes // Which = 2; Surregat = 2; Start = 2; End = 2; - sal_uInt16 nAttr; - for ( nAttr = 0; nAttr < nAttribs; nAttr++ ) + size_t nAttr; + for (nAttr = 0; nAttr < nAttribs; ++nAttr) { sal_uInt16 _nWhich, nStart, nEnd; const SfxPoolItem* pItem; @@ -1264,7 +1275,7 @@ void BinTextObject::CreateData( SvStream& rIStream ) else { XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd ); - pC->GetAttribs().Insert( pAttr, pC->GetAttribs().Count() ); + pC->aAttribs.push_back(pAttr); if ( ( _nWhich >= EE_FEATURE_START ) && ( _nWhich <= EE_FEATURE_END ) ) { @@ -1291,20 +1302,20 @@ void BinTextObject::CreateData( SvStream& rIStream ) } } - for ( nAttr = pC->GetAttribs().Count(); nAttr; ) + for (nAttr = pC->aAttribs.size(); nAttr; ) { - XEditAttribute* pAttr = pC->GetAttribs().GetObject( --nAttr ); - if ( pAttr->GetItem()->Which() == EE_CHAR_FONTINFO ) + const XEditAttribute& rAttr = pC->aAttribs[--nAttr]; + if ( rAttr.GetItem()->Which() == EE_CHAR_FONTINFO ) { - const SvxFontItem& rFontItem = (const SvxFontItem&)*pAttr->GetItem(); + const SvxFontItem& rFontItem = (const SvxFontItem&)*rAttr.GetItem(); if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) ) || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) { // Not correctly converted - rtl::OString aPart(aByteString.copy(pAttr->GetStart(), pAttr->GetEnd()-pAttr->GetStart())); + rtl::OString aPart(aByteString.copy(rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart())); rtl::OUString aNew(rtl::OStringToOUString(aPart, rFontItem.GetCharSet())); - pC->GetText().Erase( pAttr->GetStart(), pAttr->GetEnd()-pAttr->GetStart() ); - pC->GetText().Insert( aNew, pAttr->GetStart() ); + pC->GetText().Erase( rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart() ); + pC->GetText().Insert( aNew, rAttr.GetStart() ); } // Convert StarMath and StarBats to StarSymbol @@ -1314,10 +1325,12 @@ void BinTextObject::CreateData( SvStream& rIStream ) SvxFontItem aNewFontItem( rFontItem ); aNewFontItem.SetFamilyName( GetFontToSubsFontName( hConv ) ); - pC->GetAttribs().Remove( nAttr ); - XEditAttribute* pNewAttr = CreateAttrib( aNewFontItem, pAttr->GetStart(), pAttr->GetEnd() ); - pC->GetAttribs().Insert( pNewAttr, nAttr ); - DestroyAttrib( pAttr ); + // Replace the existing attribute with a new one. + XEditAttribute* pNewAttr = CreateAttrib(aNewFontItem, rAttr.GetStart(), rAttr.GetEnd()); + + pPool->Remove(*rAttr.GetItem()); + pC->aAttribs.erase(pC->aAttribs.begin()+nAttr); + pC->aAttribs.insert(pC->aAttribs.begin()+nAttr, pNewAttr); for ( sal_uInt16 nChar = pNewAttr->GetStart(); nChar < pNewAttr->GetEnd(); nChar++ ) { @@ -1348,7 +1361,12 @@ void BinTextObject::CreateData( SvStream& rIStream ) for ( sal_uInt16 nChar = 0; nChar < pC->GetText().Len(); nChar++ ) { - if ( !pC->GetAttribs().FindAttrib( EE_CHAR_FONTINFO, nChar ) ) + const ContentInfo::XEditAttributesType& rAttribs = pC->aAttribs; + ContentInfo::XEditAttributesType::const_iterator it = + std::find_if(rAttribs.begin(), rAttribs.end(), + FindAttribByChar(EE_CHAR_FONTINFO, nChar)); + + if (it == rAttribs.end()) { sal_Unicode cOld = pC->GetText().GetChar( nChar ); DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" ); @@ -1550,7 +1568,7 @@ void BinTextObject::CreateData300( SvStream& rIStream ) if ( pItem ) { XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd ); - pC->GetAttribs().Insert( pAttr, pC->GetAttribs().Count() ); + pC->aAttribs.push_back(pAttr); } } } diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx index ea633faac59c..ad611e6ecdd5 100644 --- a/editeng/source/editeng/editobj2.hxx +++ b/editeng/source/editeng/editobj2.hxx @@ -34,14 +34,12 @@ #include <unotools/fontcvt.hxx> +#include <boost/ptr_container/ptr_vector.hpp> class SfxStyleSheetPool; class XEditAttribute { - friend class ContentInfo; // for destructor - friend class BinTextObject; // for destructor - private: const SfxPoolItem* pItem; sal_uInt16 nStart; @@ -50,10 +48,9 @@ private: XEditAttribute(); XEditAttribute( const XEditAttribute& rCopyFrom ); - ~XEditAttribute(); - public: - XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd ); + XEditAttribute( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd ); + ~XEditAttribute(); const SfxPoolItem* GetItem() const { return pItem; } @@ -65,16 +62,17 @@ public: sal_uInt16 GetLen() const { return nEnd-nStart; } - bool IsFeature() + bool IsFeature() const; + + inline bool operator==( const XEditAttribute& rCompare ) const; + + bool operator!= (const XEditAttribute& r) const { - sal_uInt16 nWhich = pItem->Which(); - return ((nWhich >= EE_FEATURE_START) && (nWhich <= EE_FEATURE_END)); + return !operator==(r); } - - inline bool operator==( const XEditAttribute& rCompare ); }; -inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) +inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) const { return (nStart == rCompare.nStart) && (nEnd == rCompare.nEnd) && @@ -83,15 +81,6 @@ inline bool XEditAttribute::operator==( const XEditAttribute& rCompare ) (*pItem == *rCompare.pItem)); } -typedef XEditAttribute* XEditAttributePtr; -SV_DECL_PTRARR( XEditAttributeListImpl, XEditAttributePtr, 0 ) - -class XEditAttributeList : public XEditAttributeListImpl -{ -public: - XEditAttribute* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nChar ) const; -}; - struct XParaPortion { long nHeight; @@ -135,11 +124,14 @@ public: class ContentInfo { friend class BinTextObject; +public: + typedef boost::ptr_vector<XEditAttribute> XEditAttributesType; private: String aText; String aStyle; - XEditAttributeList aAttribs; + + XEditAttributesType aAttribs; SfxStyleFamily eFamily; SfxItemSet aParaAttribs; WrongList* pWrongs; @@ -150,15 +142,16 @@ private: public: ~ContentInfo(); + const XEditAttributesType& GetAttribs() const { return aAttribs; } + XEditAttributesType& GetAttribs() { return aAttribs; } + const String& GetText() const { return aText; } const String& GetStyle() const { return aStyle; } - const XEditAttributeList& GetAttribs() const { return aAttribs; } const SfxItemSet& GetParaAttribs() const { return aParaAttribs; } SfxStyleFamily GetFamily() const { return eFamily; } String& GetText() { return aText; } String& GetStyle() { return aStyle; } - XEditAttributeList& GetAttribs() { return aAttribs; } SfxItemSet& GetParaAttribs() { return aParaAttribs; } SfxStyleFamily& GetFamily() { return eFamily; } diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index f2373fa9828e..d20958f6f12a 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1118,7 +1118,7 @@ EditTextObject* ImpEditEngine::CreateBinTextObject( EditSelection aSel, SfxItemP if ( !pX->GetLen() && !bEmptyPara ) pTxtObj->DestroyAttrib( pX ); else - pC->GetAttribs().Insert( pX, pC->GetAttribs().Count() ); + pC->GetAttribs().push_back(pX); } nAttr++; pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); @@ -1256,31 +1256,31 @@ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, Ed // Character attributes ... sal_Bool bAllreadyHasAttribs = aPaM.GetNode()->GetCharAttribs().Count() ? sal_True : sal_False; - sal_uInt16 nNewAttribs = pC->GetAttribs().Count(); + size_t nNewAttribs = pC->GetAttribs().size(); if ( nNewAttribs ) { sal_Bool bUpdateFields = sal_False; - for ( sal_uInt16 nAttr = 0; nAttr < nNewAttribs; nAttr++ ) + for (size_t nAttr = 0; nAttr < nNewAttribs; ++nAttr) { - XEditAttribute* pX = pC->GetAttribs().GetObject( nAttr ); + const XEditAttribute& rX = pC->GetAttribs()[nAttr]; // Can happen when paragraphs > 16K, it is simply wrapped. - if ( pX->GetEnd() <= aPaM.GetNode()->Len() ) + if ( rX.GetEnd() <= aPaM.GetNode()->Len() ) { - if ( !bAllreadyHasAttribs || pX->IsFeature() ) + if ( !bAllreadyHasAttribs || rX.IsFeature() ) { // Normal attributes then go faster ... // Features shall not be inserted through // EditDoc:: InsertAttrib, using FastInsertText they are // already in the flow - DBG_ASSERT( pX->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute too large!" ); + DBG_ASSERT( rX.GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute too large!" ); EditCharAttrib* pAttr; if ( !bConvertItems ) - pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(pX->GetItem()), pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos ); + pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(rX.GetItem()), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); else { - SfxPoolItem* pNew = pX->GetItem()->Clone(); + SfxPoolItem* pNew = rX.GetItem()->Clone(); ConvertItem( *pNew, eSourceUnit, eDestUnit ); - pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos ); + pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); delete pNew; } DBG_ASSERT( pAttr->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (1)" ); @@ -1290,9 +1290,9 @@ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, Ed } else { - DBG_ASSERT( pX->GetEnd()+nStartPos <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (2)" ); + DBG_ASSERT( rX.GetEnd()+nStartPos <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (2)" ); // Tabs and other Features can not be inserted through InsertAttrib: - aEditDoc.InsertAttrib( aPaM.GetNode(), pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos, *pX->GetItem() ); + aEditDoc.InsertAttrib( aPaM.GetNode(), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos, *rX.GetItem() ); } } } |