Do not unconditionally throw NoSuchElementException

...this fixes 1a9463277006e8e5a8c0b82bbf5d5ab2d5ea15ac "coverity#704274
Logically dead code" and JunitTest_sc_unoapi.

Change-Id: I20fc5262d6198fca1c7dfc970a7f8664c325aa91