summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-06-29 14:26:26 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-30 07:39:50 +0200
commitec0b3af329e8096d791504429db8ebc27fc83a39 (patch)
tree87efe236fef69b3fa1f76acaf6524f8af040f638 /sd
parentaf7b619f2752fcac3492c53444e836371efbd5fe (diff)
sd: support changing position with .uno:EditAnnotation
Change-Id: Ie5c683c06079e4d77d42b242c60cf67257db5c16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97421 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit affe8a36c977d396e1e229b0d656cc8c2c062132) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97462 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx50
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx28
2 files changed, 74 insertions, 4 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index bae15c6b79d2..a3dddaa78bb2 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -110,6 +110,7 @@ public:
void testTdf81754();
void testTdf105502();
void testCommentCallbacks();
+ void testCommentChange();
void testMultiViewInsertDeletePage();
void testDisableUndoRepair();
void testDocumentRepair();
@@ -159,6 +160,7 @@ public:
CPPUNIT_TEST(testTdf81754);
CPPUNIT_TEST(testTdf105502);
CPPUNIT_TEST(testCommentCallbacks);
+ CPPUNIT_TEST(testCommentChange);
CPPUNIT_TEST(testMultiViewInsertDeletePage);
CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST(testDocumentRepair);
@@ -1779,6 +1781,54 @@ void SdTiledRenderingTest::testCommentCallbacks()
comphelper::LibreOfficeKit::setTiledAnnotations(true);
}
+void SdTiledRenderingTest::testCommentChange()
+{
+ uno::Sequence<beans::PropertyValue> aArgs;
+
+ // Load the document.
+ // Set the tiled annotations off
+ comphelper::LibreOfficeKit::setTiledAnnotations(false);
+
+ createDoc("dummy.odp", comphelper::InitPropertySequence(
+ {
+ {".uno:Author", uno::makeAny(OUString("LOK User1"))},
+ }));
+
+ ViewCallback aView1;
+
+ // Add a new comment
+ aArgs = comphelper::InitPropertySequence(
+ {
+ {"Text", uno::makeAny(OUString("Comment"))},
+ });
+ comphelper::dispatchCommand(".uno:InsertAnnotation", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
+
+ int nComment1 = aView1.m_aCommentCallbackResult.get<int>("id");
+
+ CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty());
+ CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
+ CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 0, 0"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle"));
+
+ // Edit this annotation now
+ aArgs = comphelper::InitPropertySequence(
+ {
+ {"Id", uno::makeAny(OUString::number(nComment1))},
+ {"PositionX", uno::makeAny(sal_Int32(10))},
+ {"PositionY", uno::makeAny(sal_Int32(20))}
+ });
+ comphelper::dispatchCommand(".uno:EditAnnotation", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action"));
+ CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text"));
+ CPPUNIT_ASSERT_EQUAL(std::string("10, 20, 0, 0"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle"));
+
+ comphelper::LibreOfficeKit::setTiledAnnotations(true);
+}
+
void SdTiledRenderingTest::testMultiViewInsertDeletePage()
{
// Load the document.
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index b3b81b8c37ae..902bac125ce7 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -33,6 +33,7 @@
#include <sal/macros.h>
#include <svl/itempool.hxx>
+#include <svl/intitem.hxx>
#include <unotools/localedatawrapper.hxx>
#include <unotools/useroptions.hxx>
#include <unotools/syslocale.hxx>
@@ -389,6 +390,9 @@ void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest const & rReq)
Reference< XAnnotation > xAnnotation;
sal_uInt32 nId = 0;
OUString sText;
+ sal_Int32 nPositionX = -1;
+ sal_Int32 nPositionY = -1;
+
if (!pArgs)
return;
@@ -404,13 +408,29 @@ void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest const & rReq)
if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_TEXT, true, &pPoolItem))
sText = static_cast<const SfxStringItem*>(pPoolItem)->GetValue();
- if (xAnnotation.is() && !sText.isEmpty())
+ if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_POSITION_X, true, &pPoolItem))
+ nPositionX = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+
+ if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_POSITION_Y, true, &pPoolItem))
+ nPositionY = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+
+ if (xAnnotation.is())
{
CreateChangeUndo(xAnnotation);
- // TODO: Not allow other authors to change others' comments ?
- Reference<XText> xText(xAnnotation->getTextRange());
- xText->setString(sText);
+ if (nPositionX >= 0 && nPositionY >= 0)
+ {
+ double fX = convertTwipToMm100(nPositionX) / 100.0;
+ double fY = convertTwipToMm100(nPositionY) / 100.0;
+ xAnnotation->setPosition({fX, fY});
+ }
+
+ if (!sText.isEmpty())
+ {
+ // TODO: Not allow other authors to change others' comments ?
+ Reference<XText> xText(xAnnotation->getTextRange());
+ xText->setString(sText);
+ }
LOKCommentNotifyAll(CommentNotificationType::Modify, xAnnotation);
}