Kaydet (Commit) 1b4ce7cd authored tarafından Pranav Kant's avatar Pranav Kant Kaydeden (comit) pranavk

sd lok: Support editing annotations by id + unit test

Change-Id: Id4faf59eab8c72a2d78157bca15a5e07f9622dde
Reviewed-on: https://gerrit.libreoffice.org/34512Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarpranavk <pranavk@collabora.co.uk>
üst 76198c53
...@@ -1647,6 +1647,25 @@ void SdTiledRenderingTest::testCommentCallbacks() ...@@ -1647,6 +1647,25 @@ void SdTiledRenderingTest::testCommentCallbacks()
CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty()); CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty());
CPPUNIT_ASSERT(!aView2.m_aCommentCallbackResult.get<std::string>("parthash").empty()); CPPUNIT_ASSERT(!aView2.m_aCommentCallbackResult.get<std::string>("parthash").empty());
// Edit this annotation now
aArgs = comphelper::InitPropertySequence(
{
{"Id", uno::makeAny(OUString::number(nComment1))},
{"Text", uno::makeAny(OUString("Edited comment"))},
});
comphelper::dispatchCommand(".uno:EditAnnotation", aArgs);
Scheduler::ProcessEventsToIdle();
// We received a LOK_CALLBACK_COMMENT callback with comment 'Modify' action
CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView2.m_aCommentCallbackResult.get<std::string>("action"));
CPPUNIT_ASSERT_EQUAL(nComment1, aView1.m_aCommentCallbackResult.get<int>("id"));
CPPUNIT_ASSERT_EQUAL(nComment1, aView2.m_aCommentCallbackResult.get<int>("id"));
CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty());
CPPUNIT_ASSERT(!aView2.m_aCommentCallbackResult.get<std::string>("parthash").empty());
CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text"));
// Delete the comment // Delete the comment
aArgs = comphelper::InitPropertySequence( aArgs = comphelper::InitPropertySequence(
{ {
......
...@@ -154,6 +154,11 @@ interface ImpressEditView : DrawView ...@@ -154,6 +154,11 @@ interface ImpressEditView : DrawView
ExecMethod = ExecuteAnnotation; ExecMethod = ExecuteAnnotation;
StateMethod = GetAnnotationState; StateMethod = GetAnnotationState;
] ]
SID_EDIT_POSTIT
[
ExecMethod = ExecuteAnnotation;
StateMethod = GetAnnotationState;
]
SID_REPLYTO_POSTIT SID_REPLYTO_POSTIT
[ [
ExecMethod = ExecuteAnnotation; ExecMethod = ExecuteAnnotation;
......
...@@ -354,6 +354,9 @@ void AnnotationManagerImpl::ExecuteAnnotation(SfxRequest& rReq ) ...@@ -354,6 +354,9 @@ void AnnotationManagerImpl::ExecuteAnnotation(SfxRequest& rReq )
case SID_DELETEALLBYAUTHOR_POSTIT: case SID_DELETEALLBYAUTHOR_POSTIT:
ExecuteDeleteAnnotation( rReq ); ExecuteDeleteAnnotation( rReq );
break; break;
case SID_EDIT_POSTIT:
ExecuteEditAnnotation( rReq );
break;
case SID_PREVIOUS_POSTIT: case SID_PREVIOUS_POSTIT:
case SID_NEXT_POSTIT: case SID_NEXT_POSTIT:
SelectNextAnnotation( rReq.GetSlot() == SID_NEXT_POSTIT ); SelectNextAnnotation( rReq.GetSlot() == SID_NEXT_POSTIT );
...@@ -434,6 +437,41 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq) ...@@ -434,6 +437,41 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq)
UpdateTags(); UpdateTags();
} }
void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest& rReq)
{
const SfxItemSet* pArgs = rReq.GetArgs();
Reference< XAnnotation > xAnnotation;
sal_uInt32 nId = 0;
OUString sText;
if (pArgs)
{
const SfxPoolItem* pPoolItem = nullptr;
if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_ID, true, &pPoolItem))
{
nId = static_cast<const SvxPostItIdItem*>(pPoolItem)->GetValue().toUInt32();
xAnnotation = GetAnnotationById(nId);
}
if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_TEXT, true, &pPoolItem))
sText = static_cast<const SfxStringItem*>(pPoolItem)->GetValue();
if (xAnnotation.is() && !sText.isEmpty())
{
// TODO: Not allow other authors to change others' comments ?
Reference<XText> xText(xAnnotation->getTextRange());
xText->setString(sText);
const SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
lcl_CommentNotification(CommentNotificationType::Modify, pViewShell, xAnnotation);
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
}
UpdateTags(true);
}
void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) void AnnotationManagerImpl::InsertAnnotation(const OUString& rText)
{ {
SdPage* pPage = GetCurrentPage(); SdPage* pPage = GetCurrentPage();
...@@ -719,9 +757,13 @@ void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet) ...@@ -719,9 +757,13 @@ void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet)
Reference< XAnnotation > xAnnotation; Reference< XAnnotation > xAnnotation;
GetSelectedAnnotation( xAnnotation ); GetSelectedAnnotation( xAnnotation );
// Don't disable SID_DELETE_POSTIT slot in case of LOK // Don't disable these slot in case of LOK, as postit doesn't need to
// selected before doing an operation on it in LOK
if( (!xAnnotation.is() && !comphelper::LibreOfficeKit::isActive()) || bReadOnly ) if( (!xAnnotation.is() && !comphelper::LibreOfficeKit::isActive()) || bReadOnly )
{
rSet.DisableItem( SID_DELETE_POSTIT ); rSet.DisableItem( SID_DELETE_POSTIT );
rSet.DisableItem( SID_EDIT_POSTIT );
}
SdPage* pPage = nullptr; SdPage* pPage = nullptr;
......
...@@ -66,6 +66,7 @@ public: ...@@ -66,6 +66,7 @@ public:
void ExecuteInsertAnnotation(SfxRequest& rReq); void ExecuteInsertAnnotation(SfxRequest& rReq);
void ExecuteDeleteAnnotation(SfxRequest& rReq); void ExecuteDeleteAnnotation(SfxRequest& rReq);
void ExecuteEditAnnotation(SfxRequest& rReq);
void ExecuteReplyToAnnotation(SfxRequest& rReq); void ExecuteReplyToAnnotation(SfxRequest& rReq);
void SelectNextAnnotation(bool bForeward); void SelectNextAnnotation(bool bForeward);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment