https://bugs.documentfoundation.org/show_bug.cgi?id=173518

--- Comment #2 from Jim Vallino <[email protected]> ---
IsEmpty does return True when testing the attribute. To not generate an error,
it will require a switch in the order of operations. I believe that a typical
programming idiom would have you use:

    Fetch the selection collection
    Test if it has what you want

When you fetch using the accessor function like:

    oSelection = ThisComponent.getCurrentSelection()
    if IsNull(oSelection) Then
        -- handle no shape selected
    End If

no error is generated. If you fetch with the attribute:

    oSelection = ThisComponent.CurrentController.Selection
    If IsEmpty(oSelection) Then
        -- handle no shape selected

an error will be generated. To prevent that, you either have to test the
attribute first before doing the assignment or surround the statements with an
error trap.

I think that the method for accessing the value should not determine the order
of the operations and the actual test to be done. At least, that is my opinion
on it.

Is this a standard difference between using attributes and accessor functions
that I should expect and program for? This probably could be avoided if at
object creation time the selection attribute is initialized to Null.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to