summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-01-30 20:14:10 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-01-31 07:21:39 +0000
commit1e92059fe95cc1ba31aab4a66926d55bc00d0684 (patch)
treef6d6523928daff96ff0a2d15ab923c4777ab09e7 /include
parentd9ebb2e76bf7ec068ebfceccf7f477471012d157 (diff)
svx: Refactor (sdr) views to access the SdrModel by reference
In SdrPaintView (and subclasses) the mpModel variable is always the same as the input (reference) model, so there is no need for that extra variable. Change the strange and confusing var. name mrSdrModelFromSdrView (the input reference to SdrModel) to just mrModel and use that in GetModel(). Change the GetModel() to return a reference instead of a pointer and reactor the code to accomodate the change. This gets rid of many nullptr checks for the pointer that the GetModel() returns and makes the code more simple is some cases. Change-Id: I18351a417fd82f49262a83de036ec1420a65399c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146373 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/svx/svdedtv.hxx37
-rw-r--r--include/svx/svdpntv.hxx8
2 files changed, 34 insertions, 11 deletions
diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx
index 1a6ba3897152..2ff56e71b17b 100644
--- a/include/svx/svdedtv.hxx
+++ b/include/svx/svdedtv.hxx
@@ -174,14 +174,37 @@ public:
// between BegUndo() and EndUndo() calls (unlimited).
// The comment used for the UndoAction is the first BegUndo(String).
// In this case NotifyNewUndoAction is called at the last EndUndo().
- // NotifyNewUndoAction() is not called for an empty group.
- void BegUndo() { mpModel->BegUndo(); } // open undo-grouping
- void BegUndo(const OUString& rComment) { mpModel->BegUndo(rComment); } // open undo-grouping
- void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc=SdrRepeatFunc::NONE) { mpModel->BegUndo(rComment,rObjDescr,eFunc); } // open undo-grouping
- void EndUndo(); // close undo-grouping (incl. BroadcastEdges)
- void AddUndo(std::unique_ptr<SdrUndoAction> pUndo) { mpModel->AddUndo(std::move(pUndo)); } // add action
+ // NotifyNewUndoAction() is not called for an empty group
+ void BegUndo()
+ {
+ // open undo-grouping
+ GetModel().BegUndo();
+ }
+ void BegUndo(const OUString& rComment)
+ {
+ // open undo-grouping
+ GetModel().BegUndo(rComment);
+ }
+ void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc=SdrRepeatFunc::NONE)
+ {
+ // open undo-grouping
+ GetModel().BegUndo(rComment,rObjDescr,eFunc);
+ }
+
+ void EndUndo(); // close undo-grouping (incl. BroadcastEdges)
+
+ void AddUndo(std::unique_ptr<SdrUndoAction> pUndo)
+ {
+ // add action
+ GetModel().AddUndo(std::move(pUndo));
+ }
+
// only after first BegUndo or before last EndUndo:
- void SetUndoComment(const OUString& rComment, const OUString& rObjDescr) { mpModel->SetUndoComment(rComment,rObjDescr); }
+ void SetUndoComment(const OUString& rComment, const OUString& rObjDescr)
+ {
+ GetModel().SetUndoComment(rComment,rObjDescr);
+ }
+
bool IsUndoEnabled() const;
/**
diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx
index 7e49d959232b..f6be42ee1e9a 100644
--- a/include/svx/svdpntv.hxx
+++ b/include/svx/svdpntv.hxx
@@ -118,11 +118,10 @@ private:
friend class SdrGrafObj;
// the SdrModel this view was created with, unchanged during lifetime
- SdrModel& mrSdrModelFromSdrView;
+ SdrModel& mrModel;
std::unique_ptr<SdrPageView> mpPageView;
protected:
- SdrModel* mpModel;
VclPtr<OutputDevice> mpActualOutDev; // Only for comparison
VclPtr<OutputDevice> mpDragWin;
SfxStyleSheet* mpDefaultStyleSheet;
@@ -255,10 +254,11 @@ protected:
public:
// SdrModel access on SdrView level
- SdrModel& getSdrModelFromSdrView() const { return mrSdrModelFromSdrView; }
+ SdrModel& getSdrModelFromSdrView() const { return mrModel; }
+
+ SdrModel& GetModel() const { return mrModel; }
virtual void ClearPageView();
- SdrModel* GetModel() const { return mpModel; }
virtual bool IsAction() const;
virtual void MovAction(const Point& rPnt);