Test for a TABLE in Writer Macro <Abandonded>

As a tidy up of code from previous questions, for which I have received superb support. In tidying up the code and testing, I find that if a document contains a text box table I get the following error

1:An exception occurred
Type: com.sun.star.lang,IllegalArgumentException
Message: cannot coerce argument type during coreflection call:
arg no.: 0 expected: "com.sun.star.text.XTextRange" actual:
"com.sun.star.text.XTextContent" ./stoc/source/coreflection/
criface.cxx:652
Line: 729"

Without the text box table, code works as intended and line 729 is

	oCur=oDoc.Text.createTextCursorByRange(oEnum.nextElement) 'current paragraph as cursor'

Which works within a loop detecting line styles and executes code accordingly, until it hits the text box.
oCur.ParaStyleName which is part of the following code does not seem to show text boxes tables, so what can I use to test for them?
All I need do is test for that text box table and skip the code that follows,

EDIT: I’m an idiot, NOT a Text box but a TABLE!!!

Please upload the full code list and an ODF type sample file here.

Doc attached Code is “ChangeKey” error at line 729.
Abide with me (D).odt (43.4 KB)

EDIT: Note the correction in the OP.

Because the tables aren’t the same like paragraphs for oDoc.Text.createEnumeration. So if you want to traverse the paragraphs in Table, you need traverse Text in cells cell-by-cell.
But you don’t need use oDoc.Text.createEnumeration, you can work only with SearchDescriptor and test the property oFound.ParaStyleName.


But there is classical problem in your example I expected, the chords aren’t “justified” clearly to text, so there could be 2nd way for designing chords → the frames with chords. But there is next problem for macro, how to detect the frames in selection? But I don’t know, I tried it but failed.

If tables cannot be easily ignored, I shall find another method to store the data. (I could just store the verses in paragraphs and will, most likely do that to avoid the issue in future.) Menatime, I ahve over a thousand songs to convert, which is why I’m developing this code any way.

I am aware of the Justification of Chords issue, It is not a major problem as most of my playing these days is on Bass and I use NN for that. The charts are really a throwback to my days as a guitarist and I am just trying develop something that works for me. The main purpose of this project is to make it as flexible and bullet proof as possible. If a guitarist needs to see a chord chart then I can convert to the specific key. If the changes are not perfectly justified it’s not going to be a huge problem as familiarity with the song should allow chords to be changed correctly anyway.

Currently, I run an iPad with SongsheetPro on it, which does much of what I need, however, it does not handle NN, nor does it talk to Linux. I do possess a tablet PC which I am planning on using (waiting on a new SSD) with Writer and the code I am currently developing. It then makes adding a new song a matter of copying data across my home network than having to jump through hoops just to load a song on that device!

I’ll flag this question as Abandoned!
Thanks again for all of your assistance.

Because you need the F&R in selection, then it will be always more complicated with tables than without ones.

Fair enough, I’m just converting the tables as I find them to two columns in a separate section which seems to work with no ill effect.