summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2018-06-08 17:09:55 -0400
committerEike Rathke <erack@redhat.com>2018-06-26 14:24:02 +0200
commitb6b1ded0a0539e7be1b5338de378a3276a6ff445 (patch)
tree79ac65de77ee5eadf714adb62628f74f4265491f /sc/source/ui
parentf5e2dbb40cab1a21dc972806ee4038f52843e838 (diff)
sc: replace ScCaptionPtr with std::shared_ptr, tdf#117997, tdf#117228
Change-Id: I9b6a2c2504c9ce060906ac3bf156721709fef2f3 Reviewed-on: https://gerrit.libreoffice.org/55490 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/app/scmod.cxx28
-rw-r--r--sc/source/ui/docshell/docfunc.cxx4
-rw-r--r--sc/source/ui/docshell/docsh.cxx33
-rw-r--r--sc/source/ui/drawfunc/futext3.cxx4
-rw-r--r--sc/source/ui/inc/docsh.hxx2
-rw-r--r--sc/source/ui/inc/notemark.hxx2
-rw-r--r--sc/source/ui/inc/undocell.hxx45
-rw-r--r--sc/source/ui/undo/undocell.cxx185
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx2
-rw-r--r--sc/source/ui/unoobj/notesuno.cxx2
-rw-r--r--sc/source/ui/view/drawview.cxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx2
-rw-r--r--sc/source/ui/view/notemark.cxx2
-rw-r--r--sc/source/ui/view/tabview5.cxx2
-rw-r--r--sc/source/ui/view/viewfun6.cxx2
15 files changed, 266 insertions, 51 deletions
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index c0f8a33b8367..687ced15ef33 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -659,34 +659,6 @@ void ScModule::SetDragJump(
m_pDragData->aJumpText = rText;
}
-ScDocument* ScModule::GetClipDoc()
-{
- // called from document
- SfxViewFrame* pViewFrame = nullptr;
- ScTabViewShell* pViewShell = nullptr;
- css::uno::Reference<css::datatransfer::XTransferable2> xTransferable;
-
- if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current())))
- xTransferable.set(pViewShell->GetClipData());
- else if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::GetFirst())))
- xTransferable.set(pViewShell->GetClipData());
- else if ((pViewFrame = SfxViewFrame::GetFirst()))
- {
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
- pViewFrame->GetWindow().GetClipboard();
- xTransferable.set(xClipboard.is() ? xClipboard->getContents() : nullptr, css::uno::UNO_QUERY);
- }
-
- const ScTransferObj* pObj = ScTransferObj::GetOwnClipboard(xTransferable);
- if (pObj)
- {
- ScDocument* pDoc = pObj->GetDocument();
- assert((!pDoc || pDoc->IsClipboard()) && "Document is not clipboard, how can that be?");
- return pDoc;
- }
-
- return nullptr;
-}
void ScModule::SetSelectionTransfer( ScSelectionTransferObj* pNew )
{
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 3908a1a35279..518410f25f47 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1206,7 +1206,7 @@ bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
if (ScViewData* pViewData = ScDocShell::GetViewData())
{
if (ScDrawView* pDrawView = pViewData->GetScDrawView())
- pDrawView->SyncForGrid( pNote->GetCaption());
+ pDrawView->SyncForGrid( pNote->GetCaption().get() );
}
rDocShell.SetDocumentModified();
@@ -1282,7 +1282,7 @@ void ScDocFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, c
}
// create the undo action
- if( pUndoMgr && (aOldData.mxCaption || aNewData.mxCaption) )
+ if( pUndoMgr && (aOldData.m_pCaption || aNewData.m_pCaption) )
pUndoMgr->AddUndoAction( new ScUndoReplaceNote( rDocShell, rPos, aOldData, aNewData, pDrawLayer->GetCalcUndo().release() ) );
// repaint cell (to make note marker visible)
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index b0c10dd0989b..40d6107accb5 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -114,6 +114,7 @@
#include <optsolver.hxx>
#include <sheetdata.hxx>
#include <tabprotection.hxx>
+#include <transobj.hxx>
#include <docparam.hxx>
#include "docshimp.hxx"
#include <sizedev.hxx>
@@ -1076,7 +1077,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
// document's drawing layer pages and what not, which otherwise when
// pasting to another document after this document was destructed would
// attempt to access non-existing data. Preserve the text data though.
- ScDocument* pClipDoc = ScModule::GetClipDoc();
+ ScDocument* pClipDoc = GetClipDoc();
if (pClipDoc)
pClipDoc->ClosingClipboardSource();
}
@@ -2783,6 +2784,36 @@ ScDocFunc *ScDocShell::CreateDocFunc()
return new ScDocFuncDirect( *this );
}
+ScDocument* ScDocShell::GetClipDoc()
+{
+ css::uno::Reference<css::datatransfer::XTransferable2> xTransferable;
+
+ if (ScTabViewShell* pViewShell = GetBestViewShell())
+ xTransferable.set(pViewShell->GetClipData());
+ else
+ {
+ SfxViewFrame* pViewFrame = nullptr;
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard;
+
+ if ((pViewFrame = SfxViewFrame::GetFirst(this, false)))
+ xClipboard = pViewFrame->GetWindow().GetClipboard();
+ else if ((pViewFrame = SfxViewFrame::GetFirst()))
+ xClipboard = pViewFrame->GetWindow().GetClipboard();
+
+ xTransferable.set(xClipboard.is() ? xClipboard->getContents() : nullptr, css::uno::UNO_QUERY);
+ }
+
+ const ScTransferObj* pObj = ScTransferObj::GetOwnClipboard(xTransferable);
+ if (pObj)
+ {
+ ScDocument* pDoc = pObj->GetDocument();
+ assert((!pDoc || pDoc->IsClipboard()) && "Document is not clipboard, how can that be?");
+ return pDoc;
+ }
+
+ return nullptr;
+}
+
ScDocShell::ScDocShell( const ScDocShell& rShell ) :
SvRefBase(),
SotObject(),
diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx
index a9e243fb3583..4a003558c88d 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -68,7 +68,7 @@ void FuText::StopEditMode()
{
aNotePos = pCaptData->maStart;
pNote = rDoc.GetNote( aNotePos );
- OSL_ENSURE( pNote && (pNote->GetCaption() == pObject), "FuText::StopEditMode - missing or invalid cell note" );
+ OSL_ENSURE( pNote && (pNote->GetCaption().get() == pObject), "FuText::StopEditMode - missing or invalid cell note" );
}
ScDocShell* pDocShell = rViewData.GetDocShell();
@@ -88,7 +88,7 @@ void FuText::StopEditMode()
/* Note has been created before editing, if first undo action is
an insert action. Needed below to decide whether to drop the
undo if editing a new note has been cancelled. */
- bNewNote = (pCalcUndo->GetActionCount() > 0) && dynamic_cast< SdrUndoNewObj* >(pCalcUndo->GetAction( 0 ));
+ bNewNote = (pCalcUndo->GetActionCount() > 0) && dynamic_cast< ScUndoNewSdrCaptionObj* >(pCalcUndo->GetAction( 0 ));
// create a "insert note" undo action if needed
if( bNewNote )
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index d65b09772a75..6082dee5bc6f 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -379,6 +379,8 @@ public:
ScTabViewShell* GetBestViewShell( bool bOnlyVisible = true );
+ ScDocument* GetClipDoc();
+
void SetDocumentModifiedPending( bool bVal )
{ m_bDocumentModifiedPending = bVal; }
bool IsDocumentModifiedPending() const
diff --git a/sc/source/ui/inc/notemark.hxx b/sc/source/ui/inc/notemark.hxx
index e0e723c624c3..a8305316e2d4 100644
--- a/sc/source/ui/inc/notemark.hxx
+++ b/sc/source/ui/inc/notemark.hxx
@@ -48,7 +48,7 @@ private:
tools::Rectangle m_aRect;
ScDrawView* m_pDrawView;
SdrModel* m_pModel;
- ScCaptionPtr m_xObject;
+ std::shared_ptr< SdrCaptionObj > m_xObject;
bool m_bVisible;
DECL_LINK( TimeHdl, Timer*, void );
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index 67306e5d6e71..695c36f609d0 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -42,6 +42,51 @@ class CellValues;
}
+class ScUndoSdrCaptionObj: public SdrUndoAction
+{
+protected:
+ SdrObjList* m_pObjList;
+ sal_uInt32 m_nOrdNum;
+ std::shared_ptr< SdrCaptionObj > m_pCaptionObj;
+
+ void UnmarkObject();
+ void BroadcastSwitchToPage();
+ OUString GetDescriptionString( const char* pStrCacheID, bool bRepeat = false ) const;
+
+public:
+ ScUndoSdrCaptionObj(const std::shared_ptr< SdrCaptionObj >&);
+ virtual ~ScUndoSdrCaptionObj() override;
+};
+
+class ScUndoDelSdrCaptionObj: public ScUndoSdrCaptionObj
+{
+public:
+ ScUndoDelSdrCaptionObj(const std::shared_ptr< SdrCaptionObj >& pCaptionObj);
+ virtual ~ScUndoDelSdrCaptionObj() override;
+
+ virtual void Undo() override;
+ virtual void Redo() override;
+
+ virtual OUString GetComment() const override;
+ virtual OUString GetSdrRepeatComment(SdrView& rView) const override;
+
+ virtual void SdrRepeat(SdrView& rView) override;
+ virtual bool CanSdrRepeat(SdrView& rView) const override;
+};
+
+
+class ScUndoNewSdrCaptionObj: public ScUndoSdrCaptionObj
+{
+public:
+ ScUndoNewSdrCaptionObj(const std::shared_ptr< SdrCaptionObj >& pCaptionObj);
+ virtual ~ScUndoNewSdrCaptionObj() override;
+
+ virtual void Undo() override;
+ virtual void Redo() override;
+
+ virtual OUString GetComment() const override;
+};
+
class ScUndoCursorAttr: public ScSimpleUndo
{
public:
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index fc9015daff20..04048d8ef96e 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -25,6 +25,12 @@
#include <editeng/justifyitem.hxx>
#include <svl/zforlist.hxx>
#include <svl/sharedstringpool.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/e3dsceneupdater.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdviter.hxx>
+#include <svx/strings.hrc>
#include <sfx2/app.hxx>
#include <attrib.hxx>
@@ -715,22 +721,183 @@ bool ScUndoThesaurus::CanRepeat(SfxRepeatTarget& rTarget) const
return dynamic_cast<const ScTabViewTarget*>( &rTarget) != nullptr;
}
+
+ScUndoSdrCaptionObj::ScUndoSdrCaptionObj(const std::shared_ptr< SdrCaptionObj >& pCaptionObj)
+ : SdrUndoAction(pCaptionObj->getSdrModelFromSdrObject())
+ , m_pObjList(pCaptionObj->getParentSdrObjListFromSdrObject())
+ , m_nOrdNum(pCaptionObj->GetOrdNum())
+ , m_pCaptionObj(pCaptionObj)
+{
+}
+
+ScUndoSdrCaptionObj::~ScUndoSdrCaptionObj()
+{
+}
+
+void ScUndoSdrCaptionObj::BroadcastSwitchToPage()
+{
+ if (m_pCaptionObj && m_pCaptionObj->IsInserted() && m_pCaptionObj->getSdrPageFromSdrObject())
+ {
+ SdrHint aHint(SdrHintKind::SwitchToPage, *m_pCaptionObj, m_pCaptionObj->getSdrPageFromSdrObject());
+ rMod.Broadcast(aHint);
+ }
+}
+
+void ScUndoSdrCaptionObj::UnmarkObject()
+{
+ SdrViewIter aIter( m_pCaptionObj.get() );
+ for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
+ {
+ pView->MarkObj( m_pCaptionObj.get(), pView->GetSdrPageView(), true );
+ }
+}
+
+OUString ScUndoSdrCaptionObj::GetDescriptionString(const char* pStrCacheID, bool bRepeat ) const
+{
+ const OUString rStr {SvxResId(pStrCacheID)};
+
+ const sal_Int32 nPos = rStr.indexOf("%1");
+ if (nPos < 0)
+ return rStr;
+
+ if (bRepeat)
+ return rStr.replaceAt(nPos, 2, SvxResId(STR_ObjNameSingulPlural));
+
+ return rStr.replaceAt(nPos, 2, m_pCaptionObj->TakeObjNameSingul());
+}
+
+ScUndoDelSdrCaptionObj::ScUndoDelSdrCaptionObj(const std::shared_ptr< SdrCaptionObj >& pCaptionObj)
+ : ScUndoSdrCaptionObj(pCaptionObj)
+{
+}
+
+ScUndoDelSdrCaptionObj::~ScUndoDelSdrCaptionObj()
+{
+
+}
+
+void ScUndoDelSdrCaptionObj::Undo()
+{
+ // Trigger PageChangeCall
+ BroadcastSwitchToPage();
+
+ if (!m_pCaptionObj->IsInserted())
+ {
+ Point aOwnerAnchorPos(0, 0);
+
+ if (dynamic_cast< const SdrObjGroup* >(m_pObjList->getSdrObjectFromSdrObjList()) != nullptr)
+ {
+ aOwnerAnchorPos = m_pObjList->getSdrObjectFromSdrObjList()->GetAnchorPos();
+ }
+
+ E3DModifySceneSnapRectUpdater aUpdater(m_pObjList->getSdrObjectFromSdrObjList());
+ m_pObjList->InsertObject(m_pCaptionObj.get(), m_nOrdNum);
+
+ if(aOwnerAnchorPos.X() || aOwnerAnchorPos.Y())
+ {
+ m_pCaptionObj->NbcSetAnchorPos(aOwnerAnchorPos);
+ }
+ }
+
+}
+
+void ScUndoDelSdrCaptionObj::Redo()
+{
+ if (m_pCaptionObj->IsInserted())
+ {
+ UnmarkObject();
+ E3DModifySceneSnapRectUpdater aUpdater(m_pCaptionObj.get());
+ m_pObjList->RemoveObject(m_nOrdNum);
+ }
+
+ // Trigger PageChangeCall
+ BroadcastSwitchToPage();
+}
+
+OUString ScUndoDelSdrCaptionObj::GetComment() const
+{
+ return GetDescriptionString(STR_EditDelete);
+}
+
+void ScUndoDelSdrCaptionObj::SdrRepeat(SdrView& rView)
+{
+ rView.DeleteMarked();
+}
+
+bool ScUndoDelSdrCaptionObj::CanSdrRepeat(SdrView& rView) const
+{
+ return rView.AreObjectsMarked();
+}
+
+OUString ScUndoDelSdrCaptionObj::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ return GetDescriptionString(STR_EditDelete, true);
+}
+
+ScUndoNewSdrCaptionObj::ScUndoNewSdrCaptionObj(const std::shared_ptr< SdrCaptionObj >& pCaptionObj)
+ : ScUndoSdrCaptionObj(pCaptionObj)
+{
+}
+
+ScUndoNewSdrCaptionObj::~ScUndoNewSdrCaptionObj()
+{
+}
+
+void ScUndoNewSdrCaptionObj::Undo()
+{
+ // Trigger PageChangeCall
+ BroadcastSwitchToPage();
+
+ if (m_pCaptionObj->IsInserted())
+ {
+ UnmarkObject();
+ m_pObjList->RemoveObject(m_nOrdNum);
+ }
+}
+
+void ScUndoNewSdrCaptionObj::Redo()
+{
+ if (!m_pCaptionObj->IsInserted())
+ {
+ Point aAnchorPos( 0, 0 );
+
+ if (dynamic_cast<const SdrObjGroup*>(m_pObjList->getSdrObjectFromSdrObjList()) != nullptr)
+ {
+ aAnchorPos = m_pCaptionObj->GetAnchorPos();
+ }
+
+ m_pObjList->InsertObject(m_pCaptionObj.get(), m_nOrdNum);
+
+ // Arcs lose position when grouped (#i45952#)
+ if ( aAnchorPos.X() || aAnchorPos.Y() )
+ {
+ m_pCaptionObj->NbcSetAnchorPos( aAnchorPos );
+ }
+ }
+
+ // Trigger PageChangeCall
+ BroadcastSwitchToPage();
+}
+
+OUString ScUndoNewSdrCaptionObj::GetComment() const
+{
+ return GetDescriptionString(STR_UndoInsertObj);
+}
+
ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rPos,
const ScNoteData& rNoteData, bool bInsert, SdrUndoAction* pDrawUndo ) :
ScSimpleUndo( &rDocShell ),
maPos( rPos ),
mpDrawUndo( pDrawUndo )
{
- OSL_ENSURE( rNoteData.mxCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note caption" );
+ OSL_ENSURE( rNoteData.m_pCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note caption" );
if (bInsert)
{
maNewData = rNoteData;
- maNewData.mxCaption.setNotOwner();
}
else
{
maOldData = rNoteData;
- maOldData.mxCaption.setNotOwner();
}
}
@@ -742,10 +909,8 @@ ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rP
maNewData( rNewData ),
mpDrawUndo( pDrawUndo )
{
- OSL_ENSURE( maOldData.mxCaption || maNewData.mxCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note captions" );
+ OSL_ENSURE( maOldData.m_pCaption || maNewData.m_pCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note captions" );
OSL_ENSURE( !maOldData.mxInitData.get() && !maNewData.mxInitData.get(), "ScUndoReplaceNote::ScUndoReplaceNote - unexpected uninitialized note" );
- maOldData.mxCaption.setNotOwner();
- maNewData.mxCaption.setNotOwner();
}
ScUndoReplaceNote::~ScUndoReplaceNote()
@@ -790,13 +955,13 @@ bool ScUndoReplaceNote::CanRepeat( SfxRepeatTarget& /*rTarget*/ ) const
OUString ScUndoReplaceNote::GetComment() const
{
- return ScResId( maNewData.mxCaption ?
- (maOldData.mxCaption ? STR_UNDO_EDITNOTE : STR_UNDO_INSERTNOTE) : STR_UNDO_DELETENOTE );
+ return ScResId( maNewData.m_pCaption ?
+ (maOldData.m_pCaption ? STR_UNDO_EDITNOTE : STR_UNDO_INSERTNOTE) : STR_UNDO_DELETENOTE );
}
void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData )
{
- if( rNoteData.mxCaption )
+ if( rNoteData.m_pCaption )
{
ScDocument& rDoc = pDocShell->GetDocument();
OSL_ENSURE( !rDoc.GetNote(maPos), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" );
@@ -808,7 +973,7 @@ void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData )
void ScUndoReplaceNote::DoRemoveNote( const ScNoteData& rNoteData )
{
- if( rNoteData.mxCaption )
+ if( rNoteData.m_pCaption )
{
ScDocument& rDoc = pDocShell->GetDocument();
OSL_ENSURE( rDoc.GetNote(maPos), "ScUndoReplaceNote::DoRemoveNote - missing cell note" );
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index fb59b24b328e..2989c6aed34a 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -137,7 +137,7 @@ std::unique_ptr<SvxEditSource> ScAnnotationEditSource::Clone() const
SdrObject* ScAnnotationEditSource::GetCaptionObj()
{
ScPostIt* pNote = pDocShell->GetDocument().GetNote(aCellPos);
- return pNote ? pNote->GetOrCreateCaption( aCellPos ) : nullptr;
+ return pNote ? pNote->GetOrCreateCaption( aCellPos ).get() : nullptr;
}
SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx
index 12e44a040e85..796ed043e3e6 100644
--- a/sc/source/ui/unoobj/notesuno.cxx
+++ b/sc/source/ui/unoobj/notesuno.cxx
@@ -216,7 +216,7 @@ uno::Reference < drawing::XShape > SAL_CALL ScAnnotationObj::getAnnotationShape(
SolarMutexGuard aGuard;
uno::Reference < drawing::XShape > xShape;
if( const ScPostIt* pNote = ImplGetNote() )
- if( SdrObject* pCaption = pNote->GetOrCreateCaption( aCellPos ) )
+ if( SdrObject* pCaption = pNote->GetOrCreateCaption( aCellPos ).get() )
xShape.set( pCaption->getUnoShape(), uno::UNO_QUERY );
return xShape;
}
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 9069aede14ad..51b281c91b3f 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -867,7 +867,7 @@ void ScDrawView::DeleteMarked()
{
// rescue note data for undo (with pointer to caption object)
ScNoteData aNoteData = pNote->GetNoteData();
- OSL_ENSURE( aNoteData.mxCaption.get() == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
+ OSL_ENSURE( aNoteData.m_pCaption.get() == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
// collect the drawing undo action created while deleting the note
if( bUndo )
pDrawLayer->BeginCalcUndo(false);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index a159d448b726..a1598a203b0a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -360,7 +360,7 @@ static void lcl_UnLockComment( ScDrawView* pView, const Point& rPos, const ScVie
ScDocument& rDoc = *pViewData->GetDocument();
ScAddress aCellPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
ScPostIt* pNote = rDoc.GetNote( aCellPos );
- SdrObject* pObj = pNote ? pNote->GetCaption() : nullptr;
+ SdrObject* pObj = pNote ? pNote->GetCaption().get() : nullptr;
if( pObj && pObj->GetLogicRect().IsInside( rPos ) && ScDrawLayer::IsNoteCaption( pObj ) )
{
const ScProtectionAttr* pProtAttr = rDoc.GetAttr( aCellPos, ATTR_PROTECTION );
diff --git a/sc/source/ui/view/notemark.cxx b/sc/source/ui/view/notemark.cxx
index af3a404401fb..3df9dc44e2ff 100644
--- a/sc/source/ui/view/notemark.cxx
+++ b/sc/source/ui/view/notemark.cxx
@@ -67,7 +67,7 @@ ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window*
ScNoteMarker::~ScNoteMarker()
{
if (m_pModel)
- m_xObject.release(); // deleting pModel also deletes the SdrCaptionObj
+ m_xObject.reset(); // deleting pModel also deletes the SdrCaptionObj
InvalidateWin();
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 8f95f23078db..058bedd5b1d0 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -653,7 +653,7 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote)
if (!comphelper::LibreOfficeKit::isActive())
return;
- const SdrCaptionObj* pCaption = pNote->GetCaption();
+ const SdrCaptionObj* pCaption = pNote->GetCaption().get();
if (!pCaption) return;
tools::Rectangle aRect = pCaption->GetLogicRect();
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index f37d0d1241fc..28c0340986ba 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -495,7 +495,7 @@ void ScViewFunc::EditNote()
/* Drawing object has been created in ScDocument::GetOrCreateNote() or
in ScPostIt::ShowCaptionTemp(), so ScPostIt::GetCaption() should
return a caption object. */
- if( SdrCaptionObj* pCaption = pNote->GetCaption() )
+ if( SdrCaptionObj* pCaption = pNote->GetCaption().get() )
{
if ( ScDrawView* pScDrawView = GetScDrawView() )
pScDrawView->SyncForGrid( pCaption );