mirror of
https://github.com/kekingcn/kkFileView.git
synced 2026-04-20 00:28:38 +00:00
集成OpenOffice替换为LibreOffice
This commit is contained in:
@@ -1,25 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
||||
<!--***********************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
***********************************************************-->
|
||||
<!--
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
-->
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Misc" script:language="StarBasic">REM ***** BASIC *****
|
||||
|
||||
Const SBSHARE = 0
|
||||
@@ -104,6 +101,9 @@ Dim oMasterKey
|
||||
If Ubound(sLocaleList()) > 0 Then
|
||||
aLocLocale.Country = sLocaleList(1)
|
||||
End If
|
||||
If Ubound(sLocaleList()) > 1 Then
|
||||
aLocLocale.Variant = sLocaleList(2)
|
||||
End If
|
||||
GetStarOfficeLocale() = aLocLocale
|
||||
End Function
|
||||
|
||||
@@ -137,14 +137,14 @@ Dim sProdName as String
|
||||
End Function
|
||||
|
||||
|
||||
' Opens a Document, checks beforehand, wether it has to be loaded
|
||||
' or wether it is already on the desktop.
|
||||
' If the parameter bDisposable is set to False then then returned document
|
||||
' Opens a Document, checks beforehand, whether it has to be loaded
|
||||
' or whether it is already on the desktop.
|
||||
' If the parameter bDisposable is set to False then the returned document
|
||||
' should not be disposed afterwards, because it is already opened.
|
||||
Function OpenDocument(DocPath as String, Args(), Optional bDisposable as Boolean)
|
||||
Dim oComponents as Object
|
||||
Dim oComponent as Object
|
||||
' Search if one of the active Components ist the one that you search for
|
||||
' Search if one of the active Components is the one that you search for
|
||||
oComponents = StarDesktop.Components.CreateEnumeration
|
||||
While oComponents.HasmoreElements
|
||||
oComponent = oComponents.NextElement
|
||||
@@ -168,7 +168,7 @@ End Function
|
||||
Function TaskonDesktop(DocPath as String) as Boolean
|
||||
Dim oComponents as Object
|
||||
Dim oComponent as Object
|
||||
' Search if one of the active Components ist the one that you search for
|
||||
' Search if one of the active Components is the one that you search for
|
||||
oComponents = StarDesktop.Components.CreateEnumeration
|
||||
While oComponents.HasmoreElements
|
||||
oComponent = oComponents.NextElement
|
||||
@@ -235,8 +235,8 @@ End Function
|
||||
|
||||
' Gets the fully qualified path to a subdirectory of the
|
||||
' Template Directory, e. g. with the parameter "wizard/bitmap"
|
||||
' The parameter must be passed over in Url-scription
|
||||
' The return-Value is in Urlscription
|
||||
' The parameter must be passed in Url notation
|
||||
' The return-Value is in Url notation
|
||||
Function GetOfficeSubPath(sOfficePath as String, ByVal sSubDir as String)
|
||||
Dim sOfficeString as String
|
||||
Dim sOfficeList() as String
|
||||
@@ -276,9 +276,9 @@ Dim oLocResSrv as Object
|
||||
If bResObjectexists Then
|
||||
oLocResSrv = oResSrv
|
||||
End If
|
||||
If InitResources("Tools", "com") Then
|
||||
If InitResources("Tools") Then
|
||||
ProductName = GetProductName()
|
||||
sError = GetResText(1006)
|
||||
sError = GetResText("RID_COMMON_6")
|
||||
sError = ReplaceString(sError, ProductName, "%PRODUCTNAME")
|
||||
sError = ReplaceString(sError, chr(13), "<BR>")
|
||||
MsgBox(sError, 16, ProductName)
|
||||
@@ -290,38 +290,50 @@ Dim oLocResSrv as Object
|
||||
End Sub
|
||||
|
||||
|
||||
Function InitResources(Description, ShortDescription as String) as boolean
|
||||
On Error Goto ErrorOcurred
|
||||
oResSrv = createUnoService( "com.sun.star.resource.VclStringResourceLoader" )
|
||||
Function InitResources(Description) as boolean
|
||||
Dim xResource as Object
|
||||
Dim sOfficeDir as String
|
||||
Dim aArgs(5) as Any
|
||||
On Error Goto ErrorOccurred
|
||||
sOfficeDir = "$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/wizards/"
|
||||
sOfficeDir = GetDefaultContext.getByName("/singletons/com.sun.star.util.theMacroExpander").ExpandMacros(sOfficeDir)
|
||||
aArgs(0) = sOfficeDir
|
||||
aArgs(1) = true
|
||||
aArgs(2) = GetStarOfficeLocale()
|
||||
aArgs(3) = "resources"
|
||||
aArgs(4) = ""
|
||||
aArgs(5) = NULL
|
||||
oResSrv = getProcessServiceManager().createInstanceWithArguments( "com.sun.star.resource.StringResourceWithLocation", aArgs() )
|
||||
If (IsNull(oResSrv)) then
|
||||
InitResources = FALSE
|
||||
MsgBox( Description & ": No resource loader found", 16, GetProductName())
|
||||
MsgBox("could not initialize StringResourceWithLocation")
|
||||
Else
|
||||
InitResources = TRUE
|
||||
oResSrv.FileName = ShortDescription
|
||||
End If
|
||||
Exit Function
|
||||
ErrorOcurred:
|
||||
ErrorOccurred:
|
||||
Dim nSolarVer
|
||||
InitResources = FALSE
|
||||
nSolarVer = GetSolarVersion()
|
||||
MsgBox("Resource file missing (" & ShortDescription & trim(str(nSolarVer)) + "*.res)", 16, GetProductName())
|
||||
MsgBox("Resource file missing", 16, GetProductName())
|
||||
Resume CLERROR
|
||||
CLERROR:
|
||||
End Function
|
||||
|
||||
|
||||
Function GetResText( nID as integer ) As string
|
||||
On Error Goto ErrorOcurred
|
||||
Function GetResText( sID as String ) As string
|
||||
Dim sString as String
|
||||
On Error Goto ErrorOccurred
|
||||
If Not IsNull(oResSrv) Then
|
||||
GetResText = oResSrv.getString( nID )
|
||||
sString = oResSrv.resolveString(sID)
|
||||
GetResText = ReplaceString(sString, GetProductname(), "%PRODUCTNAME")
|
||||
Else
|
||||
GetResText = ""
|
||||
End If
|
||||
Exit Function
|
||||
ErrorOcurred:
|
||||
ErrorOccurred:
|
||||
GetResText = ""
|
||||
MsgBox("Resource with ID =" + str( nID ) + " not found!", 16, GetProductName())
|
||||
MsgBox("Resource with ID =" + sID + " not found!", 16, GetProductName())
|
||||
Resume CLERROR
|
||||
CLERROR:
|
||||
End Function
|
||||
@@ -361,7 +373,7 @@ Dim oRange as Object
|
||||
End Sub
|
||||
|
||||
|
||||
' Inserts a certain String to all cells of a Range that ist passed over
|
||||
' Inserts a certain string to all cells of a range that is passed
|
||||
' either as an object or as the RangeName
|
||||
Sub ChangeValueofRange(oSheet as Object, Range, ReplaceValue, Optional StyleName as String)
|
||||
Dim oCellRange as Object
|
||||
@@ -369,7 +381,7 @@ Dim oCellRange as Object
|
||||
' Get the Range out of the Rangename
|
||||
oCellRange = oSheet.GetCellRangeByName(Range)
|
||||
Else
|
||||
' The range is passed over as an object
|
||||
' The range is passed as an object
|
||||
Set oCellRange = Range
|
||||
End If
|
||||
If IsMissing(StyleName) Then
|
||||
@@ -630,7 +642,7 @@ Dim i as Integer
|
||||
End Function
|
||||
|
||||
|
||||
Function GetLastUsedRow(oSheet as Object) as Integer
|
||||
Function GetLastUsedRow(oSheet as Object) as Long
|
||||
Dim oCell As Object
|
||||
Dim oCursor As Object
|
||||
Dim aAddress As Variant
|
||||
@@ -731,14 +743,6 @@ Function IsFatOffice() As Boolean
|
||||
End Function
|
||||
|
||||
|
||||
Function GetLocale(sLanguage as String, sCountry as String)
|
||||
Dim oLocale as New com.sun.star.lang.Locale
|
||||
oLocale.Language = sLanguage
|
||||
oLocale.Country = sCountry
|
||||
GetLocale = oLocale
|
||||
End Function
|
||||
|
||||
|
||||
Sub ToggleDesignMode(oDocument as Object)
|
||||
Dim aSwitchMode as new com.sun.star.util.URL
|
||||
aSwitchMode.Complete = ".uno:SwitchControlDesignMode"
|
||||
@@ -779,18 +783,18 @@ Dim ErrMsg as String
|
||||
oDocument = StarDesktop.LoadComponentFromURL(sUrl,"_default",0, NoArgs())
|
||||
NOMODULEINSTALLED:
|
||||
If (Err <> 0) OR IsNull(oDocument) Then
|
||||
If InitResources("", "com") Then
|
||||
If InitResources("") Then
|
||||
Select Case sType
|
||||
Case "swriter"
|
||||
ErrMsg = GetResText(1001)
|
||||
ErrMsg = GetResText("RID_COMMON_1")
|
||||
Case "scalc"
|
||||
ErrMsg = GetResText(1002)
|
||||
ErrMsg = GetResText("RID_COMMON_2")
|
||||
Case "simpress"
|
||||
ErrMsg = GetResText(1003)
|
||||
ErrMsg = GetResText("RID_COMMON_3")
|
||||
Case "sdraw"
|
||||
ErrMsg = GetResText(1004)
|
||||
ErrMsg = GetResText("RID_COMMON_4")
|
||||
Case "smath"
|
||||
ErrMsg = GetResText(1005)
|
||||
ErrMsg = GetResText("RID_COMMON_5")
|
||||
Case Else
|
||||
ErrMsg = "Invalid Document Type!"
|
||||
End Select
|
||||
|
||||
Reference in New Issue
Block a user