Bug selecting text using the API

classic Classic list List threaded Threaded
6 messages Options
Andrew Douglas Pitonyak Andrew Douglas Pitonyak
Reply | Threaded
Open this post in threaded view
|

Bug selecting text using the API


Tested using LO 6.2.0.3 on Fedora Linux.

I wanted to find all instances of Italic text using the API and select
that text. I created a simple document with four areas that were Italic.
I used the following macro and, although FindAll does return all italic
text, it only selects the last three instances and not the first one.


My example had two instances in normal text and two instances in a text
table.

If I have more than once instance, it ignores the first. If I have ONLY
one instance of Italic text, it will select the text.


Sub FindItalic_all
   Dim oDescriptor  'The search descriptor
   Dim oFound       'The found range
   Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue

   SrchAttributes(0).Name = "CharPosture"
   SrchAttributes(0).Value =  com.sun.star.awt.FontSlant.ITALIC
'  SrchAttributes(0).Name = "CharFontName"
'  SrchAttributes(0).Value =  "Comic Sans MS"

   oDescriptor = ThisComponent.createSearchDescriptor()
   oDescriptor.SetSearchAttributes(SrchAttributes)

   oFound = ThisComponent.findAll(oDescriptor)

'  Dim i As Integer
'  for i = 0 To oFound.Count - 1
'    Print oFound.getByIndex(i).getString(i)
'  Next
   Thiscomponent.getCurrentController.select(oFound)
End Sub





--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php


--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Mauricio Baeza-4 Mauricio Baeza-4
Reply | Threaded
Open this post in threaded view
|

Re: Bug selecting text using the API

On Sun, 20 Oct 2019 21:07:26 -0400, Andrew Douglas Pitonyak <[hidden email]> wrote:

>
> Tested using LO 6.2.0.3 on Fedora Linux.
>
> I wanted to find all instances of Italic text using the API and select
> that text. I created a simple document with four areas that were Italic.
> I used the following macro and, although FindAll does return all italic
> text, it only selects the last three instances and not the first one.
>
>
> My example had two instances in normal text and two instances in a text
> table.
>
> If I have more than once instance, it ignores the first. If I have ONLY
> one instance of Italic text, it will select the text.
>
>
> Sub FindItalic_all
>    Dim oDescriptor  'The search descriptor
>    Dim oFound       'The found range
>    Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
>
>    SrchAttributes(0).Name = "CharPosture"
>    SrchAttributes(0).Value =  com.sun.star.awt.FontSlant.ITALIC
> '  SrchAttributes(0).Name = "CharFontName"
> '  SrchAttributes(0).Value =  "Comic Sans MS"
>
>    oDescriptor = ThisComponent.createSearchDescriptor()
>    oDescriptor.SetSearchAttributes(SrchAttributes)
>
>    oFound = ThisComponent.findAll(oDescriptor)
>
> '  Dim i As Integer
> '  for i = 0 To oFound.Count - 1
> '    Print oFound.getByIndex(i).getString(i)
> '  Next
>    Thiscomponent.getCurrentController.select(oFound)
> End Sub
>


Hi...

Can you share your document?

Best regards

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Mauricio Baeza-4 Mauricio Baeza-4
Reply | Threaded
Open this post in threaded view
|

Re: Bug selecting text using the API

In reply to this post by Andrew Douglas Pitonyak
On Sun, 20 Oct 2019 21:07:26 -0400, Andrew Douglas Pitonyak <[hidden email]> wrote:

>
> Tested using LO 6.2.0.3 on Fedora Linux.
>
> I wanted to find all instances of Italic text using the API and select
> that text. I created a simple document with four areas that were Italic.
> I used the following macro and, although FindAll does return all italic
> text, it only selects the last three instances and not the first one.
>
>
> My example had two instances in normal text and two instances in a text
> table.
>
> If I have more than once instance, it ignores the first. If I have ONLY
> one instance of Italic text, it will select the text.
>
>
> Sub FindItalic_all
>    Dim oDescriptor  'The search descriptor
>    Dim oFound       'The found range
>    Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
>
>    SrchAttributes(0).Name = "CharPosture"
>    SrchAttributes(0).Value =  com.sun.star.awt.FontSlant.ITALIC
> '  SrchAttributes(0).Name = "CharFontName"
> '  SrchAttributes(0).Value =  "Comic Sans MS"
>
>    oDescriptor = ThisComponent.createSearchDescriptor()
>    oDescriptor.SetSearchAttributes(SrchAttributes)
>
>    oFound = ThisComponent.findAll(oDescriptor)
>
> '  Dim i As Integer
> '  for i = 0 To oFound.Count - 1
> '    Print oFound.getByIndex(i).getString(i)
> '  Next
>    Thiscomponent.getCurrentController.select(oFound)
> End Sub
>


I confirm the same bug, with Python:

    from com.sun.star.beans import PropertyValue
    from com.sun.star.awt.FontSlant import ITALIC

    doc = XSCRIPTCONTEXT.getDocument()

    opt = (PropertyValue(Name='CharPosture', Value=ITALIC),)
    descriptor = doc.createSearchDescriptor()
    descriptor.setSearchAttributes(opt)

    found = doc.findAll(descriptor)
    doc.CurrentController.select(found)

Always select len(found) - 1

I search if bug is reported, but not found any.


Best regards
--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Andrew Douglas Pitonyak Andrew Douglas Pitonyak
Reply | Threaded
Open this post in threaded view
|

Re: Bug selecting text using the API

Thanks for testing. We now have three instances where this fails.

If you still want the document I can send it, but, I think that the list strips attachments I would need to send it to you directly

⁣Sent from BlueMail ​

On Oct 20, 2019, 11:00 PM, at 11:00 PM, Mauricio Baeza <[hidden email]> wrote:

>On Sun, 20 Oct 2019 21:07:26 -0400, Andrew Douglas Pitonyak
><[hidden email]> wrote:
>
>>
>> Tested using LO 6.2.0.3 on Fedora Linux.
>>
>> I wanted to find all instances of Italic text using the API and
>select
>> that text. I created a simple document with four areas that were
>Italic.
>> I used the following macro and, although FindAll does return all
>italic
>> text, it only selects the last three instances and not the first one.
>>
>>
>> My example had two instances in normal text and two instances in a
>text
>> table.
>>
>> If I have more than once instance, it ignores the first. If I have
>ONLY
>> one instance of Italic text, it will select the text.
>>
>>
>> Sub FindItalic_all
>>    Dim oDescriptor  'The search descriptor
>>    Dim oFound       'The found range
>>    Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue
>>
>>    SrchAttributes(0).Name = "CharPosture"
>>    SrchAttributes(0).Value =  com.sun.star.awt.FontSlant.ITALIC
>> '  SrchAttributes(0).Name = "CharFontName"
>> '  SrchAttributes(0).Value =  "Comic Sans MS"
>>
>>    oDescriptor = ThisComponent.createSearchDescriptor()
>>    oDescriptor.SetSearchAttributes(SrchAttributes)
>>
>>    oFound = ThisComponent.findAll(oDescriptor)
>>
>> '  Dim i As Integer
>> '  for i = 0 To oFound.Count - 1
>> '    Print oFound.getByIndex(i).getString(i)
>> '  Next
>>    Thiscomponent.getCurrentController.select(oFound)
>> End Sub
>>
>
>
>I confirm the same bug, with Python:
>
>    from com.sun.star.beans import PropertyValue
>    from com.sun.star.awt.FontSlant import ITALIC
>
>    doc = XSCRIPTCONTEXT.getDocument()
>
>    opt = (PropertyValue(Name='CharPosture', Value=ITALIC),)
>    descriptor = doc.createSearchDescriptor()
>    descriptor.setSearchAttributes(opt)
>
>    found = doc.findAll(descriptor)
>    doc.CurrentController.select(found)
>
>Always select len(found) - 1
>
>I search if bug is reported, but not found any.
>
>
>Best regards
>--
>To unsubscribe e-mail to: [hidden email]
>Problems?
>https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>Posting guidelines + more:
>https://wiki.documentfoundation.org/Netiquette
>List archive: https://listarchives.libreoffice.org/global/users/
>Privacy Policy: https://www.documentfoundation.org/privacy

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Mauricio Baeza-4 Mauricio Baeza-4
Reply | Threaded
Open this post in threaded view
|

Re: Bug selecting text using the API

On Sun, 20 Oct 2019 23:41:50 -0400, Andrew Pitonyak <[hidden email]> wrote:

> Thanks for testing. We now have three instances where this fails.
>
> If you still want the document I can send it, but, I think that the list strips attachments I would need to send it to you directly
>


It's ok... You or I report this?

Best regards
--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Andrew Douglas Pitonyak Andrew Douglas Pitonyak
Reply | Threaded
Open this post in threaded view
|

Re: Bug selecting text using the API

Can you report this? If not I will do so

⁣Sent from BlueMail ​

On Oct 21, 2019, 12:00 AM, at 12:00 AM, Mauricio Baeza <[hidden email]> wrote:

>On Sun, 20 Oct 2019 23:41:50 -0400, Andrew Pitonyak
><[hidden email]> wrote:
>
>> Thanks for testing. We now have three instances where this fails.
>>
>> If you still want the document I can send it, but, I think that the
>list strips attachments I would need to send it to you directly
>>
>
>
>It's ok... You or I report this?
>
>Best regards
>--
>To unsubscribe e-mail to: [hidden email]
>Problems?
>https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
>Posting guidelines + more:
>https://wiki.documentfoundation.org/Netiquette
>List archive: https://listarchives.libreoffice.org/global/users/
>Privacy Policy: https://www.documentfoundation.org/privacy

--
To unsubscribe e-mail to: [hidden email]
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy