diff options
-rw-r--r-- | sw/inc/txatbase.hxx | 8 | ||||
-rw-r--r-- | sw/inc/txtatr.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/text/atrstck.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 80 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtatr2.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unoportenum.cxx | 1 |
7 files changed, 43 insertions, 94 deletions
diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx index 2a49460a05ca..32fedb3753a0 100644 --- a/sw/inc/txatbase.hxx +++ b/sw/inc/txatbase.hxx @@ -121,7 +121,6 @@ public: inline const SwTOXMark &GetTOXMark() const; inline const SwFmtRefMark &GetRefMark() const; inline const SwFmtINetFmt &GetINetFmt() const; - inline const SvXMLAttrContainerItem &GetXMLAttrContainer() const; inline const SwFmtRuby &GetRuby() const; inline const SwFmtMeta &GetMeta() const; @@ -230,13 +229,6 @@ inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const return (const SwFmtINetFmt&)(*m_pAttr); } -inline const SvXMLAttrContainerItem& SwTxtAttr::GetXMLAttrContainer() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_UNKNOWNATR_CONTAINER, - "Wrong attribute" ); - return (const SvXMLAttrContainerItem&)(*m_pAttr); -} - inline const SwFmtRuby& SwTxtAttr::GetRuby() const { ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY, diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index 92b51fede495..d9e9463a30a7 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -60,15 +60,6 @@ public: }; -// ATT_XMLCONTAINERITEM ****************************** - -class SwTxtXMLAttrContainer : public SwTxtAttrEnd -{ -public: - SwTxtXMLAttrContainer( SvXMLAttrContainerItem& rAttr, - xub_StrLen nStart, xub_StrLen nEnd ); -}; - // ****************************** class SwTxtAttrNesting : public SwTxtAttrEnd diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index a6ed9f42255b..7db8ec2e2506 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -523,13 +523,11 @@ void SwAttrHandler::PushAndChg( const SwTxtAttr& rAttr, SwFont& rFnt ) sal_Bool SwAttrHandler::Push( const SwTxtAttr& rAttr, const SfxPoolItem& rItem ) { - ASSERT( rItem.Which() < RES_TXTATR_WITHEND_END || - RES_UNKNOWNATR_CONTAINER == rItem.Which() , + ASSERT( rItem.Which() < RES_TXTATR_WITHEND_END, "I do not want this attribute, nWhich >= RES_TXTATR_WITHEND_END" ); // robust - if ( RES_TXTATR_WITHEND_END <= rItem.Which() || - RES_UNKNOWNATR_CONTAINER == rItem.Which() ) + if ( RES_TXTATR_WITHEND_END <= rItem.Which() ) return sal_False; USHORT nStack = StackPos[ rItem.Which() ]; @@ -557,6 +555,9 @@ sal_Bool SwAttrHandler::Push( const SwTxtAttr& rAttr, const SfxPoolItem& rItem ) void SwAttrHandler::PopAndChg( const SwTxtAttr& rAttr, SwFont& rFnt ) { + if ( RES_TXTATR_WITHEND_END <= rAttr.Which() ) + return; // robust + // these special attributes in fact represent a collection of attributes // they have to be removed from each stack they belong to if ( RES_TXTATR_INETFMT == rAttr.Which() || @@ -583,7 +584,7 @@ void SwAttrHandler::PopAndChg( const SwTxtAttr& rAttr, SwFont& rFnt ) } // this is the usual case, we have a basic attribute, remove it from the // stack and reset the font - else if ( RES_UNKNOWNATR_CONTAINER != rAttr.Which() ) + else { aAttrStack[ StackPos[ rAttr.Which() ] ].Remove( rAttr ); // reset font according to attribute on top of stack @@ -600,13 +601,13 @@ void SwAttrHandler::PopAndChg( const SwTxtAttr& rAttr, SwFont& rFnt ) void SwAttrHandler::Pop( const SwTxtAttr& rAttr ) { - ASSERT( rAttr.Which() < RES_TXTATR_WITHEND_END || - RES_UNKNOWNATR_CONTAINER == rAttr.Which() , + ASSERT( rAttr.Which() < RES_TXTATR_WITHEND_END, "I do not have this attribute, nWhich >= RES_TXTATR_WITHEND_END" ); - if ( RES_UNKNOWNATR_CONTAINER != rAttr.Which() && - rAttr.Which() < RES_TXTATR_WITHEND_END ) + if ( rAttr.Which() < RES_TXTATR_WITHEND_END ) + { aAttrStack[ StackPos[ rAttr.Which() ] ].Remove( rAttr ); + } } /************************************************************************* diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index f5ebacaac8cd..55de390d6c74 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -943,9 +943,7 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, bool bNoExp = false; bool bResort = false; const USHORT coArrSz = static_cast<USHORT>(RES_TXTATR_WITHEND_END) - - static_cast<USHORT>(RES_CHRATR_BEGIN) + - static_cast<USHORT>(RES_UNKNOWNATR_END) - - static_cast<USHORT>(RES_UNKNOWNATR_BEGIN); + static_cast<USHORT>(RES_CHRATR_BEGIN); BOOL aDontExp[ coArrSz ]; memset( &aDontExp, 0, coArrSz * sizeof(BOOL) ); @@ -980,14 +978,6 @@ void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, nWhPos = static_cast<USHORT>(nWhich - RES_CHRATR_BEGIN); } - else if (isUNKNOWNATR(nWhich)) - { - nWhPos = static_cast<USHORT>( - nWhich - - static_cast<USHORT>(RES_UNKNOWNATR_BEGIN) + - static_cast<USHORT>(RES_TXTATR_WITHEND_END) - - static_cast<USHORT>(RES_CHRATR_BEGIN) ); - } else continue; diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 12f8e210e7c5..81bdb95f0699 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1065,11 +1065,6 @@ SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, case RES_TXTATR_TOXMARK: pNew = new SwTxtTOXMark( (SwTOXMark&)rNew, nStt, &nEnd ); break; - case RES_UNKNOWNATR_CONTAINER: - case RES_TXTATR_UNKNOWN_CONTAINER: - pNew = new SwTxtXMLAttrContainer( (SvXMLAttrContainerItem&)rNew, - nStt, nEnd ); - break; case RES_TXTATR_CJK_RUBY: pNew = new SwTxtRuby( (SwFmtRuby&)rNew, nStt, nEnd ); break; @@ -1669,8 +1664,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, SfxItemSet aCharSet( *rSet.GetPool(), aCharAutoFmtSetRange ); - USHORT nWhich, nCount = 0; - SwTxtAttr* pNew; + USHORT nCount = 0; SfxItemIter aIter( *pSet ); const SfxPoolItem* pItem = aIter.GetCurItem(); @@ -1678,8 +1672,10 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, { if ( pItem && (reinterpret_cast<SfxPoolItem*>(-1) != pItem)) { - nWhich = pItem->Which(); - if ( isCHRATR(nWhich) || isTXTATR(nWhich) || isUNKNOWNATR(nWhich) ) + const USHORT nWhich = pItem->Which(); + ASSERT( isCHRATR(nWhich) || isTXTATR(nWhich), + "SwTxtNode::SetAttr(): unknown attribute" ); + if ( isCHRATR(nWhich) || isTXTATR(nWhich) ) { if ((RES_TXTATR_CHARFMT == nWhich) && (GetDoc()->GetDfltCharFmt() == @@ -1698,7 +1694,8 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, } else { - pNew = MakeTxtAttr( *GetDoc(), + + SwTxtAttr *const pNew = MakeTxtAttr( *GetDoc(), const_cast<SfxPoolItem&>(*pItem), nStt, nEnd ); if ( pNew ) { @@ -1862,20 +1859,18 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, } const USHORT nSize = m_pSwpHints->Count(); - USHORT n; - xub_StrLen nAttrStart; - const xub_StrLen* pAttrEnd; if( nStt == nEnd ) // kein Bereich: { - for( n = 0; n < nSize; ++n ) // + for (USHORT n = 0; n < nSize; ++n) { const SwTxtAttr* pHt = (*m_pSwpHints)[n]; - nAttrStart = *pHt->GetStart(); + const xub_StrLen nAttrStart = *pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; - if( 0 == ( pAttrEnd = pHt->GetEnd() )) // nie Attribute ohne Ende + const xub_StrLen* pAttrEnd = pHt->GetEnd(); + if ( ! pAttrEnd ) // no attributes without end continue; if( ( nAttrStart < nStt && @@ -1889,22 +1884,21 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, else // es ist ein Bereich definiert { // --> FME 2007-03-13 #i75299# - std::vector< SwPoolItemEndPair >* pAttrArr = 0; + ::std::auto_ptr< std::vector< SwPoolItemEndPair > > pAttrArr; // <-- const USHORT coArrSz = static_cast<USHORT>(RES_TXTATR_WITHEND_END) - - static_cast<USHORT>(RES_CHRATR_BEGIN) + - static_cast<USHORT>(RES_UNKNOWNATR_END) - - static_cast<USHORT>(RES_UNKNOWNATR_BEGIN); + static_cast<USHORT>(RES_CHRATR_BEGIN); - for( n = 0; n < nSize; ++n ) + for (USHORT n = 0; n < nSize; ++n) { const SwTxtAttr* pHt = (*m_pSwpHints)[n]; - nAttrStart = *pHt->GetStart(); + const xub_StrLen nAttrStart = *pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; - if( 0 == ( pAttrEnd = pHt->GetEnd() )) // nie Attribute ohne Ende + const xub_StrLen* pAttrEnd = pHt->GetEnd(); + if ( ! pAttrEnd ) // no attributes without end continue; BOOL bChkInvalid = FALSE; @@ -1927,7 +1921,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, if( bChkInvalid ) { // uneindeutig ? - SfxItemIter* pItemIter = 0; + ::std::auto_ptr< SfxItemIter > pItemIter; const SfxPoolItem* pItem = 0; if ( RES_TXTATR_AUTOFMT == pHt->Which() ) @@ -1935,7 +1929,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, const SfxItemSet* pAutoSet = CharFmt::GetItemSet( pHt->GetAttr() ); if ( pAutoSet ) { - pItemIter = new SfxItemIter( *pAutoSet ); + pItemIter.reset( new SfxItemIter( *pAutoSet ) ); pItem = pItemIter->GetCurItem(); } } @@ -1947,9 +1941,14 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, while ( pItem ) { const USHORT nHintWhich = pItem->Which(); + ASSERT(!isUNKNOWNATR(nHintWhich), + "SwTxtNode::GetAttr(): unkonwn attribute?"); - if( !pAttrArr ) - pAttrArr = new std::vector< SwPoolItemEndPair >( coArrSz ); + if ( !pAttrArr.get() ) + { + pAttrArr.reset( + new std::vector< SwPoolItemEndPair >(coArrSz)); + } std::vector< SwPoolItemEndPair >::iterator pPrev = pAttrArr->begin(); if (isCHRATR(nHintWhich) || @@ -1957,12 +1956,6 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, { pPrev += nHintWhich - RES_CHRATR_BEGIN; } - else if (isUNKNOWNATR(nHintWhich)) - { - pPrev += nHintWhich - RES_UNKNOWNATR_BEGIN + ( - static_cast< USHORT >(RES_TXTATR_WITHEND_END) - - static_cast< USHORT >(RES_CHRATR_BEGIN) ); - } else { pPrev = pAttrArr->end(); @@ -2006,28 +1999,21 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, } } - pItem = ( pItemIter && !pItemIter->IsAtEnd() ) ? pItemIter->NextItem() : 0; + pItem = ( pItemIter.get() && !pItemIter->IsAtEnd() ) + ? pItemIter->NextItem() : 0; } // end while - - delete pItemIter; } } - if( pAttrArr ) + if ( pAttrArr.get() ) { - for( n = 0; n < coArrSz; ++n ) + for (USHORT n = 0; n < coArrSz; ++n) { const SwPoolItemEndPair& rItemPair = (*pAttrArr)[ n ]; if( (0 != rItemPair.mpItem) && ((SfxPoolItem*)-1 != rItemPair.mpItem) ) { - USHORT nWh; - if( n < static_cast<USHORT>( static_cast<USHORT>(RES_TXTATR_WITHEND_END) - - static_cast<USHORT>(RES_CHRATR_BEGIN) ) ) - nWh = static_cast<USHORT>(n + RES_CHRATR_BEGIN); - else - nWh = n - static_cast<USHORT>( static_cast<USHORT>(RES_TXTATR_WITHEND_END) - - static_cast<USHORT>(RES_CHRATR_BEGIN) + - static_cast<USHORT>(RES_UNKNOWNATR_BEGIN) ); + const USHORT nWh = + static_cast<USHORT>(n + RES_CHRATR_BEGIN); if( nEnd <= rItemPair.mnEndPos ) // hinter oder genau Ende { @@ -2039,8 +2025,6 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, rSet.InvalidateItem( nWh ); } } - - delete pAttrArr; } } if( aFmtSet.Count() ) diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index 18db65d13dc8..afed4e1af732 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <hintids.hxx> #include <hints.hxx> #include <sfx2/objsh.hxx> @@ -52,13 +51,6 @@ TYPEINIT1(SwTxtINetFmt,SwClient); TYPEINIT1(SwTxtRuby,SwClient); -// ATT_XMLCONTAINERITEM ****************************** - -SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( - SvXMLAttrContainerItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) -{} /************************************************************************* * class SwTxtCharFmt diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index b49816d9c9e3..a8426cf8b438 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -831,7 +831,6 @@ lcl_ExportHints( case RES_TXTATR_AUTOFMT: case RES_TXTATR_INETFMT: case RES_TXTATR_CHARFMT: - case RES_TXTATR_UNKNOWN_CONTAINER: break; // these are handled as properties of a "Text" portion default: DBG_ERROR("unknown attribute"); |