ViewDataSourceBrowser

Antwort erstellen


BBCode ist eingeschaltet
[img] ist ausgeschaltet
[url] ist eingeschaltet
Smileys sind ausgeschaltet

Die letzten Beiträge des Themas
   

Ansicht erweitern Die letzten Beiträge des Themas: ViewDataSourceBrowser

ViewDataSourceBrowser

von moritz » Mi, 12.09.2007 20:55

Hallo, das Thema "Auswahl von Datensätzen im DatabaseBrowser" für Serienbriefe wurde hier schon mehrfach angesprochen.
Ich möchte den Datenbankbrowser mit einer bestimmten Tabellenansicht (das Ergebnis einer SQL-Abfrage) aufrufen und dann die Feldinhalte in einen Serienbrief eintragen. Mit den folgenden Makros (alle nicht von mir) klappt das als Beispiel auch ganz gut, wenn die richtige Datentabelle aktuell ist.
Meine Fragen:
1. Wie kann man mit einem Makro die richtige Datenquelle auswählen und diese im Datenquellenbrowser anzeigen?
2. "dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ViewDataSourceBrowser"
args1(0).Value = OpenIt
"dispatcher.executeDispatch(oFrame,".uno:ViewDataSourceBrowser","",0,args1())"
Kann es sein, daß man ".uno:ViewDataSourceBrowser" mehr Argumente mitgeben kann, z.B. für die aktuelle Tabellenansicht.
Das wäre sicher die beste Variante.
Ich hoffe, daß jemand eine Antwort darauf weiß.
Moritz

Sub DisplayF4_Beamer(OpenIt as Boolean)
Dim dispatcher,oFrame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oFrame = ThisComponent.CurrentController.Frame
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ViewDataSourceBrowser"
args1(0).Value = OpenIt
dispatcher.executeDispatch(oFrame,".uno:ViewDataSourceBrowser","",0,args1())
End Sub

Sub DataToFields '(oDoc) 'Version 2, John C. Vigor, Jr. 2/25/07
'Credit to Bernard Marcelly, Marc Santhoff, Frank Schönheit, Paolo Mantovani
'and Fernand for the difficult portion of the code in the "RowSelectionInDataBrowser"
'function:
' http://codesnippets.services.openoffice ... ethod.snip
'This function has otherwise been butchered by me.
BasicLibraries.LoadLibrary("XrayTool")
Dim DBname,tableName,DBrow,oEnum,thisField
Dim TFM,fieldName,s$,a$,iAns,ExtraFN,ExtraDB
oDoc = ThisComponent
REM Get the database row 0, database name and table name.
DBrow = RowSelectionInDataBrowser(oDoc,DBname,tableName)
oEnum = oDoc.getTextFields.createEnumeration 'Enumerate text fields.
While oEnum.hasMoreElements
thisField = oEnum.nextElement

If thisField.SupportsService("com.sun.star.text.TextField.Database") then 'Its a DB field.
TFM = thisField.getTextFieldMaster 'Get text field master.
If TFM.DataBaseName = DBname then 'The field is from the current database.
TFM.DataTableName = tableName 'Set text field master to selected table.
fieldName = TFM.DataColumnName 'Get the field name.
'msgbox fieldName
If DBrow.Columns.hasByName(fieldName) then 'Current DB row has this field name.
s$ = DBrow.Columns.getByName(fieldName).String 'Get desired presentation string.
thisField.CurrentPresentation = s$ 'Set the presentation.
Else ExtraFN = ExtraFN + 1 'Foreign field name count.
EndIf
Else ExtraDB = ExtraDB + 1 'Foreign database count.
Endif
EndIf
Wend
oDoc.Modified = true
If ExtraFN > 0 or ExtraDB > 0 then
s$ = "The macro has successfully completed but one or more database fields were not set:"
If ExtraFN > 0 then s$ = s$ & Chr(10) & " The document contains " & ExtraFN _
& " field name(s) not contained in the selected table."
If ExtraDB > 0 then s$ = s$ & Chr(10) & " The document contains " & ExtraDB _
& " field name(s) from a different data source."
MsgBox (s$,64)
EndIf
End Sub

Function RowSelectionInDataBrowser(oDoc,DBname,tableName)
Dim frame1,frame2,oModel,oDataSourceBrowser
frame1 = oDoc.CurrentController.Frame
frame2 = frame1.findFrame("_beamer",4) ' get DataBrowser frame
oDataSourcebrowser = frame2.Controller
oModel = oDataSourcebrowser.com_sun_star_awt_XTabController_getModel
DBname = oModel.DataSourceName 'Das ist die aktuell manuell gewählte Datenbank im Datenbankfenster
tableName = oModel.Command
oModel.moveToBookmark(0)
xray oModel
RowSelectionInDataBrowser = oModel
End Function

Nach oben