[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libreoffice-users] Experimental macro features: How to determine object types?


Den tis 22 okt. 2019 kl 09:00 skrev Stephan Bergmann <sbergman@redhat.com>:

> On 21/10/2019 21:43, Johnny Rosenberg wrote:
> > Den mån 21 okt. 2019 kl 12:53 skrev Stephan Bergmann <
> sbergman@redhat.com>:
> >> On 18/10/2019 20:16, Johnny Rosenberg wrote:
> >>> *Private Function ItemFound(sItem As string, _ oRange As
> >>> com.sun.star.sheet.XSheetCellRange) As Boolean Dim oDescriptor As
> >>> com.sun.star.util.XReplaceDescriptor
> >>> oDescriptor=oRange.createSearchDescriptor()*
> >>> *⁝*
> >>> *⁝*
> >>> *End Function*
> >>>
> >>> So the answer to my question seems to be
> >>> ”com.sun.star.util.XReplaceDescriptor”. Exactly why is a little blurry
> to
> >>> me at the moment.
> >>
> >> css.util.XReplaceDescriptor is derived from css.util.XSearchDescriptor.
> >> I assume that what dim'ing you need should depend on what you do with
> >> oDescriptor in the part you elided: If you only call
> >> XSearchDescriptor-methods on it, then dim as XSearchDescriptor should
> >> suffice. If you call any of the XReplaceDescriptor-only methods
> >> (getting/setting the ReplaceString), then you need to dim as
> >> XReplaceDescriptor.
> >>
> > But in that case, why did the error message happen at the
> > ”oDescriptor=oRange.createSearchDescriptor()” line? I hadn't started to
> use
> > it yet…
>
> So what /is/ the exact error message?
>
> That's strange. I was convinced that I already said that, but I can't find
it in the thread, so maybe I just didn't.

The exact message is:
”Object not accessible.
Invalid use of an object.”

If I change the Dim statement from ”Dim oDescriptor As
com.sun.star.util.XSearchDescriptor” to ”Dim oDescriptor As
com.sun.star.util.XReplaceDescriptor”, the error message doesn't appear and
everything seems to work.

Example code for testing this:





*Sub Test Dim oRange As com.sun.star.sheet.XSheetCellRange
oRange=ThisComponent.getSheets().getByIndex(0).getCellRangeByPosition(0,0,10,10)
Dim oDescriptor As com.sun.star.util.XSearchDescriptor
oDescriptor=oRange.createSearchDescriptor() ' Gives an error message.End
Sub*






*Sub Test Dim oRange As com.sun.star.sheet.XSheetCellRange
oRange=ThisComponent.getSheets().getByIndex(0).getCellRangeByPosition(0,0,10,10)
Dim oDescriptor As com.sun.star.util.XReplaceDescriptor
oDescriptor=oRange.createSearchDescriptor() ' Works fine.End Sub*

I just think it's a little funny: I want to create a search descriptor, but
”declaring” it as such doesn't work, I need to ”declare” it as a replace
descriptor. It's a little hard to take those things in. :)


Kind regards

Johnny Rosenberg

--
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

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.