[Libreoffice-commits] .: 2 commits - svx/inc svx/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Aug 30 21:36:40 PDT 2012
svx/inc/svx/svdmodel.hxx | 8 ++------
svx/source/dialog/imapdlg.cxx | 4 ++--
svx/source/svdraw/svdfmtf.cxx | 22 +++++++++++-----------
svx/source/svdraw/svdfmtf.hxx | 32 ++------------------------------
svx/source/svdraw/svdmodel.cxx | 16 +++++++++++++---
5 files changed, 30 insertions(+), 52 deletions(-)
New commits:
commit 4deb9d4e0f29dd6947322aea665ee65ea8ef9ec4
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Thu Aug 30 23:21:49 2012 +0400
SdrModel: make sure undo/redo stacks are not empty
most probably Undo() does not get called if there is no undo actions,
just to be on the safe side.
Change-Id: I3597698dbe8208916be94ebddd7260fbd7eadc74
diff --git a/svx/inc/svx/svdmodel.hxx b/svx/inc/svx/svdmodel.hxx
index dd2919c..77a4e02 100644
--- a/svx/inc/svx/svdmodel.hxx
+++ b/svx/inc/svx/svdmodel.hxx
@@ -575,13 +575,9 @@ public:
void SetMaxUndoActionCount(sal_uIntPtr nAnz);
sal_uIntPtr GetMaxUndoActionCount() const { return nMaxUndoCount; }
void ClearUndoBuffer();
- // UndoAction(0) ist die aktuelle (also die zuletzt eingegangene)
- sal_uIntPtr GetUndoActionCount() const { return pUndoStack!=NULL ? pUndoStack->size() : 0; }
- const SfxUndoAction* GetUndoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pUndoStack!=NULL ? (*pUndoStack)[nNum] : NULL); }
- // RedoAction(0) ist die aktuelle (also die des letzten Undo)
- sal_uIntPtr GetRedoActionCount() const { return pRedoStack!=NULL ? pRedoStack->size() : 0; }
- const SfxUndoAction* GetRedoAction(sal_uIntPtr nNum) const { return (SfxUndoAction*)(pRedoStack!=NULL ? (*pRedoStack)[nNum] : NULL); }
+ bool HasUndoActions() const;
+ bool HasRedoActions() const;
bool Undo();
bool Redo();
bool Repeat(SfxRepeatTarget&);
diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx
index 3fa0cb5..b70dc32 100644
--- a/svx/source/dialog/imapdlg.cxx
+++ b/svx/source/dialog/imapdlg.cxx
@@ -791,8 +791,8 @@ IMPL_LINK( SvxIMapDlg, StateHdl, IMapWindow*, pWnd )
aTbxIMapDlg1.EnableItem( TBI_POLYDELETE, !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
// Undo/Redo
- aTbxIMapDlg1.EnableItem( TBI_UNDO, pModel->GetUndoActionCount() > 0 );
- aTbxIMapDlg1.EnableItem( TBI_REDO, pModel->GetRedoActionCount() > 0 );
+ aTbxIMapDlg1.EnableItem( TBI_UNDO, pModel->HasUndoActions() );
+ aTbxIMapDlg1.EnableItem( TBI_REDO, pModel->HasRedoActions() );
if ( bPolyEdit )
{
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 14d45d6..9938a1f 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -431,6 +431,16 @@ void SdrModel::ClearUndoBuffer()
}
}
+bool SdrModel::HasUndoActions() const
+{
+ return pUndoStack && !pUndoStack->empty();
+}
+
+bool SdrModel::HasRedoActions() const
+{
+ return pRedoStack && !pRedoStack->empty();
+}
+
bool SdrModel::Undo()
{
bool bRet = false;
@@ -440,7 +450,7 @@ bool SdrModel::Undo()
}
else
{
- SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
+ SfxUndoAction* pDo = HasUndoActions() ? pUndoStack->front() : NULL;
if(pDo!=NULL)
{
const bool bWasUndoEnabled = mbUndoEnabled;
@@ -466,7 +476,7 @@ bool SdrModel::Redo()
}
else
{
- SfxUndoAction* pDo=(SfxUndoAction*)GetRedoAction(0);
+ SfxUndoAction* pDo = HasRedoActions() ? pRedoStack->front() : NULL;
if(pDo!=NULL)
{
const bool bWasUndoEnabled = mbUndoEnabled;
@@ -492,7 +502,7 @@ bool SdrModel::Repeat(SfxRepeatTarget& rView)
}
else
{
- SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
+ SfxUndoAction* pDo = HasUndoActions() ? pUndoStack->front() : NULL;
if(pDo!=NULL)
{
if(pDo->CanRepeat(rView))
commit c050300a72f80ab838bd10f0cedd355048a2aaa5
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Thu Aug 30 23:19:17 2012 +0400
remove SdrObjRefList, use vector directly
also prevent using operator[] on empty vector
Change-Id: I0582ab1c7fd04a0bc6d717d8ca51670c3e5ef1c9
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 7287db0..b8c007e 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -219,7 +219,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
// MapMode scaling
MapScaling();
// scale objects to predetermined rectangle
- sal_uIntPtr nAnz=aTmpList.GetObjCount();
+ size_t nAnz=aTmpList.size();
// To calculate the progress meter, we use GetActionSize()*3.
// However, aTmpList has a lower entry count limit than GetActionSize(),
@@ -238,9 +238,9 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
// insert all objects cached in aTmpList now into rOL from nInsPos
if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount();
SdrInsertReason aReason(SDRREASON_VIEWCALL);
- for (sal_uIntPtr i=0; i<nAnz; i++)
+ for (size_t i=0; i<nAnz; i++)
{
- SdrObject* pObj=aTmpList.GetObj(i);
+ SdrObject* pObj=aTmpList[i];
rOL.NbcInsertObject(pObj,nInsPos,&aReason);
nInsPos++;
@@ -264,7 +264,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
pProgrInfo->ReportError();
}
- return aTmpList.GetObjCount();
+ return aTmpList.size();
}
void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
@@ -427,7 +427,7 @@ void ImpSdrGDIMetaFileImport::InsertObj( SdrObject* pObj, sal_Bool bScale )
}
else
{
- aTmpList.InsertObject( pObj );
+ aTmpList.push_back( pObj );
if ( HAS_BASE( SdrPathObj, pObj ) )
{
bool bClosed=pObj->IsClosedObj();
@@ -563,9 +563,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc
}
// #i73407# reformulation to use new B2DPolygon classes
- if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count())
+ if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count() && !aTmpList.empty())
{
- SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
+ SdrObject* pTmpObj = aTmpList.back();
SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
if(pLastPoly)
@@ -629,9 +629,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc
bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
{
// #i73407# reformulation to use new B2DPolygon classes
- if(bLastObjWasPolyWithoutLine)
+ if(bLastObjWasPolyWithoutLine && !aTmpList.empty())
{
- SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
+ SdrObject* pTmpObj = aTmpList.back();
SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
if(pLastPoly)
@@ -929,7 +929,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
void ImpSdrGDIMetaFileImport::MapScaling()
{
- sal_uInt32 i, nAnz = aTmpList.GetObjCount();
+ size_t i, nAnz = aTmpList.size();
const MapMode& rMap = aVD.GetMapMode();
Point aMapOrg( rMap.GetOrigin() );
sal_Bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0;
@@ -937,7 +937,7 @@ void ImpSdrGDIMetaFileImport::MapScaling()
{
for ( i = nMapScalingOfs; i < nAnz; i++ )
{
- SdrObject* pObj = aTmpList.GetObj(i);
+ SdrObject* pObj = aTmpList[i];
if ( bMov2 )
pObj->NbcMove( Size( aMapOrg.X(), aMapOrg.Y() ) );
}
diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx
index ceead0d..f0fc89e 100644
--- a/svx/source/svdraw/svdfmtf.hxx
+++ b/svx/source/svdraw/svdfmtf.hxx
@@ -46,44 +46,16 @@ class SdrObject;
class SvdProgressInfo;
//************************************************************
-// Helper Class SdrObjRefList
-//************************************************************
-
-class SdrObjRefList
-{
- std::vector<SdrObject*> aList;
-public:
-
- SdrObjRefList()
- : aList()
- {}
-
- void Clear() { aList.clear(); }
- sal_uLong GetObjCount() const { return aList.size(); }
- SdrObject* GetObj(sal_uLong nNum) const { return aList[nNum]; }
- SdrObject* operator[](sal_uLong nNum) const { return aList[nNum]; }
- void InsertObject(SdrObject* pObj) { aList.push_back(pObj); }
- void InsertObject(SdrObject* pObj, sal_uLong nPos)
- {
- if(nPos==CONTAINER_APPEND)
- aList.push_back(pObj);
- else
- aList.insert(aList.begin() + nPos, pObj);
- }
- void RemoveObject(sal_uLong nPos) { aList.erase(aList.begin()+nPos); }
-};
-
-//************************************************************
// Helper Class ImpSdrGDIMetaFileImport
//************************************************************
class ImpSdrGDIMetaFileImport
{
protected:
- SdrObjRefList aTmpList;
+ std::vector<SdrObject*> aTmpList;
VirtualDevice aVD;
Rectangle aScaleRect;
- sal_uLong nMapScalingOfs; // from here on, not edited with MapScaling
+ size_t nMapScalingOfs; // from here on, not edited with MapScaling
SfxItemSet* pLineAttr;
SfxItemSet* pFillAttr;
SfxItemSet* pTextAttr;
More information about the Libreoffice-commits
mailing list