Date: prev next · Thread: first prev next last
2019 Archives by date, by thread · List index



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: users+unsubscribe@global.libreoffice.org
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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.