Function FindR2(P as String)
Dim Doc, Found
Dim Font As String
Doc = StarDesktop.CurrentComponent
Dim SearchDesc As Object
SearchDesc = Doc.createSearchDescriptor()
SearchDesc.SearchRegularExpression = TRUE
SearchDesc.searchString = P
Found = Doc.findFirst(SearchDesc)
Font = Found.CharFontName
MsgBox(Font)
end function 'FindR2
Harvey (harveyab)
OOo 3.3.0 on MS Windows XP --- Time drags so quickly.
The API's search descriptor (as documented) can search by style names rather than single attributes. You may iterate over TextPortions, which are documented as
A TextPortion is a piece of text within a paragraph that does not contain changes of its attributes inside.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
So are you saying that I will have to write a search algorithm in order to do the iteration rather than just calling the FindFirst() function?
The example you gave a link to is in C, and I am using BASIC.
I tried converting it to BASIC but no success.
OR
are you saying that I can specify the criteria for the font and still use the FindFirst call?
Sorry for being slow to understand.
Harvey
Harvey (harveyab)
OOo 3.3.0 on MS Windows XP --- Time drags so quickly.
I refered to the API documentation of service "com.sun.star.text.TextPortion". The office-API is language independent. In any supported language you can loop through parargraphs and TextPortions in order to get the smallest sequences of equally formatted text, then check if the respective portion has this or that property and then do whatever with it.
There are several resources about how to program with this API (if you already know how to program) by means of script languages Basic, Python, JavaBeans, Windows COM and compiled languages Java and C++. There are some differences how you call methods from a compiled language. Most examples are documented for Java since it is easier to transfer from Java to a script language than it would be the other way round. http://www.pitonyak.org/oo.php http://wiki.services.openoffice.org/wiki/Main_Page http://sourceforge.net/project/showfile ... _id=101416XRay, the indispensable helper for Basic coders
Local copy of the API-reference. Best used with XRay: http://download.openoffice.org/2.4.0/sdk.html http://download.openoffice.org/3.0/sdk.html
No, it's not like VBA
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Since 2.4.1 is a bug-fix release of 2.4, you can expect equal APIs between 2.4 and 2.4.1. The latter fixes things that should have worked in 2.4 already. You may even use an older SDK without beeing able to lookup the API for the latest features added between the older SDK-version and the one you are programming for. With Basic + XRay you need the SDK to look up the right html files in the SDK's documentation tree. If you are programming with 3.0 and there is no SDK for 3.0 yet, this might be no problem as long as you stay hacking on the usual document features which did not change since version 1, such as paragraphs and portions of equally formatted text. I'm not shure about v3 though, since I ignore v3 until today.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice