Issue 98931 - macros does not paste text into Notes as in 2.4
Summary: macros does not paste text into Notes as in 2.4
Alias: None
Product: Writer
Classification: Application
Component: programming (show other issues)
Version: OOo 3.0
Hardware: All Windows XP
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2009-02-05 17:34 UTC by l_allemano
Modified: 2017-05-20 11:17 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

in oo writer 3.0 macros does not works as in 2.4 (12.45 KB, application/vnd.oasis.opendocument.text)
2009-02-05 17:37 UTC, l_allemano
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description l_allemano 2009-02-05 17:34:42 UTC
I make intensive use of  macros  that inspect the text and in presence of   
keywords transform the paragraph in Annotation
in OO writer 2.4 calling the macro "Trasform_Selected_Text_To_Annotation"   
will replace the selected text with a Annotation  which contains the selected 
text .
in OO writer 3.0  the same macro  cuts the text and inserts a Annotation with 
no text  at all , without raise errors or exceptions.

REM  *****  BASIC  *****
rem define variables
		dim document   as object
		dim dispatcher as object

Sub Trasform_Selected_Text_To_Annotation()
	   Dim 	oDisp , octl
	   Dim  NoArg()
	   Dim nome as String 
	   dim textOfAnnotation As String
	   document   = ThisComponent.CurrentController.Frame
         ''' create the DispatcherService
	   dispatcher = createUnoService("")
	 ''' Set source doc/currentController/frame/sheet/range.
	   octl = ThisComponent.getCurrentController()
	 '''''copy the current selection to the clipboard.
	   dispatcher.executeDispatch(octl, ".uno:Cut", "", 0, NoArg())
	   textOfAnnotation = getClipBoard()
End Sub

sub insertAnnotation (textOfAnnotation)
		dim args2(2) as new
		args2(0).Name = "Text"
		args2(0).Value =  textOfAnnotation 
		args2(1).Name = "Author"
		args2(1).Value = "test"
		args2(2).Name = "Date"
		args2(2).Value = ""
(document, ".uno:InsertAnnotation", "", 0, args2())

end sub

Function  getClipBoard() as String
	Dim oClip, oClipContents, oTypes
	Dim oConverter, convertedString$
	Dim i%, iPlainLoc%
	iPlainLoc = -1
	Dim s$ : s$ = ""
	oClip = createUnoService(s$)
	oConverter = createUnoService("")
	'Print "Clipboard name = " & oClip.getName()
	'Print "Implemantation name = " & oClip.getImplementationName()
	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)
	If (iPlainLoc >= 0) Then
		convertedString = oConverter.convertToSimpleType( _
		oClipContents.getTransferData(oTypes(iPlainLoc)), _
	End If
	getClipBoard = convertedString
End Function
Comment 1 l_allemano 2009-02-05 17:37:56 UTC
Created attachment 59967 [details]
in oo writer 3.0 macros does not works as in 2.4
Comment 2 michael.ruess 2009-02-12 15:24:47 UTC
MRU->OS: see attached document. Selected text is not pasted into a Note anymore
as it was done in OOo 2.4 by the Macro.
Comment 3 michael.ruess 2009-02-12 15:49:33 UTC
Comment 4 michael.ruess 2009-02-13 14:03:32 UTC
Ignore my above "Closed" comment...
Wanted to reassign to OS...
Comment 5 jurf 2009-05-23 14:06:43 UTC
I've came across the same bug (3.1 dev OOO3010m40 build 9388), trying to paste
text into a new Note using a macro. Behaviour was extremely erratic: worked
about one in twenty times, if that, with no apparent logic.

This suggests a problem with timing or threads, and - so far - adding a short
pause after the Note's creation (.uno:InsertAnnotation) seems to work for me. A
simple example:

Sub Main
	dim document   as object
	dim dispatcher as object
	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("")

	dispatcher.executeDispatch(document, ".uno:Copy", "", 0, array())
	dispatcher.executeDispatch(document, ".uno:InsertAnnotation", "", 0, array())
	wait 500
	dispatcher.executeDispatch(document, ".uno:Paste", "", 0, array())
End Sub

Hope that helps.
Comment 6 Oliver Specht 2009-09-30 09:32:10 UTC
Target changed to 3.x
Comment 7 Marcus 2017-05-20 11:17:48 UTC
Reset assigne to the default "".