Bug 78980 - BASIC: Dispatcher .uno:InsertAnnotation wont accept args()
Summary: BASIC: Dispatcher .uno:InsertAnnotation wont accept args()
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: Other All
: medium normal
Assignee: Maxim Monastirsky
URL:
Whiteboard: BSA target:4.5.0 target:4.4.0 target:...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-20 17:47 UTC by gastermd
Modified: 2014-12-10 01:53 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gastermd 2014-05-20 17:47:56 UTC
Problem description:
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. 


Sample Code:

sub Macro1
   Dim document   as object
   Dim dispatcher as object
   Dim oct1
   
   
   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())
end Sub

Current behavior:
Creates empty comment with focus, as if I had just inserted a comment.

Expected behavior:
It should create a full comment with provided arguments.

              
Operating System: Windows 7
Version: 4.2.4.2 release
Comment 1 Laurent Godard 2014-05-21 06:52:04 UTC
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
Comment 2 gastermd 2014-05-21 13:31:53 UTC
(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

Hi Laurent,

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?

Thanks again.
Comment 3 Buovjaga 2014-11-02 14:14:02 UTC
Yep, on Windows it creates an empty comment.

Win 7 64-bit Version: 4.4.0.0.alpha1+
Build ID: 1baad070d8c2a38581cf33d803c5043f1974647f
TinderBox: Win-x86@39, Branch:master, Time: 2014-11-01_00:15:06
Comment 4 Matt Price 2014-11-19 16:19:19 UTC
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 4.3.3.2 on Arch Linux.
Comment 5 Maxim Monastirsky 2014-11-19 21:36:18 UTC
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.
Comment 6 Matt Price 2014-11-19 21:55:34 UTC
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.
Comment 7 Commit Notification 2014-11-21 00:00:07 UTC
Maxim Monastirsky committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=917c52f3219149741199015fce1740c5b13d814e

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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Matt Price 2014-11-21 00:28:50 UTC
Thanks Maxim!
Comment 9 Adolfo Jayme Barrientos 2014-11-21 00:41:30 UTC
(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.
Comment 10 Maxim Monastirsky 2014-11-21 12:05:45 UTC
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:

https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=66952#p297888

See also:
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Fields
http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1text_1_1textfield_1_1Annotation.html

This should work even without my patch.
Comment 11 Maxim Monastirsky 2014-11-22 17:15:46 UTC
Let's mark it as FIXED. I'll backport the patch to 4-3 later.
Comment 12 Matt Price 2014-12-10 01:53:23 UTC
i never said thank you for this!  it's much appreciated.