summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/svxids.hrc3
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx50
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx28
-rw-r--r--svx/sdi/svx.sdi7
4 files changed, 83 insertions, 5 deletions
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index be93603f8444..9081fe0f36f6 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -221,6 +221,9 @@ class SvxSetItem;
// CAUTION! Range <64 .. 67> used by EditEngine (!)
+#define SID_ATTR_POSTIT_POSITION_X TypedWhichId<SfxInt32Item>( SID_SVX_START + 68 )
+#define SID_ATTR_POSTIT_POSITION_Y TypedWhichId<SfxInt32Item>( SID_SVX_START + 69 )
+
#define SID_RULER_CHANGE_STATE ( SID_SVX_START + 78 )
#define SID_RULER_NULL_OFFSET TypedWhichId<SfxPointItem>( SID_SVX_START + 79 )
#define SID_RULER_BORDERS TypedWhichId<SvxRulerItem>( SID_SVX_START + 80 )
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 8eef1f6733dd..647d01dbe2b1 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -111,6 +111,7 @@ public:
void testTdf81754();
void testTdf105502();
void testCommentCallbacks();
+ void testCommentChange();
void testMultiViewInsertDeletePage();
void testDisableUndoRepair();
void testDocumentRepair();
@@ -161,6 +162,7 @@ public:
CPPUNIT_TEST(testTdf81754);
CPPUNIT_TEST(testTdf105502);
CPPUNIT_TEST(testCommentCallbacks);
+ CPPUNIT_TEST(testCommentChange);
CPPUNIT_TEST(testMultiViewInsertDeletePage);
CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST(testDocumentRepair);
@@ -1807,6 +1809,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 512ed85a786d..4edab188efab 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);
}
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index fcf88f0f0659..738d3bc671fb 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -4501,7 +4501,12 @@ SfxVoidItem InsertAnnotation SID_INSERT_POSTIT
]
SfxVoidItem EditAnnotation SID_EDIT_POSTIT
-(SvxPostItIdItem Id SID_ATTR_POSTIT_ID,SvxPostItAuthorItem Author SID_ATTR_POSTIT_AUTHOR,SvxPostItDateItem Date SID_ATTR_POSTIT_DATE,SvxPostItTextItem Text SID_ATTR_POSTIT_TEXT)
+(SvxPostItIdItem Id SID_ATTR_POSTIT_ID,
+ SvxPostItAuthorItem Author SID_ATTR_POSTIT_AUTHOR,
+ SvxPostItDateItem Date SID_ATTR_POSTIT_DATE,
+ SvxPostItTextItem Text SID_ATTR_POSTIT_TEXT,
+ SfxInt32Item PositionX SID_ATTR_POSTIT_POSITION_X
+ SfxInt32Item PositionY SID_ATTR_POSTIT_POSITION_Y)
[
AutoUpdate = FALSE,
FastCall = FALSE,