I am attempting to write a series of macros that inserts preset comments into the text. However, the InsertAnnotation dispatcher won't accept any arguments.
Dim document as object
Dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oct1 = ThisComponent.getCurrentController()
dim args2(12) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Text"
args2(0).Value = "Text of the annotation"
args2(1).Name = "Author"
args2(1).Value = "Test"
args2(2).Name = "Date"
args2(2).Value = Now
dispatcher.executeDispatch(document,".uno:InsertAnnotation", "", 0, args2())
Creates empty comment with focus, as if I had just inserted a comment.
It should create a full comment with provided arguments.
Operating System: Windows 7
Version: 184.108.40.206 release
first, a small error occured on args2(2).Value
needed to change to
args2(2).Name = "Date"
args2(2).Value = cstr(Now())
--> strange ! btw, not the problem ?
executing the given code, the Annotation is created, with correct text. The not does not have the focus (hidden comment)
(4.2.4 - linux)
wild guess, provide correct args2() dimension ?
dim args2(2) as new com.sun.star.beans.PropertyValue
problem not reproductible at this stage for me
(In reply to comment #1)
> first, a small error occured on args2(2).Value
> needed to change to
> args2(2).Name = "Date"
> args2(2).Value = cstr(Now())
> --> strange ! btw, not the problem ?
> executing the given code, the Annotation is created, with correct text. The
> not does not have the focus (hidden comment)
> (4.2.4 - linux)
> wild guess, provide correct args2() dimension ?
> dim args2(2) as new com.sun.star.beans.PropertyValue
> problem not reproductible at this stage for me
Thanks for your help; however, after making the recommended changes, the behavior of the macro remains the same. It still creates an empty comment with focus, i.e. it still ignores the args().
Perhaps this only occurs on Windows? Can anyone with a Windows operating system confirm?
Yep, on Windows it creates an empty comment.
Win 7 64-bit Version: 220.127.116.11.alpha1+
Build ID: 1baad070d8c2a38581cf33d803c5043f1974647f
TinderBox: Win-x86@39, Branch:master, Time: 2014-11-01_00:15:06
I'm seeing the same problem -- none of the args2 arguments appear to get passed on to uno:InsertAnnotation. I get a blank comment with the default date and author.
RUnning libreoffice 18.104.22.168 on Arch Linux.
Last worked in Writer in OOo 2.4, broken in OOo 3.0 (with the introduction of the side display for comments), but still works in Calc with current master. The current code in sw/source/uibase/shells/textfld.cxx simply doesn't handle any arguments at all.
That's interesting -- can you possibly indicate what the relevant lines in the sourcecode are? It's not immediately obvious to me when I look at the file. I'm not even sure what the method is supposed to be called, since there's no one-to-one mapping between BASIC and the source classes/functions.
Maxim Monastirsky committed a patch related to this issue.
It has been pushed to "master":
fdo#78980 i#98931 Accept args for .uno:InsertAnnotation
It will be available in 4.4.0.
The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
Affected users are encouraged to test the fix and report feedback.
(In reply to Commit Notification from comment #7)
> It will be available in 4.4.0.
The bot meant 4.5.0. The commit will be available in 4.4 when pushed to libreoffice-4-4, which has been created a few hours ago.
I pushed it to 4-4 as well.
BTW that's not the preferable way to add comments from a macro. You should try using insertTextContent with css::text::textfield::Annotation instead. Example macro here:
This should work even without my patch.
Let's mark it as FIXED. I'll backport the patch to 4-3 later.
i never said thank you for this! it's much appreciated.