Enumerating conditional text fields
Posted: Fri May 31, 2019 6:48 am
LibreOffice 6.1.5.2 (x64) on W10. Writer. BASIC macro.
I'm trying to enumerate all text fields in a document in order to search for a specific one. Other objects enumerate easily. e.g.ThisComponent.Bookmarks is an array of bookmark objects. ThisComponent.TextFields exists but is not an array and has no iterative mechanism. To try to do this with general text fields I have modified Pitonyak's EnumerateTextSections (Listing 342) to show only text fields but in more detail, i.e. if not IsNull( oParSection.TextField) then inspect the section. For variable type text fields the object is fully constructed and all methods and elements are valid and accessible. But for conditional text fields the object is incomplete. Most elements are <out of scope> and all of the elements that are not like this have the same values as any fully constructed text field. Even the array elements that the BASIC IDE debugger implies are complete because it tells their index range, SupportedServiceName, Types, and ImplementationID, are not complete and expanding them crashes the debugger. Writer itself obviously knows how to make sense of this because Insert > Field > More Fields > Functions tab shows any existing conditional text fields. Does anyone have any idea how to access this same information from a macro?
I'm trying to enumerate all text fields in a document in order to search for a specific one. Other objects enumerate easily. e.g.ThisComponent.Bookmarks is an array of bookmark objects. ThisComponent.TextFields exists but is not an array and has no iterative mechanism. To try to do this with general text fields I have modified Pitonyak's EnumerateTextSections (Listing 342) to show only text fields but in more detail, i.e. if not IsNull( oParSection.TextField) then inspect the section. For variable type text fields the object is fully constructed and all methods and elements are valid and accessible. But for conditional text fields the object is incomplete. Most elements are <out of scope> and all of the elements that are not like this have the same values as any fully constructed text field. Even the array elements that the BASIC IDE debugger implies are complete because it tells their index range, SupportedServiceName, Types, and ImplementationID, are not complete and expanding them crashes the debugger. Writer itself obviously knows how to make sense of this because Insert > Field > More Fields > Functions tab shows any existing conditional text fields. Does anyone have any idea how to access this same information from a macro?