Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-11 Thread Ennio-Sr
* Ennio-Sr [EMAIL PROTECTED] [110605, 00:56]:
 * Ennio-Sr [EMAIL PROTECTED] [100605, 19:47]:
  * Laurent Godard [EMAIL PROTECTED] [100605, 18:21]:
   Hi again
   
   i am totally wrong sorry
  It's me to be sorry for not being able to figure out what this means ;)
   
   subRegExpressions
   [...]
 
 Hi Laurent,
 
 no matter what that IDL description might mean, Paolo's code with your
 integration, once you substitute [:alnum:]+ for [:digit:]+ and
 separate the items to be searched with a '\',e.g:
 this \will \be \found \in \Paolo \test \text \333 \654\]
 works very smoothly :-)))
 
 Now, the only missing feature is an inter-active dialog box where to put
 the string(s) to be searched for: Paolo ... ?
 
 Thanks again to both of you,
   Ennio.

Again me (hoping not to be talking to myself... ;-)

I found the way to use sStrToSearch = inputBox( .) and while
testing with many other strings I realized the reverse strokes '\' don't
seem to be necessary, although I canot tell why I reported this
impression during my first attempts ;(.

A further step would seem to be the capability to replace the found items
with new ones ? (But I have no idea where to start looking for ...)

Lonely yours, ;)
Ennio

-- 
[Perche' usare Win$ozz (dico io) se ...anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!  (diceva Henry Miller) ](°|°)
[Why use Win$ozz (I say) if ... even a fool can do that.  )=(
 Do something you aren't good at! (as Henry Miller used to say) ]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-11 Thread Ennio-Sr
* Ennio-Sr [EMAIL PROTECTED] [110605, 00:56]:
 * Ennio-Sr [EMAIL PROTECTED] [100605, 19:47]:
  * Laurent Godard [EMAIL PROTECTED] [100605, 18:21]:
   Hi again
   
   i am totally wrong sorry
  It's me to be sorry for not being able to figure out what this means ;)
   
   subRegExpressions
   [...]
 
Hi Laurent (and Paolo),
When I wrote (a couple of hours ago):

- quote -
Again me (hoping not to be talking to myself... ;-)

I found the way to use sStrToSearch = inputBox( .) and while
testing with many other strings I realized the reverse strokes '\' don't
seem to be necessary, although I canot tell why I reported this
impression during my first attempts ;(.

A further step would seem to be the capability to replace the found items
with new ones ? (But I have no idea where to start looking for ...)

- unquote -

I spoke too early ... ;(
Pieces of the search string are being regularly shown in the MsgBox, but
that happens for any kind of string, even if it doesn't exist in the
file being searched !

So it seems to be behaving as if :

 while aSearchResult.subRegExpressions  0 

were always 'true' ...

Doubtfully yours, ;)
Ennio


-- 
[Perche' usare Win$ozz (dico io) se ...anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!  (diceva Henry Miller) ](°|°)
[Why use Win$ozz (I say) if ... even a fool can do that.  )=(
 Do something you aren't good at! (as Henry Miller used to say) ]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-10 Thread Laurent Godard

Hi paolo,

interresting game :)



At the end of this post there's my testing code
am I doing something wrong ?
Perhaps I missed some SearchFlags ?



please find a working modification of your code at the end

in fact you have to loop aver oTextSerach, by starting after the 
endOfset of your previous result
oTextSearch.searchForward(sStrToSearch, 
aSearchResult.endOffset(rank)+1,Len(sStrToSearch)-1 )


until you have no more result given by
while aSearchResult.subRegExpressions  0

Please verify this as i didn't take time to verify all things

HTH

Laurent

'--
Sub Main

oTextSearch = CreateUnoService(com.sun.star.util.TextSearch)

Dim aSrcOpt As New com.sun.star.util.SearchOptions
With aSrcOpt
.searchFlag = com.sun.star.util.SearchFlags.REG_EXTENDED
.algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
.searchString = [:digit:]+
End With

oTextSearch.setOptions(aSrcOpt)
	sStrToSearch = 1 sometext 33 othertext and an other 1 followed by 11 
and 654
	aSearchResult = oTextSearch.searchForward(sStrToSearch, 
0,Len(sStrToSearch)-1 )


while aSearchResult.subRegExpressions  0
rank = aSearchResult.subRegExpressions - 1
iMatchStartPos = aSearchResult.startOffset(rank) + 1
			iMatchLen = aSearchResult.endOffset(rank) - 
aSearchResult.startOffset(rank)

sMatchString = Mid(sStrToSearch, iMatchStartPos, 
iMatchLen)
MsgBox sMatchString 
			aSearchResult = oTextSearch.searchForward(sStrToSearch, 
aSearchResult.endOffset(rank)+1,Len(sStrToSearch)-1 )		

wend

End Sub


--
Laurent Godard [EMAIL PROTECTED] - Ingénierie OpenOffice.org
Indesko  http://www.indesko.com
Nuxeo CPS  http://www.nuxeo.com - http://www.cps-project.org
Livre Programmation OpenOffice.org, Eyrolles 2004


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-10 Thread Ennio-Sr
* Laurent Godard [EMAIL PROTECTED] [100605, 15:15]:
 Hi paolo,
 
 interresting game :)
 
 
 At the end of this post there's my testing code
 am I doing something wrong ?
 Perhaps I missed some SearchFlags ?
 
 
 please find a working modification of your code at the end
 
 in fact you have to loop aver oTextSerach, by starting after the 
 endOfset of your previous result
 oTextSearch.searchForward(sStrToSearch, 
 aSearchResult.endOffset(rank)+1,Len(sStrToSearch)-1 )
 
 until you have no more result given by
 while aSearchResult.subRegExpressions  0
 
 Please verify this as i didn't take time to verify all things
 
 HTH
 
 Laurent
 

Hi Laurent,
I've been playing with Paolo's code for a while (just to try to
understand a bit more how things work). The best I could envisage
when I realized the loop was missing was a Goto label ... :-)

With your modification the game goes over, giving the various substrings
as (apparently) they are found (i.e. the aSearchResult.subRegExpressions is 
0). Of course (?) having set .searchString = [:digit:]+ in the
SearchOptions it finds digits only. I tried [:alpha:]+ [:digit:]+ and
seemed to work for both numbers and letters, although not all items were
'found'.

While Paolo will give the final answer to this respect as he knows
exactly what is trying to achieve, I'm curious to know whether the IDL
statement that the subRegExpressions value can be greater than 1 is
correct at all. It seems to be a boolean value, or am I far behind any
acceptable understanding of what I read?

Thanks for your attention.
Regards,
Ennio.

-- 
[Perche' usare Win$ozz (dico io) se ...anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!  (diceva Henry Miller) ](°|°)
[Why use Win$ozz (I say) if ... even a fool can do that.  )=(
 Do something you aren't good at! (as Henry Miller used to say) ]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-10 Thread Laurent Godard

Hi ennio,



While Paolo will give the final answer to this respect as he knows
exactly what is trying to achieve, I'm curious to know whether the IDL
statement that the subRegExpressions value can be greater than 1 is
correct at all. It seems to be a boolean value, or am I far behind any
acceptable understanding of what I read?


sorry, i didn't have time to read the IDL
i think subRegExpressions is the dimension/number of elements of the 
arrays endOffset and startOffset

but it is only a guess
if it is that, you will have to loop over them to retrive all the results

i will read the IDL as may be totally wrong

Laurent


--
Laurent Godard [EMAIL PROTECTED] - Ingénierie OpenOffice.org
Indesko  http://www.indesko.com
Nuxeo CPS  http://www.nuxeo.com - http://www.cps-project.org
Livre Programmation OpenOffice.org, Eyrolles 2004


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-10 Thread Laurent Godard

Hi again


i will read the IDL as may be totally wrong



i am totally wrong sorry

subRegExpressions
Number of subexpressions, if it is 0, then no match found; this value 
is 1 for ABSOLUTE and APPROXIMATE match. The start and endOffset are 
always dependent on the search direction. For example: if you search X 
in the text -X- the offset are: for forward: start = 1, end = 2 for 
backward: start = 2, end = 1 Forward, the startOffset is inclusive, the 
endOffset exclusive. Backward, the startOffset is exclusive, the 
endOffset inclusive. For regular expressions it can be greater than 1. 
If the value is 1, startoffset[0] and endoffset[0] points to the 
matching sub string if value is  1, still startoffset[0] and 
endoffset[0] points to the matching substring for whole regular 
expression startoffset[i] and endoffset[i] points to the matching 
substring of i th matching substring.


sorry

Laurent

--
Laurent Godard [EMAIL PROTECTED] - Ingénierie OpenOffice.org
Indesko  http://www.indesko.com
Nuxeo CPS  http://www.nuxeo.com - http://www.cps-project.org
Livre Programmation OpenOffice.org, Eyrolles 2004


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-10 Thread Ennio-Sr
* Ennio-Sr [EMAIL PROTECTED] [100605, 19:47]:
 * Laurent Godard [EMAIL PROTECTED] [100605, 18:21]:
  Hi again
  
  i am totally wrong sorry
 It's me to be sorry for not being able to figure out what this means ;)
  
  subRegExpressions
  [...]

Hi Laurent,

no matter what that IDL description might mean, Paolo's code with your
integration, once you substitute [:alnum:]+ for [:digit:]+ and
separate the items to be searched with a '\',e.g:
this \will \be \found \in \Paolo \test \text \333 \654\]
works very smoothly :-)))

Now, the only missing feature is an inter-active dialog box where to put
the string(s) to be searched for: Paolo ... ?

Thanks again to both of you,
Ennio.

-- 
[Perche' usare Win$ozz (dico io) se ...anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!  (diceva Henry Miller) ](°|°)
[Why use Win$ozz (I say) if ... even a fool can do that.  )=(
 Do something you aren't good at! (as Henry Miller used to say) ]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-09 Thread Ennio-Sr
* Paolo Mantovani [EMAIL PROTECTED] [090605, 18:17]:
 Hi all,
 
 The method XTextSearch.searchForward results an
 com.sun.star.util.SearchResult structure
 
 http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchResult.html
 
 As you can see, IDL documentation says that setting the searchAlgorithm to 
 REGEXP I can find multiple sub matches but, in my tests I'm obtaining ever 
 and only the first one
 
 At the end of this post there's my testing code
 am I doing something wrong ?
 Perhaps I missed some SearchFlags ?
 
 
 Thanks in advance for any help
 Paolo M.
 
Hi Paolo,
I'm the least apt to give any help on this list ... however you might
have missed the fact that both
LBound(aSearchResult.startOffset()) # and
UBound(aSearchResult.startOffset())
evaluate to 0 and all subsequent values are 1!
HTH, although I'm not sure I correctly interpreted your macro.
Ciao,
Ennio

-- 
[Perche' usare Win$ozz (dico io) se ...anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!  (diceva Henry Miller) ](°|°)
[Why use Win$ozz (I say) if ... even a fool can do that.  )=(
 Do something you aren't good at! (as Henry Miller used to say) ]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-09 Thread Paolo Mantovani
Hi all,

me again :-)
after a second reading of the IDL documentation, I realized that probably, 
I've initially misunderstood the real meaning.

Anyway the intersting (but problematic) part of the document says:

struct SearchResult




Alle 18:17, giovedì 9 giugno 2005, Paolo Mantovani ha scritto:
 Hi all,

 The method XTextSearch.searchForward results an
 com.sun.star.util.SearchResult structure

 http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchResult.ht
ml

 As you can see, IDL documentation says that setting the searchAlgorithm to
 REGEXP I can find multiple sub matches but, in my tests I'm obtaining ever
 and only the first one

 At the end of this post there's my testing code
 am I doing something wrong ?
 Perhaps I missed some SearchFlags ?


 Thanks in advance for any help
 Paolo M.


 REM  *  BASIC  *

 Sub Main

 oTextSearch = CreateUnoService(com.sun.star.util.TextSearch)

   Dim aSrcOpt As New com.sun.star.util.SearchOptions
   With aSrcOpt
   .searchFlag = com.sun.star.util.SearchFlags.REG_EXTENDED
   .algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP
   .searchString = [:digit:]+
   End With

   oTextSearch.setOptions(aSrcOpt)
   sStrToSearch = 1 sometext 33 othertext 654
   aSearchResult = oTextSearch.searchForward(sStrToSearch,
 0,Len(sStrToSearch)-1 )

   If aSearchResult.subRegExpressions  0 Then
   For I = LBound(aSearchResult.startOffset()) To
 UBound(aSearchResult.startOffset())

   iMatchStartPos = aSearchResult.startOffset(I) + 1
   iMatchLen = aSearchResult.endOffset(I) - 
 aSearchResult.startOffset(I)
   sMatchString = Mid(sStrToSearch, iMatchStartPos, 
 iMatchLen)

   MsgBox sMatchString

   Next I
   End If

 End Sub

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [api-dev] service com.sun.star.util.TextSearch

2005-06-09 Thread Paolo Mantovani
sorry for the previous post, I accidentally pressed something in my 
keyboard


Hi all,

me again :-)
after a second reading of the IDL documentation, I realized that probably, 
I've initially misunderstood the point

Anyway the intersting (but problematic) part of the document says:

--
struct com.sun.star.util.SearchResult

  subRegExpressions

[omissis...] For regular expressions it can be greater than 1. If the 
value is 1, startoffset[0] and endoffset[0] points to the matching sub string 
if value is  1, still startoffset[0] and endoffset[0] points to the matching 
substring for whole regular expression startoffset[i] and endoffset[i] points 
to the matching substring of i th matching substring. 
--


I tried to define substrings in the search string using parenthesis, f.e.:

searchString = (so).*(xt)
textToSearch = some text

but the subRegExpressions value is always 1

how should I specify the search string in order to obtain a 
subRegExpressions  1 ?


thanks 
Paolo


Alle 18:17, giovedì 9 giugno 2005, Paolo Mantovani ha scritto:
 Hi all,

 The method XTextSearch.searchForward results an
 com.sun.star.util.SearchResult structure

 http://api.openoffice.org/docs/common/ref/com/sun/star/util/SearchResult.ht
ml

 As you can see, IDL documentation says that setting the searchAlgorithm to
 REGEXP I can find multiple sub matches but, in my tests I'm obtaining ever
 and only the first one

 At the end of this post there's my testing code
 am I doing something wrong ?
 Perhaps I missed some SearchFlags ?


 Thanks in advance for any help
 Paolo M.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]