/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoTep/UtilAPI.xba is in libreoffice-dmaths 3.4+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="UtilAPI" script:language="StarBasic">'**********************************************************************
' UtilAPI module
'
' Module of utility routines for working with the OOo API.
' These utilities are not specific to Draw, or Writer,
' or Calc, for instance.
'
'**********************************************************************
' Copyright (c) 2003 - 2004 Danny Brewer
' d29583@groovegarden.com
'
' This library is free software; you can redistribute it and/or
' modify it under the terms of the GNU Lesser General Public
' License as published by the Free Software Foundation; either
' version 2.1 of the License, or (at your option) any later version.
'
' This library is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
' Lesser General Public License for more details.
'
' You should have received a copy of the GNU Lesser General Public
' License along with this library; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 - 1307 USA
'
' See: http://www.gnu.org/licenses/lgpl.html
'
'**********************************************************************
' If you make changes, please append to the change log below.
'
' Change Log
' Danny Brewer Revised 2004 - 10 - 25 - 01
'
'**********************************************************************
Function GetDocumentFrame( oDoc As Object ) As Object
Dim oFrame As Object
Dim oCtrl as Object
' If the caller gave us the document model...
If oDoc.supportsService( "com.sun.star.document.OfficeDocument" ) Then
' ...then get the controller from that.
oCtrl = oDoc.getCurrentController()
' ...then get the frame from the controller.
oFrame = oCtrl.getFrame()
' If the caller gave us a document controller...
ElseIf HasUnoInterfaces( oDoc, "com.sun.star.frame.XController" ) Then
oCtrl = oDoc
' ...then get the frame from the controller.
oFrame = oCtrl.getFrame()
' If the caller gave us the document frame...
ElseIf HasUnoInterfaces( oDoc, "com.sun.star.frame.XFrame" ) Then
' ...thanks! That's just what we wanted!
oFrame = oDoc
Else
' The caller did not give us what we expected!
MsgBox1 "GetDocumentFrame called with incorrect parameter."
EndIf
GetDocumentFrame() = oFrame
End Function
Sub DocumentDispatch( ByVal oDocumentFrame As Object, ByVal cURL As String, Optional cTargetFrameName, Optional nSearchFlags, Optional aDispatchArgs )
Dim oDispatchHelper as Object
' If they gave us the wrong parameter...
If Not IsNull( oDocumentFrame ) Then
If Not HasUnoInterfaces( oDocumentFrame, "com.sun.star.frame.XFrame" ) Then
' Be sure that we've got the document frame.
' Someone might have passed us the document model or one of
' its controller's.
oDocumentFrame = GetDocumentFrame( oDocumentFrame )
EndIf
EndIf
If IsMissing( cTargetFrameName ) Then
cTargetFrameName = ""
EndIf
If IsMissing( nSearchFlags ) Then
nSearchFlags = 0
EndIf
If IsMissing( aDispatchArgs ) Then
aDispatchArgs = Array()
EndIf
oDispatchHelper = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatchHelper.executeDispatch( oDocumentFrame, cURL, cTargetFrameName, nSearchFlags, aDispatchArgs )
End Sub
Sub ClipBoardToText(cText as String)
dim oDoc
dim oText
dim oCursor
oDoc = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Array( MakePropertyValue( "Hidden", True ) ) )
' Get the text of the document.
oText = oDoc.getText()
' Get a cursor that can move over or to any part of the text.
oCursor = oText.createTextCursor()
' Insert text and paragraph breaks into the text, at the cursor position.
oText.insertString( oCursor, cText, False )
ClipboardPaste( oDoc )
SelectAll( oDoc )
cText = oText.GetString(oCursor)
oDoc.close( True )
End Sub
Sub TextToClipboard( ByVal cText As String )
dim oDoc
dim oText
dim oCursor
oDoc = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Array( MakePropertyValue( "Hidden", True ) ) )
' Get the text of the document.
oText = oDoc.getText()
' Get a cursor that can move over or to any part of the text.
oCursor = oText.createTextCursor()
' Insert text and paragraph breaks into the text, at the cursor position.
oText.insertString( oCursor, cText, False )
SelectAll( oDoc )
ClipboardCopy( oDoc )
oDoc.close( True )
End Sub
Sub SelectAll( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:SelectAll" )
End Sub
Sub ClipboardCopy( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Copy" )
End Sub
Sub ClipboardPaste( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Paste" )
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue as New com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
</script:module>
|