Jim,

That was it!  Or, almost.  I changed the line to:

 oText.insertTextContent(oVC, oAnno, True)
>

And the annotation now gets attached to the whole range.

I wish I knew how to find the documentation for these functions!  I don't
know what the various parameters actually d -- what is the final Boolean
doing there?  How do you know?

But in any case, many thanks for solving htis problem, it's actually pretty
awesome to be able to do this with a single keystroke!

m



On Wed, Nov 19, 2014 at 12:38 PM, Jim Byrnes <[email protected]> wrote:

> On 11/19/2014 10:55 AM, Matt Price wrote:
>
>> Thanks Tom,
>>
>> I've just spent some time looking htrough Andrew Pitonyak's macro guide.
>> It helps a little but there doesn't seem to be any direct documentation of
>> hte functions.  What I'm looking at is the second line reproduced below:
>>
>>      oVC = ThisComponent.CurrentController.ViewCursor
>>      oText.insertTextContent(oVC.Start, oAnno, False)
>>
>
> Matt,
> I don't use Writer much and honestly I'm not sure what you expect to see.
> Try this.  In the above two lines change Start to End and False to True and
> put those two lines right under your "rem I don't know what to put in here"
> line. Then select some text and run the macro.
>
> Regards,  Jim
>
>
>  I think oVC.Start needs to be replaced with something else, but I can't
>> figure out what.  All of Andrew's examples with insertTextContent insert
>> the content at a single location, not at a text range, so maybe I need a
>> different function. If someone knows another method I'd appreciate the
>> advice.
>>
>> Thanks,
>> Matt
>>
>> On Wed, Nov 19, 2014 at 11:15 AM, Tom Davies <[email protected]> wrote:
>>
>>  Hi :)
>>> The best documentation is at;
>>> https://wiki.documentfoundation.org/Documentation/Publications
>>> and the most recent full books are also on the official LibreOffice
>>> website.
>>>
>>> For macros i think the best book by far is Andrew Pitonyak's guide on
>>>
>>> https://wiki.documentfoundation.org/Documentation/Other_
>>> Documentation_and_Resources#Programmers
>>>
>>> I'm not sure they will help for this specific use-case but they might
>>> help
>>> generally.
>>> Regards from
>>> Tom :)
>>>
>>>
>>>
>>> On 19 November 2014 16:05, Matt Price <[email protected]> wrote:
>>>
>>>  Hi,
>>>>
>>>> I am trying to add a really simple macro that I can bind to a key.  I
>>>> just
>>>> want ot be able ot add checkmarks to student papers veyr quickly, so I
>>>> would like to select a sentence or other text range, then press a key,
>>>> and
>>>> have the ckeckmark appear in a new comment.
>>>>
>>>> I can almost do htis, using code stolen from the web:
>>>>
>>>> rem-------------------------------------------
>>>> rem -- misleadingly named macro adds a simple hceckmark at point, or in
>>>> response to highlighted text.
>>>> sub createComment
>>>>      rem create the annotation object
>>>>      oAnno =
>>>> ThisComponent.createInstance("com.sun.star.text.textfield.Annotation")
>>>>      rem Chr 10004 is the decimal for hex code 2714, "heavy checkmark"
>>>>      oAnno.Content = Chr(10004)
>>>>      oAnno.Author = "Matt Price"
>>>>      oText = ThisComponent.Text
>>>>      rem check to see if anything is selected
>>>>      oSels = ThisComponent.getCurrentSelection()
>>>>      If Not IsNull(oSels) Then
>>>>          rem I don't know what to put in here
>>>>      Else
>>>>          oVC = ThisComponent.CurrentController.ViewCursor
>>>>          oText.insertTextContent(oVC.Start, oAnno, False)
>>>>      End If
>>>> end sub
>>>>
>>>> -----------------------
>>>>
>>>> You can see that, if there's no selection, I already know how to insert
>>>> the
>>>> annotation.  But I don't know how to attach the annotation to the
>>>> selected
>>>> range instead of just the start of the cursor.
>>>>
>>>> In general, I don't know where to find the funciton references or even
>>>> the
>>>> source code for the relevant functions.  I'm finding it quite difficult
>>>> to
>>>> figure out how to learn to program -- is there comprehensive
>>>> documentation
>>>> somewhere?
>>>>
>>>> Thanks,
>>>>
>>>> Matt
>>>>
>>>> --
>>>> To unsubscribe e-mail to: [email protected]
>>>> Problems?
>>>> http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>>>> Posting guidelines + more: http://wiki.documentfoundation.org/
>>>> Netiquette
>>>> List archive: http://listarchives.libreoffice.org/global/users/
>>>> All messages sent to this list will be publicly archived and cannot be
>>>> deleted
>>>>
>>>>
>>>
>>>
>>
>
>
> --
> To unsubscribe e-mail to: [email protected]
> Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-
> unsubscribe/
> Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
> List archive: http://listarchives.libreoffice.org/global/users/
> All messages sent to this list will be publicly archived and cannot be
> deleted
>

-- 
To unsubscribe e-mail to: [email protected]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Reply via email to