summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 14:54:42 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-03-28 14:54:42 -0400
commit17cc39f2b0ef13efdfb052fe6b815508879fb755 (patch)
tree3b50cfa4aaa019312bda8ac4054bcfb36026d59d /editeng
parent484b44b39bc2788160f475c3b40ce6b569fdc6cb (diff)
ContentInfoArray is gone.
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdoc.hxx3
-rw-r--r--editeng/source/editeng/editundo.cxx40
-rw-r--r--editeng/source/editeng/editundo.hxx7
-rw-r--r--editeng/source/editeng/impedit5.cxx2
4 files changed, 32 insertions, 20 deletions
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 11149907a6c7..7551eca0c523 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 e29043bec4f8..b59b71a060f4 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 0479d1fe74b8..bfb141ce55b0 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 7dd4ab463ed8..b59ad86a7e93 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++ )
{