[Libreoffice-commits] .: 2 commits - editeng/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Mar 28 10:35:26 PDT 2012
editeng/source/editeng/editdbg.cxx | 12 ++++++------
editeng/source/editeng/editdoc.hxx | 14 +++++++-------
editeng/source/editeng/editdoc2.cxx | 11 +++++++++++
editeng/source/editeng/editundo.cxx | 21 +++++++--------------
editeng/source/editeng/impedit5.cxx | 2 +-
5 files changed, 32 insertions(+), 28 deletions(-)
New commits:
commit d192756c71519b1f013bbaa1a0594d46606a6336
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Mar 28 13:35:19 2012 -0400
No more CharAttribArray.
diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx
index fc9c562..a1b4575 100644
--- a/editeng/source/editeng/editdbg.cxx
+++ b/editeng/source/editeng/editdbg.cxx
@@ -496,19 +496,19 @@ sal_Bool ParaPortion::DbgCheckTextPortions()
}
#endif
-sal_Bool CheckOrderedList( CharAttribArray& rAttribs, sal_Bool bStart )
+bool CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart)
{
sal_uInt16 nPrev = 0;
- for ( sal_uInt16 nAttr = 0; nAttr < rAttribs.Count(); nAttr++ )
+ for (size_t nAttr = 0; nAttr < rAttribs.size(); ++nAttr)
{
- EditCharAttrib* pAttr = rAttribs[nAttr];
- sal_uInt16 nCur = bStart ? pAttr->GetStart() : pAttr->GetEnd();
+ const EditCharAttrib& rAttr = rAttribs[nAttr];
+ sal_uInt16 nCur = bStart ? rAttr.GetStart() : rAttr.GetEnd();
if ( nCur < nPrev )
- return sal_False;
+ return false;
nPrev = nCur;
}
- return sal_True;
+ return true;
}
#endif
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 2bd5151..1114990 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -117,9 +117,6 @@ struct WritingDirectionInfo
typedef std::deque< WritingDirectionInfo > WritingDirectionInfos;
-typedef EditCharAttrib* EditCharAttribPtr;
-SV_DECL_PTRARR( CharAttribArray, EditCharAttribPtr, 0 )
-
class ContentAttribsInfo
{
private:
@@ -804,7 +801,7 @@ inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, size_t n
return (nAttr < rAttribs.size()) ? &rAttribs[nAttr] : NULL;
}
-sal_Bool CheckOrderedList( CharAttribArray& rAttribs, sal_Bool bStart );
+bool CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart);
// -------------------------------------------------------------------------
// class EditEngineItemPool
commit 38e07aab9eb8c3c1d18038857b5dda28aace5bff
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Mar 28 13:31:27 2012 -0400
One less use of CharAttribArray.
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 7ddaa39..2bd5151 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 67c0d38..c13b656 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 1b96e14..e29043b 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 02b39a6..7dd4ab4 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);
}
}
}
More information about the Libreoffice-commits
mailing list