summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 13:31:27 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 13:35:47 -0400
commit38e07aab9eb8c3c1d18038857b5dda28aace5bff (patch)
tree99d4566e992776a95a9a658b815ddde081e0a585 /editeng
parent6b170f3d0aa519c6fd4e3ee92421f5a87ab511e3 (diff)
One less use of CharAttribArray.
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdoc.hxx9
-rw-r--r--editeng/source/editeng/editdoc2.cxx11
-rw-r--r--editeng/source/editeng/editundo.cxx21
-rw-r--r--editeng/source/editeng/impedit5.cxx2
4 files changed, 25 insertions, 18 deletions
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 7ddaa392c2f8..2bd515110d64 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -123,16 +123,19 @@ SV_DECL_PTRARR( CharAttribArray, EditCharAttribPtr, 0 )
class ContentAttribsInfo
{
private:
+ typedef boost::ptr_vector<EditCharAttrib> CharAttribsType;
+
SfxItemSet aPrevParaAttribs;
- CharAttribArray aPrevCharAttribs;
+ CharAttribsType aPrevCharAttribs;
public:
ContentAttribsInfo( const SfxItemSet& rParaAttribs );
const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; }
- const CharAttribArray& GetPrevCharAttribs() const { return aPrevCharAttribs; }
+ const CharAttribsType& GetPrevCharAttribs() const { return aPrevCharAttribs; }
- CharAttribArray& GetPrevCharAttribs() { return aPrevCharAttribs; }
+ void RemoveAllCharAttribsFromPool(SfxItemPool& rPool) const;
+ void AppendCharAttrib(EditCharAttrib* pNew);
};
typedef ContentAttribsInfo* ContentAttribsInfoPtr;
diff --git a/editeng/source/editeng/editdoc2.cxx b/editeng/source/editeng/editdoc2.cxx
index 67c0d38fec8c..c13b6565417c 100644
--- a/editeng/source/editeng/editdoc2.cxx
+++ b/editeng/source/editeng/editdoc2.cxx
@@ -395,6 +395,17 @@ ContentAttribsInfo::ContentAttribsInfo( const SfxItemSet& rParaAttribs ) :
{
}
+void ContentAttribsInfo::RemoveAllCharAttribsFromPool(SfxItemPool& rPool) const
+{
+ CharAttribsType::const_iterator it = aPrevCharAttribs.begin(), itEnd = aPrevCharAttribs.end();
+ for (; it != itEnd; ++it)
+ rPool.Remove(*it->GetItem());
+}
+
+void ContentAttribsInfo::AppendCharAttrib(EditCharAttrib* pNew)
+{
+ aPrevCharAttribs.push_back(pNew);
+}
void ConvertItem( SfxPoolItem& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit )
{
diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx
index 1b96e1489e58..e29043bec4f8 100644
--- a/editeng/source/editeng/editundo.cxx
+++ b/editeng/source/editeng/editundo.cxx
@@ -549,13 +549,7 @@ EditUndoSetAttribs::~EditUndoSetAttribs()
{
ContentAttribsInfo* pInf = aPrevAttribs[n];
DBG_ASSERT( pInf, "Undo_DTOR (SetAttribs): pInf = NULL!" );
- for ( sal_uInt16 nAttr = 0; nAttr < pInf->GetPrevCharAttribs().Count(); nAttr++ )
- {
- EditCharAttrib* pX = pInf->GetPrevCharAttribs()[nAttr];
- DBG_ASSERT( pX, "Undo_DTOR (SetAttribs): pX = NULL!" );
- pPool->Remove( *pX->GetItem() );
- delete pX;
- }
+ pInf->RemoveAllCharAttribsFromPool(*pPool);
delete pInf;
}
}
@@ -564,7 +558,7 @@ void EditUndoSetAttribs::Undo()
{
DBG_ASSERT( GetImpEditEngine()->GetActiveView(), "Undo/Redo: No Active View!" );
ImpEditEngine* _pImpEE = GetImpEditEngine();
- sal_Bool bFields = sal_False;
+ bool bFields = false;
for ( sal_uInt16 nPara = aESel.nStartPara; nPara <= aESel.nEndPara; nPara++ )
{
ContentAttribsInfo* pInf = aPrevAttribs[ (sal_uInt16)(nPara-aESel.nStartPara) ];
@@ -578,14 +572,13 @@ void EditUndoSetAttribs::Undo()
_pImpEE->RemoveCharAttribs( nPara, 0, sal_True );
DBG_ASSERT( _pImpEE->GetEditDoc().SaveGetObject( nPara ), "Undo (SetAttribs): pNode = NULL!" );
ContentNode* pNode = _pImpEE->GetEditDoc().GetObject( nPara );
- for ( sal_uInt16 nAttr = 0; nAttr < pInf->GetPrevCharAttribs().Count(); nAttr++ )
+ for (size_t nAttr = 0; nAttr < pInf->GetPrevCharAttribs().size(); ++nAttr)
{
- EditCharAttrib* pX = pInf->GetPrevCharAttribs()[nAttr];
- DBG_ASSERT( pX, "Redo (SetAttribs): pX = NULL!" );
+ const EditCharAttrib& rX = pInf->GetPrevCharAttribs()[nAttr];
// is automatically "poolsized"
- _pImpEE->GetEditDoc().InsertAttrib( pNode, pX->GetStart(), pX->GetEnd(), *pX->GetItem() );
- if ( pX->Which() == EE_FEATURE_FIELD )
- bFields = sal_True;
+ _pImpEE->GetEditDoc().InsertAttrib(pNode, rX.GetStart(), rX.GetEnd(), *rX.GetItem());
+ if (rX.Which() == EE_FEATURE_FIELD)
+ bFields = true;
}
}
if ( bFields )
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 02b39a6d104a..7dd4ab463ed8 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -221,7 +221,7 @@ EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const S
if (rAttr.GetLen())
{
EditCharAttrib* pNew = MakeCharAttrib(*pPool, *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd());
- pInf->GetPrevCharAttribs().Insert( pNew, pInf->GetPrevCharAttribs().Count() );
+ pInf->AppendCharAttrib(pNew);
}
}
}