Seite 1 von 1

Zwischenablage in Tabellenzelle (Cursor) einfügen

Verfasst: Do, 17.02.2011 22:14
von polarbear
Hallo Gemeinde,

wie kann der aktuelle Inhalt der Zwischenablage in die Tabellenzelle, in der der Cursor gerade steht, eingefügt werden.
Im Moment verwende ich ein Makro, das Text in das Dokument einfügt. Das funktioniert aber nicht, wenn der Cursor in einer Tabellenzelle steht:

Code: Alles auswählen

Sub ImportClipboard
  Dim oClip, oClipContents, oTypes
  Dim oConverter, convertedString$
  Dim i%, iPlainLoc%
 
  iPlainLoc = -1
 
  oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
  oConverter = createUnoService("com.sun.star.script.Converter")
 
  oClipContents = oClip.getContents()
  oTypes = oClipContents.getTransferDataFlavors()
 
  Dim msg$, iLoc%, outS
  msg = ""
  iLoc = -1
  For i=LBound(oTypes) To UBound(oTypes)
    If oTypes(i).MimeType = "text/plain;charset=utf-16" Then
      iPlainLoc = i
      Exit For
    End If
     'msg = msg & "Mime type = " & x(ii).MimeType & " normal = " & x(ii).HumanPresentableName & Chr$(10)
  Next
  If (iPlainLoc >= 0) Then
    convertedString = oConverter.convertToSimpleType(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)

    myDoc=thisComponent
    myViewCursor=myDoc.GetCurrentController.ViewCursor
    myViewCursor.String = convertedString

  Else
  	 MsgBox "Nichts zum Einfügen vorhanden"
  End If
End Sub
Ich vermute es liegt an diesen Zeilen

Code: Alles auswählen

    convertedString = oConverter.convertToSimpleType(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)
    myDoc=thisComponent
    myViewCursor=myDoc.GetCurrentController.ViewCursor
    myViewCursor.String = convertedString
Wer kann helfen?

Dank und Gruß
polarbear



Moderation,4: ins zuständige Unterforum verschoben

Re: Zwischenablage in Tabellenzelle (Cursor) einfügen

Verfasst: Mo, 07.03.2011 12:37
von komma4
polarbear hat geschrieben:wie kann der aktuelle Inhalt der Zwischenablage in die Tabellenzelle, in der der Cursor gerade steht, eingefügt werden.
Das müsste mit folgendem dispatcher Code gehen, oder?

Code: Alles auswählen

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())