Public Sub Test()
CreateNewWriterDoc()
InsertPicture("C:\Jitender.jpg")
SetSize(GetGraphicObject(0), 1000, 1000)
End Sub
Public Sub SetSize(ByVal MyObject As Object, ByVal Height As Long, ByVal Width As Long)
Dim MySize As New Object
MySize = CreateUnoStruct("com.sun.star.awt.Size")
MySize.Height = Height
MySize.Width = Width
MyObject.setSize(MySize)
End Sub
Public Function GetGraphicObject(ByVal Key As Object) As Object
If VarType(Key) = VariantType.String Then
'GetGraphicObject by name
GetGraphicObject = GetGraphicObjects.getByName(Key)
ElseIf VarType(Key) = VariantType.Integer Then
'GetGraphicObject by index
GetGraphicObject = GetGraphicObjects.getByIndex(Key)
Else
GetGraphicObject = Nothing
End If
End Function
Public Function GetGraphicObjects() As Object
'1) First step to work with GraphicObjects:
'get the GraphicObjects collection
GetGraphicObjects = ThisComponent.getGraphicObjects
End Function
Public Function InsertPicture(ByVal Filepath As String) As Object
'Instanciate a frame for the graphic object
InsertPicture = ThisComponent.createInstance("com.sun.star.text.GraphicObject")
'get image
InsertPicture.GraphicURL = ConvertToURL(Filepath)
'insert the image
ThisComponentText.InsertTextContent(TextCursor, InsertPicture, False)
End Function
Public Sub GotoBookmark(ByVal Name As String)
'2) second step:
'Find Bookmarkbyname
Dim CurseurPos As Object
'Find cursor posiution here on bookmark anchor
'Find anchor of the bookmarks
CurseurPos = GetBookmark(Name).Getanchor
'Move visible cursor to text cursor
ViewCursor.GoToRange(CurseurPos, False)
End Sub
Public Function GetBookmark(ByVal Name As String) As Object
'Check if Bookmark exists
If GetBookmarks.HasByName(Name) = True Then
'Find Bookmarkbyname
GetBookmark = GetBookmarks.GetByName(Name)
Else
GetBookmark = Nothing
End If
End Function
Public Function GetBookmarks() As Object
'1) First step to work with bookmarks:
'get the bookmarks collection
GetBookmarks = ThisComponent.getBookmarks
End Function
Public Function CreateNewCalcDoc() As Object
Dim arg(-1) As Object
'Create a new Calc doc
CreateNewCalcDoc = StarDesktop.LoadComponentFromUrl("private:factory/scalc", "blank", 0, arg)
End Function
Public Function CreateNewWriterDoc() As Object
Dim arg(-1) As Object
'Create a new Writer doc
CreateNewWriterDoc = StarDesktop.LoadComponentFromUrl("private:factory/swriter", "blank", 0, arg)
End Function
Public Function TextCursor() As Object
'1 'Method to find create a textcursor
TextCursor = ViewCursorText.CreateTextCursor
'2 Move the textcursor to the ViewCursor
TextCursor.GotoRange(ViewCursor, False)
End Function
Public Function ThisComponentText() As Object
'Method to get TextRange of the CurrentComponent
ThisComponentText = ThisComponent.GetText
End Function
Public Function ObjetXCurrentController() As Object
'Method to find the CurrentController
ObjetXCurrentController = ThisComponent.getCurrentController
End Function
Public Function ViewCursorText() As Object
'Method to get TextRange of the ViewCursor
ViewCursorText = ViewCursor.GetText
End Function
Public Function ViewCursor() As Object
'*Method to find the view cursor
ViewCursor = ObjetXCurrentController.GetViewCursor
End Function
Public Function ConvertToURL(ByVal Filepath As String) As String
'Change windows notation to OO
Dim Newstring As String
Newstring = Replace$(Filepath, "\", "/")
ConvertToURL = ("file:///" & Newstring)
End Function
Public Function CreateUnoStruct(ByVal Service As String) As Object
'Equivalent to oOOBasic Function
CreateUnoStruct = GetProcessServiceManager.Bridge_GetStruct(Service)
End Function
Public Function CreateUnoService(ByVal Service As String) As Object
'Equivalent to oOOBasic Function
CreateUnoService = GetProcessServiceManager.CreateInstance(Service)
End Function
Public Function ThisComponent() As Object
'Equivalent to oOOBasic Function
ThisComponent = StarDesktop.getCurrentComponent
End Function
Public Function StarDesktop() As Object
'Equivalent to oOOBasic Function
StarDesktop = CreateUnoService("com.sun.star.frame.Desktop")
End Function
Public Function GetProcessServiceManager() As Object
'Equivalent to oOOBasic Function
GetProcessServiceManager = CreateObject("com.sun.star.ServiceManager")
End Function
!--removed tag-->
Enter your message below
Sign in or Join us (it's free).