Eureka! I found the start of an answer for my question. I recorded a macro that imports fields from my database:
Code: Select all
sub test
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(6) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Type"
args1(0).Value = 19
args1(1).Name = "DBName"
args1(1).Value = "Indexation"
args1(2).Name = "Command"
args1(2).Value = "Vie_acad"
args1(3).Name = "ColumnName"
args1(3).Value = "libelle"
args1(4).Name = "CommandType"
args1(4).Value = 0
args1(5).Name = "Content"
args1(5).Value = ""
args1(6).Name = "Format"
args1(6).Value = 5000
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Text"
args3(0).Value = CHR$(9)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(6) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Type"
args4(0).Value = 19
args4(1).Name = "DBName"
args4(1).Value = "Indexation"
args4(2).Name = "Command"
args4(2).Value = "Vie_acad"
args4(3).Name = "ColumnName"
args4(3).Value = "titre"
args4(4).Name = "CommandType"
args4(4).Value = 0
args4(5).Name = "Content"
args4(5).Value = ""
args4(6).Name = "Format"
args4(6).Value = 5000
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args4())
rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "Text"
args5(0).Value = ", "
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args5())
rem ----------------------------------------------------------------------
dim args6(6) as new com.sun.star.beans.PropertyValue
args6(0).Name = "Type"
args6(0).Value = 19
args6(1).Name = "DBName"
args6(1).Value = "Indexation"
args6(2).Name = "Command"
args6(2).Value = "Vie_acad"
args6(3).Name = "ColumnName"
args6(3).Value = "pgdebut"
args6(4).Name = "CommandType"
args6(4).Value = 0
args6(5).Name = "Content"
args6(5).Value = ""
args6(6).Name = "Format"
args6(6).Value = 5000
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Text"
args7(0).Value = " - "
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(6) as new com.sun.star.beans.PropertyValue
args8(0).Name = "Type"
args8(0).Value = 19
args8(1).Name = "DBName"
args8(1).Value = "Indexation"
args8(2).Name = "Command"
args8(2).Value = "Vie_acad"
args8(3).Name = "ColumnName"
args8(3).Value = "pgfin"
args8(4).Name = "CommandType"
args8(4).Value = 0
args8(5).Name = "Content"
args8(5).Value = ""
args8(6).Name = "Format"
args8(6).Value = 5000
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args8())
rem ----------------------------------------------------------------------
dim args9(6) as new com.sun.star.beans.PropertyValue
args9(0).Name = "Type"
args9(0).Value = 24
args9(1).Name = "DBName"
args9(1).Value = "Indexation"
args9(2).Name = "Command"
args9(2).Value = "Vie_acad"
args9(3).Name = "ColumnName"
args9(3).Value = "TRUE"
args9(4).Name = "CommandType"
args9(4).Value = 0
args9(5).Name = "Content"
args9(5).Value = ""
args9(6).Name = "Format"
args9(6).Value = 0
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(1) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Count"
args10(0).Value = 1
args10(1).Name = "Select"
args10(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(1) as new com.sun.star.beans.PropertyValue
args11(0).Name = "Count"
args11(0).Value = 1
args11(1).Name = "Select"
args11(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(1) as new com.sun.star.beans.PropertyValue
args12(0).Name = "Count"
args12(0).Value = 1
args12(1).Name = "Select"
args12(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args12())
rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "ControlCodes"
args13(0).Value = true
dispatcher.executeDispatch(document, ".uno:ControlCodes", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(1) as new com.sun.star.beans.PropertyValue
args14(0).Name = "Count"
args14(0).Value = 1
args14(1).Name = "Select"
args14(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args14())
rem ----------------------------------------------------------------------
dim args15(1) as new com.sun.star.beans.PropertyValue
args15(0).Name = "Count"
args15(0).Value = 1
args15(1).Name = "Select"
args15(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args15())
rem ----------------------------------------------------------------------
dim args16(1) as new com.sun.star.beans.PropertyValue
args16(0).Name = "Count"
args16(0).Value = 1
args16(1).Name = "Select"
args16(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args16())
rem ----------------------------------------------------------------------
dim args17(1) as new com.sun.star.beans.PropertyValue
args17(0).Name = "Count"
args17(0).Value = 1
args17(1).Name = "Select"
args17(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args17())
rem ----------------------------------------------------------------------
dim args18(1) as new com.sun.star.beans.PropertyValue
args18(0).Name = "Count"
args18(0).Value = 1
args18(1).Name = "Select"
args18(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args18())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
rem ----------------------------------------------------------------------
dim args20(0) as new com.sun.star.beans.PropertyValue
args20(0).Name = "Text"
args20(0).Value = CHR$(9)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args20())
rem ----------------------------------------------------------------------
dim args21(6) as new com.sun.star.beans.PropertyValue
args21(0).Name = "Type"
args21(0).Value = 19
args21(1).Name = "DBName"
args21(1).Value = "Indexation"
args21(2).Name = "Command"
args21(2).Value = "Vie_acad"
args21(3).Name = "ColumnName"
args21(3).Value = "titre"
args21(4).Name = "CommandType"
args21(4).Value = 0
args21(5).Name = "Content"
args21(5).Value = ""
args21(6).Name = "Format"
args21(6).Value = 5000
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args21())
rem ----------------------------------------------------------------------
dim args22(0) as new com.sun.star.beans.PropertyValue
args22(0).Name = "Text"
args22(0).Value = ", "
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args22())
rem ----------------------------------------------------------------------
dim args23(6) as new com.sun.star.beans.PropertyValue
args23(0).Name = "Type"
args23(0).Value = 19
args23(1).Name = "DBName"
args23(1).Value = "Indexation"
args23(2).Name = "Command"
args23(2).Value = "Vie_acad"
args23(3).Name = "ColumnName"
args23(3).Value = "pgdebut"
args23(4).Name = "CommandType"
args23(4).Value = 0
args23(5).Name = "Content"
args23(5).Value = ""
args23(6).Name = "Format"
args23(6).Value = 5000
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args23())
rem ----------------------------------------------------------------------
dim args24(0) as new com.sun.star.beans.PropertyValue
args24(0).Name = "Text"
args24(0).Value = " - "
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args24())
rem ----------------------------------------------------------------------
dim args25(6) as new com.sun.star.beans.PropertyValue
args25(0).Name = "Type"
args25(0).Value = 19
args25(1).Name = "DBName"
args25(1).Value = "Indexation"
args25(2).Name = "Command"
args25(2).Value = "Vie_acad"
args25(3).Name = "ColumnName"
args25(3).Value = "pgfin"
args25(4).Name = "CommandType"
args25(4).Value = 0
args25(5).Name = "Content"
args25(5).Value = ""
args25(6).Name = "Format"
args25(6).Value = 5000
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args25())
rem ----------------------------------------------------------------------
dim args26(6) as new com.sun.star.beans.PropertyValue
args26(0).Name = "Type"
args26(0).Value = 24
args26(1).Name = "DBName"
args26(1).Value = "Indexation"
args26(2).Name = "Command"
args26(2).Value = "Vie_acad"
args26(3).Name = "ColumnName"
args26(3).Value = "TRUE"
args26(4).Name = "CommandType"
args26(4).Value = 0
args26(5).Name = "Content"
args26(5).Value = ""
args26(6).Name = "Format"
args26(6).Value = 0
dispatcher.executeDispatch(document, ".uno:InsertDBField", "", 0, args26())
end sub
This takes the two first records for a field.
Now I have to learn how to put conditional instructions on it. Like: "if field libelle not equal previous field libelle then ..."
My problem now is how to get the database information in variables to do the conditions. I've tried:
But args1(5).Value doesn't contain the value of the database field. I'll have to connect to the database and ask for values "by hand", what I don't know by now. I'm reading section 8 of AndrewBase document that talks about it.
Sorry if this seams a mess, by so is my head. I should begin macro and basic learning by an easier project... But I have no choice.