editeng/source/editeng/editdoc.hxx | 10 +++------ editeng/source/editeng/editdoc2.cxx | 6 +++-- editeng/source/editeng/editeng.cxx | 2 - editeng/source/editeng/editundo.cxx | 40 +++++++++++++++++++++++------------- editeng/source/editeng/editundo.hxx | 7 ++++-- editeng/source/editeng/impedit5.cxx | 2 - 6 files changed, 41 insertions(+), 26 deletions(-)
New commits: commit 48cd6ac1ec7e92a9c9a21f5365db4f9ff5fde93c Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Mar 28 15:31:05 2012 -0400 Fix tinderbox error & some cleanup. diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 7551eca..7f760f3 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -298,10 +298,11 @@ SV_DECL_PTRARR( DummyContentList, ContentNodePtr, 0 ) class ContentList : public DummyContentList { - sal_uInt16 nLastCache; + sal_uInt16 nLastCache; + public: - ContentList() : DummyContentList( 0 ), nLastCache(0) {} - sal_uInt16 GetPos( const ContentNodePtr &rPtr ) const; + ContentList(); + sal_uInt16 GetPos(ContentNode* p) const; }; // ------------------------------------------------------------------------- diff --git a/editeng/source/editeng/editdoc2.cxx b/editeng/source/editeng/editdoc2.cxx index c13b656..68da6aa 100644 --- a/editeng/source/editeng/editdoc2.cxx +++ b/editeng/source/editeng/editdoc2.cxx @@ -337,10 +337,12 @@ sal_uInt16 ParaPortionList::GetPos( const ParaPortionPtr &rPtr ) const ((ParaPortionList *)this)->nLastCache ); } -sal_uInt16 ContentList::GetPos( const ContentNodePtr &rPtr ) const +ContentList::ContentList() : DummyContentList( 0 ), nLastCache(0) {} + +sal_uInt16 ContentList::GetPos(ContentNode* p) const { return FastGetPos( reinterpret_cast<const VoidPtr *>( GetData() ), - Count(), static_cast<VoidPtr>( rPtr ), + Count(), static_cast<VoidPtr>(p), ((ContentList *)this)->nLastCache ); } diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 0954d51..9fcd0a2 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -2113,7 +2113,7 @@ void EditEngine::RemoveFields( sal_Bool bKeepFieldText, TypeId aType ) const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField(); if ( pFldData && ( !aType || ( pFldData->IsA( aType ) ) ) ) { - DBG_ASSERT( rAttr->GetItem()->ISA( SvxFieldItem ), "no field item..." ); + DBG_ASSERT( dynamic_cast<const SvxFieldItem*>(rAttr.GetItem()), "no field item..." ); EditSelection aSel( EditPaM(pNode, rAttr.GetStart()), EditPaM(pNode, rAttr.GetEnd()) ); String aFieldText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue(); pImpEditEngine->ImpInsertText( aSel, aFieldText ); commit 17cc39f2b0ef13efdfb052fe6b815508879fb755 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Mar 28 14:54:42 2012 -0400 ContentInfoArray is gone. diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 1114990..7551eca 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -135,9 +135,6 @@ public: void AppendCharAttrib(EditCharAttrib* pNew); }; -typedef ContentAttribsInfo* ContentAttribsInfoPtr; -SV_DECL_PTRARR( ContentInfoArray, ContentAttribsInfoPtr, 1 ) - // ---------------------------------------------------------------------- // class SvxColorList // ---------------------------------------------------------------------- diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx index e29043b..b59b71a 100644 --- a/editeng/source/editeng/editundo.cxx +++ b/editeng/source/editeng/editundo.cxx @@ -540,18 +540,26 @@ EditUndoSetAttribs::EditUndoSetAttribs( ImpEditEngine* _pImpEE, const ESelection nSpecial = 0; } +namespace { + +struct RemoveAttribsFromPool : std::unary_function<ContentAttribsInfo, void> +{ + SfxItemPool& mrPool; +public: + RemoveAttribsFromPool(SfxItemPool& rPool) : mrPool(rPool) {} + void operator() (ContentAttribsInfo& rInfo) + { + rInfo.RemoveAllCharAttribsFromPool(mrPool); + } +}; + +} + EditUndoSetAttribs::~EditUndoSetAttribs() { // Get Items from Pool... SfxItemPool* pPool = aNewAttribs.GetPool(); - sal_uInt16 nContents = aPrevAttribs.Count(); - for ( sal_uInt16 n = 0; n < nContents; n++ ) - { - ContentAttribsInfo* pInf = aPrevAttribs[n]; - DBG_ASSERT( pInf, "Undo_DTOR (SetAttribs): pInf = NULL!" ); - pInf->RemoveAllCharAttribsFromPool(*pPool); - delete pInf; - } + std::for_each(aPrevAttribs.begin(), aPrevAttribs.end(), RemoveAttribsFromPool(*pPool)); } void EditUndoSetAttribs::Undo() @@ -561,20 +569,19 @@ void EditUndoSetAttribs::Undo() bool bFields = false; for ( sal_uInt16 nPara = aESel.nStartPara; nPara <= aESel.nEndPara; nPara++ ) { - ContentAttribsInfo* pInf = aPrevAttribs[ (sal_uInt16)(nPara-aESel.nStartPara) ]; - DBG_ASSERT( pInf, "Undo (SetAttribs): pInf = NULL!" ); + const ContentAttribsInfo& rInf = aPrevAttribs[nPara-aESel.nStartPara]; // first the paragraph attributes ... - _pImpEE->SetParaAttribs( nPara, pInf->GetPrevParaAttribs() ); + _pImpEE->SetParaAttribs(nPara, rInf.GetPrevParaAttribs()); // Then the character attributes ... // Remove all attributes including features, are later re-established. - _pImpEE->RemoveCharAttribs( nPara, 0, sal_True ); + _pImpEE->RemoveCharAttribs(nPara, 0, true); DBG_ASSERT( _pImpEE->GetEditDoc().SaveGetObject( nPara ), "Undo (SetAttribs): pNode = NULL!" ); ContentNode* pNode = _pImpEE->GetEditDoc().GetObject( nPara ); - for (size_t nAttr = 0; nAttr < pInf->GetPrevCharAttribs().size(); ++nAttr) + for (size_t nAttr = 0; nAttr < rInf.GetPrevCharAttribs().size(); ++nAttr) { - const EditCharAttrib& rX = pInf->GetPrevCharAttribs()[nAttr]; + const EditCharAttrib& rX = rInf.GetPrevCharAttribs()[nAttr]; // is automatically "poolsized" _pImpEE->GetEditDoc().InsertAttrib(pNode, rX.GetStart(), rX.GetEnd(), *rX.GetItem()); if (rX.Which() == EE_FEATURE_FIELD) @@ -600,6 +607,11 @@ void EditUndoSetAttribs::Redo() ImpSetSelection( GetImpEditEngine()->GetActiveView() ); } +void EditUndoSetAttribs::AppendContentInfo(ContentAttribsInfo* pNew) +{ + aPrevAttribs.push_back(pNew); +} + void EditUndoSetAttribs::ImpSetSelection( EditView* /*pView*/ ) { ImpEditEngine* _pImpEE = GetImpEditEngine(); diff --git a/editeng/source/editeng/editundo.hxx b/editeng/source/editeng/editundo.hxx index 0479d1f..bfb141c 100644 --- a/editeng/source/editeng/editundo.hxx +++ b/editeng/source/editeng/editundo.hxx @@ -240,9 +240,11 @@ public: class EditUndoSetAttribs: public EditUndo { private: + typedef boost::ptr_vector<ContentAttribsInfo> InfoArrayType; + ESelection aESel; SfxItemSet aNewAttribs; - ContentInfoArray aPrevAttribs; + InfoArrayType aPrevAttribs; sal_uInt8 nSpecial; sal_Bool bSetIsRemove; @@ -257,7 +259,6 @@ public: EditUndoSetAttribs( ImpEditEngine* pImpEE, const ESelection& rESel, const SfxItemSet& rNewItems ); ~EditUndoSetAttribs(); - ContentInfoArray& GetContentInfos() { return aPrevAttribs; } SfxItemSet& GetNewAttribs() { return aNewAttribs; } void SetSpecial( sal_uInt8 n ) { nSpecial = n; } @@ -267,6 +268,8 @@ public: virtual void Undo(); virtual void Redo(); + + void AppendContentInfo(ContentAttribsInfo* pNew); }; // ----------------------------------------------------------------------- diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index 7dd4ab4..b59ad86 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -213,7 +213,7 @@ EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const S ContentNode* pNode = aEditDoc.GetObject( nPara ); DBG_ASSERT( aEditDoc.SaveGetObject( nPara ), "Node not found: CreateAttribUndo" ); ContentAttribsInfo* pInf = new ContentAttribsInfo( pNode->GetContentAttribs().GetItems() ); - pUndo->GetContentInfos().Insert( pInf, pUndo->GetContentInfos().Count() ); + pUndo->AppendContentInfo(pInf); for ( sal_uInt16 nAttr = 0; nAttr < pNode->GetCharAttribs().Count(); nAttr++ ) { _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits