i've got a macro in OoBasic called from a VB6 GED aplication which move formated Header and footer Text into Floating Frames
the stuff is done via a clipboard cut/paste and work fine but ...
as it's deployed on a hundred of user pc it's really anyoning for them to get their clipboard modified each time they open a document
so does anyone could help me finding a way to copy a Document Text without using that damned clipboad at all
(i've made a program to save and restore clipboard but anyway sometime that mess and clipboard is affected)
great thanks for further help
if it could help, here is a part of my code using cut and paste
Code: Select all
Private Function AttRtf_TraiterHFPageStyle(ByRef poDoc As Object, ByRef poPageStyle As Object, ByVal piHeaderFooter As Integer) As Boolean
' transformer l'entete ou bas-page (selon piHeaderFooter)
' référencé dans le style de page (poPageStyle) pour le document actif (poDoc)
Dim oPageHFCursor As Object
Dim oArgs() As Object
Dim oDisp As Object
Dim oFrame As Object
Dim oHFText As Object
Dim oTextCursor As Object
Dim oTextFrame As Object
Dim oTextFrameText As Object
Dim oTextFrameTextCursor As Object
Dim oCurrentController As Object
Dim oViewCursor As Object
Dim iPageNum As Integer, iPageCount As Integer
Dim sPageStyle As String
Dim bSuccess As Boolean
Dim sMsg As String ' message erreur eventuel (cf Echec_Preparation)
Dim sFileHF As String
Dim bViewCursorCollapsed As Boolean ' indique si la viewCursor reste vide parce qu'il peux pas se positionner sur ce header/footer
Static bShowMsgOnce As Boolean
Dim sTestInitial As String, sTest As String ' buffer texte de l'entete/baspage avant/apres collage ou insertion dans la frame pour tests
Dim sTestAfterCut As String
Dim lSaveStyleHF_Height As Long
Set oDisp = gMainForm.moSM.CreateInstance("com.sun.star.frame.DispatchHelper")
Set oCurrentController = poDoc.getCurrentController()
Set oFrame = oCurrentController.GetFrame()
Set oViewCursor = oCurrentController.getViewCursor()
Set oPageHFCursor = oHFText.createTextCursor()
' Now set some formatting (reuse cursor object)
oPageHFCursor.gotoStart (False)
oPageHFCursor.gotoEnd (True)
oCurrentController.Select oPageHFCursor
oViewCursor.GotoRange oPageHFCursor, False
bViewCursorCollapsed = oViewCursor.IsCollapsed()
If bViewCursorCollapsed Then
GoTo Finally
End If
' selectionner le texte de la TextFrame
oCurrentController.Select oPageHFCursor
oViewCursor.GotoRange oPageHFCursor, False
' couper ce texte initial
oDisp.executeDispatch oFrame, ".uno:Cut", "", 0, oArgs()
Set oTextFrame = poDoc.CreateInstance("com.sun.star.text.TextFrame")
With oTextFrame
'.anchorType = com.sun.star.Text.TextContentAnchorType.AT_PARAGRAPH
.anchortype = 0 ' 0= au paragraphe, 2=page, 1=comme car, 4=au caractere
.FrameIsAutomaticHeight = True
.FrameWidthPercent = 100
.TextWrap = 1 ' WrapTextMode.NONE = 0
' indiquer affichage de cette frame en "Arriere plan" par rapport au texte de la page
.Opaque = False
' *** voir si ces lignes peuvent etre deplacées dans le 1er bloc with
.HoriOrientPosition = 0
.VertOrientPosition = 0
.HoriOrientRelation = 8 ' Zone de texte de page
.VertOrientRelation = 7
.HoriOrient = 3 ' 0 = à gauche, 3 = à gauche
If piHeaderFooter = ci_Header Then
.VertOrient = 0 ' 1 = top, 2=center, 3=bottom, 0=du haut
' positionne header à iMargeHeader 100eme de mm du haut de la page
.VertOrientPosition = mOpenOfficeEtudeIni.iMargeHeader * 100
.SetName ("Header : " & poPageStyle.getName())
Else
.VertOrient = 3 ' 1 = top, 2=center, 3=bottom, 0=du haut
.BottomMargin = mOpenOfficeEtudeIni.iMargeFooter * 100
.SetName ("Footer : " & poPageStyle.getName())
End If
.IsFollowingTextFlow = False
End With
' Inserer cette frame dans le TextCursor du bookmarkFrame
Call oHFText.insertTextContent(oPageHFCursor, oTextFrame, False)
' creer un curseur sur le texte de cette frame
Set oTextFrameText = oTextFrame.Text
Set oTextFrameTextCursor = oTextFrameText.createTextCursor()
' selectionner le texte de la TextFrame
oCurrentController.Select oTextFrameTextCursor
'oViewCursor.GotoRange oTextFrameTextCursor, False
oViewCursor.GotoRange oTextFrameTextCursor, True
' coller le texte de l'entete actuelle dans le curseur de la TextFrame
[b]oDisp.executeDispatch oFrame, ".uno:Paste", "", 0, oArgs()[/b]
...
Finally:
Set oDisp = Nothing
Set oCurrentController = Nothing
Set oFrame = Nothing
Set oViewCursor = Nothing
End Function