summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/AnnotationWin.hxx3
-rw-r--r--sw/inc/PostItMgr.hxx7
-rw-r--r--sw/source/uibase/docvw/AnnotationWin.cxx6
-rw-r--r--sw/source/uibase/docvw/AnnotationWin2.cxx4
-rw-r--r--sw/source/uibase/docvw/PostItMgr.cxx6
5 files changed, 13 insertions, 13 deletions
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 69335760f4fe..53ae31f83b10 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SW_INC_ANNOTATIONWIN_HXX
#include <basegfx/range/b2drange.hxx>
+#include <editeng/outlobj.hxx>
#include <tools/date.hxx>
#include <tools/time.hxx>
#include <vcl/InterimItemWindow.hxx>
@@ -80,7 +81,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow
/// Calculate parent postit id of current annotation window
sal_uInt32 CalcParent();
- void InitAnswer(OutlinerParaObject const * pText);
+ void InitAnswer(OutlinerParaObject const & rText);
bool IsProtected() const;
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index 760fc7f8abe7..a2f0af3b9dea 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -33,6 +33,7 @@
#include <unotools/configitem.hxx>
#include <com/sun/star/uno/Any.hxx>
#include "SidebarWindowsTypes.hxx"
+#include <editeng/outlobj.hxx>
#include <svl/lstner.hxx>
#include <vcl/vclptr.hxx>
@@ -137,7 +138,7 @@ class SAL_DLLPUBLIC_RTTI SwPostItMgr final : public SfxListener
bool mbReadOnly;
bool mbDeleteNote;
FieldShadowState mShadowState;
- OutlinerParaObject* mpAnswer;
+ std::optional<OutlinerParaObject> mpAnswer;
OUString maAnswerText;
bool mbIsShowAnchor;
@@ -251,8 +252,8 @@ class SAL_DLLPUBLIC_RTTI SwPostItMgr final : public SfxListener
static Color GetColorLight(std::size_t aAuthorIndex);
static Color GetColorAnchor(std::size_t aAuthorIndex);
- void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
- OutlinerParaObject* IsAnswer() {return mpAnswer;}
+ void RegisterAnswer(OutlinerParaObject* pAnswer) { if (pAnswer) mpAnswer =* pAnswer; else mpAnswer.reset(); }
+ OutlinerParaObject* IsAnswer() { return mpAnswer ? &*mpAnswer : nullptr; }
void RegisterAnswerText(const OUString& aAnswerText) { maAnswerText = aAnswerText; }
const OUString& GetAnswerText() const { return maAnswerText; }
void CheckMetaText();
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx
index 01d12affedad..7ecc4889b5fc 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -397,7 +397,7 @@ sal_uInt32 SwAnnotationWin::CountFollowing()
return aCount - 1;
}
-void SwAnnotationWin::InitAnswer(OutlinerParaObject const * pText)
+void SwAnnotationWin::InitAnswer(OutlinerParaObject const & rText)
{
// If tiled annotations is off in lok case, skip adding additional reply text.
if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations())
@@ -420,8 +420,8 @@ void SwAnnotationWin::InitAnswer(OutlinerParaObject const * pText)
// insert old, selected text or "..."
// TODO: iterate over all paragraphs, not only first one to find out if it is empty
- if (!pText->GetTextObject().GetText(0).isEmpty())
- GetOutlinerView()->GetEditView().InsertText(pText->GetTextObject());
+ if (!rText.GetTextObject().GetText(0).isEmpty())
+ GetOutlinerView()->GetEditView().InsertText(rText.GetTextObject());
else
GetOutlinerView()->InsertText("...");
GetOutlinerView()->InsertText("\"\n");
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 71a78d6fae0e..12988e4d3343 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1072,8 +1072,8 @@ void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot)
// will be created
if (!mpOutliner->GetEditEngine().GetText().isEmpty())
{
- OutlinerParaObject* pPara = new OutlinerParaObject(GetOutlinerView()->GetEditView().CreateTextObject());
- mrMgr.RegisterAnswer(pPara);
+ OutlinerParaObject aPara(GetOutlinerView()->GetEditView().CreateTextObject());
+ mrMgr.RegisterAnswer(&aPara);
}
if (mrMgr.HasActiveSidebarWin())
mrMgr.SetActiveSidebarWin(nullptr);
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index fe85da695657..a60b70b6cbef 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -200,7 +200,6 @@ SwPostItMgr::SwPostItMgr(SwView* pView)
, mbLayouting(false)
, mbReadOnly(mpView->GetDocShell()->IsReadOnly())
, mbDeleteNote(true)
- , mpAnswer(nullptr)
, mbIsShowAnchor( false )
{
if(!mpView->GetDrawView() )
@@ -742,9 +741,8 @@ void SwPostItMgr::LayoutPostIts()
if (mpAnswer)
{
if (static_cast<bool>(pPostIt->CalcParent())) //do we really have another note in front of this one
- pPostIt->InitAnswer(mpAnswer);
- delete mpAnswer;
- mpAnswer = nullptr;
+ pPostIt->InitAnswer(*mpAnswer);
+ mpAnswer.reset();
}
}