ArrayPrim |
Arrays |
_ConcatVectorsTest |
Basic |
|
194 |
14 |
Sub _ConcatVectorsTest()
Dim l_Array1 As Variant Dim l_Array2 As Variant Dim l_Array3 As Variant Dim l_ArrayConcat As Variant
l_Array1 = Array(1, 2, 3) l_Array2 = Array("a", "b") l_Array3 = Array(101, 102, 103, 104) l_ArrayConcat = ConcatVectors(Array(l_Array1, l_Array2, l_Array3)) End Sub |
ArrayPrim |
Arrays |
_TestVectorFromStringNums |
Basic |
|
560 |
9 |
Sub _TestVectorFromStringNums()
Dim l_Array As Variant
l_Array = VectorFromStringNums("-1, 2-3, 5 - 5, 15, 20, 36 - 33, 50", ",", "-", True) End Sub |
ArrayPrim |
Arrays |
_VectorToDataArrayTest |
Basic |
|
600 |
16 |
Sub _VectorToDataArrayTest()
Dim l_Vector1(6) As Variant Dim l_DataArray1 As Variant Dim l_DataArray2 As Variant l_Vector1(0) = 1 l_Vector1(2) = 2 l_Vector1(3) = 3 l_Vector1(6) = 6
l_DataArray1 = VectorToDataArray(l_Vector1, True) l_DataArray2 = VectorToDataArray(l_Vector1, False)
End Sub |
ArrayPrim |
Arrays |
AddToVector |
Basic |
|
43 |
18 |
Sub AddToVector(ByRef pVector As Variant, pItem as Variant)
Dim l_Array As Variant
l_Array = pVector If _ArrayExists(l_Array) Then ReDim Preserve l_Array(UBound(l_Array) + 1) Else ReDim l_Array(0) End If l_Array(UBound(l_Array)) = pItem pVector = l_Array End Sub |
ArrayPrim |
Arrays |
Array2DToDataArray |
Basic |
|
62 |
31 |
Function Array2DToDataArray(ByRef pArray2D As Variant) As Variant
Dim l_DataArray() As Variant Dim l_arrTmp() As Variant Dim l_NbDim As Byte Dim i As Integer Dim j As Integer
l_NbDim = ArrayDimNumber(pArray2D) If (l_NbDim < 2) Then ReDim l_DataArray(UBound(pArray2D, l_NbDim)) For i = 0 To UBound(pArray2D, 1) Redim l_ArrTmp(UBound(pArray2D, 2)) For j = 0 To UBound(pArray2D, 2) l_ArrTmp(j) = pArray2D(i, j) Next l_DataArray(i) = l_ArrTmp() Next End If Array2DToDataArray = l_DataArray() End Function |
ArrayPrim |
Arrays |
ArrayDimCount |
Basic |
|
94 |
26 |
Function ArrayDimCount(ByRef pArray As Variant) As Integer
Dim i As Integer Dim l_Result As Integer On Local Error Goto ErrHandler i = 0 If Not IsEmpty(pArray) Then Do i = i + 1 l_Result = UBound(pArray, i) Loop Until (Err <> 0) End If ErrHandler: ArrayDimCount = i - 1 End Function |
ArrayPrim |
Arrays |
ArrayExists |
Basic |
ClearRanges (Procedure) GetRange (Procedure) UpdateRangeMultiColumnValues (Procedure) UpdateRangeMultiColumnValuesArray (Procedure) |
121 |
21 |
Function ArrayExists(ByRef pArray As Variant) As Boolean
Dim l_Exists As Boolean
l_Exists = Not IsNull(pArray) If l_Exists Then l_Exists = IsArray(pArray) If l_Exists Then l_Exists = (UBound(pArray) >= LBound(pArray)) End If End If ArrayExists = l_Exists End Function |
ArrayPrim |
Arrays |
ArrayIsEmpty |
Basic |
FolderIsEmpty (Procedure) |
143 |
16 |
Function ArrayIsEmpty(ByRef pArray() As Variant, Optional pDim As Byte) As Boolean
Dim l_Dim As Integer
If IsMissing(pDim) Then l_Dim = 1 Else l_Dim = pDim If (l_Dim < 1) Then l_Dim = 1 End If ArrayIsEmpty = (UBound(pArray, l_Dim) = -1) And (LBound(pArray, l_Dim) = 0) End Function |
ArrayPrim |
Arrays |
ConcatVectors |
Basic |
_ConcatVectorsTest (Procedure) |
160 |
33 |
Function ConcatVectors(ByRef pVectors As Variant) As Variant
Dim l_OutVector As Variant Dim l_Dims As Variant Dim l_Dim As Long Dim l_Offset As Long Dim i As Long Dim j As Long ReDim l_Dims(UBound(pVectors)) For i = 0 To UBound(pVectors) l_Dims(i) = UBound(pVectors(i)) l_Dim = l_Dim + l_Dims(i) + 1 Next i ReDim l_OutVector(l_Dim - 1) j = 0 l_Offset = 0 For i = 0 To UBound(pVectors) For j = 0 To l_Dims(i) l_OutVector(l_Offset + j) = pVectors(i)(j) Next j l_Offset = l_Offset + l_Dims(i) + 1 Next i ConcatVectors = l_OutVector End Function |
ArrayPrim |
Arrays |
DataArrayToArray2D |
Basic |
|
209 |
44 |
Function DataArrayToArray2D(ByRef pDataArray() As Variant, Optional pIgnoreEmpty As Boolean) As Variant
Dim l_OutArray As Variant Dim l_Dim1 As Long Dim l_Dim2 As Long Dim i As Long Dim j As Long If IsMissing(pIgnoreEmpty) Then pIgnoreEmpty = True
l_Dim1 = UBound(pDataArray) l_Dim2 = UBound(pDataArray(1)) If (l_Dim2 = 0) Then ReDim l_OutArray(l_Dim1) Else ReDim l_OutArray(l_Dim1, l_Dim2) End If For i = LBound(pDataArray) To l_Dim1 If Not pIgnoreEmpty Or (pDataArray(i)(0) <> "") Then For j = LBound(pDataArray(1)) To l_Dim2 l_OutArray(i, j) = pDataArray(i)(j) Next Else Exit For End If Next
If pIgnoreEmpty Then If (l_Dim2 = 0) Then ReDim Preserve l_OutArray(i-1) Else ReDim Preserve l_OutArray(i-1, l_Dim2) End If End If
DataArrayToArray2D = l_OutArray End Function |
ArrayPrim |
Arrays |
QuickSort |
Basic |
QuickSort2 (Procedure) Median (Procedure) |
254 |
63 |
Sub QuickSort(ByRef pArray() As Variant, Optional pFrom As Long, Optional pTo as Long) Dim l_Pivot Dim l_Lo Dim l_Hi Dim l_Tmp If IsMissing(pFrom) Then pFrom = LBound(pArray()) If IsMissing(pTo) Then pTo = UBound(pArray())
If (pTo - pFrom = 1) Then If pArray(pFrom) > pArray(pTo) Then l_Tmp=pArray(pFrom) pArray(pFrom) = pArray(pTo) pArray(pTo) = l_Tmp End If Exit Sub End If l_Pivot = pArray(Int((pFrom + pTo) / 2)) pArray(int((pFrom + pTo) / 2)) = pArray(pFrom) pArray(pFrom) = l_Pivot l_Lo = pFrom + 1 l_Hi = pTo Do While (l_Lo < l_Hi) And (pArray(l_Lo) <= l_Pivot) l_Lo = l_Lo + 1 Wend
While pArray(l_Hi) > l_Pivot l_Hi = l_Hi - 1 Wend
If l_Lo < l_Hi Then l_Tmp = pArray(l_Lo) pArray(l_Lo) = pArray(l_Hi) pArray(l_Hi) = l_Tmp End If Loop While (l_Lo < l_Hi) pArray(pFrom) = pArray(l_Hi) pArray(l_Hi) = l_Pivot If (pFrom < (l_Hi - 1)) Then QuickSort(pArray, pFrom, l_Hi-1) If ((l_Hi + 1) < pTo) Then QuickSort(pArray, l_Hi+1, pTo) End Sub |
ArrayPrim |
Arrays |
QuickSort2 |
Basic |
|
318 |
42 |
Sub QuickSort2(ByRef pArray As Variant, Optional pFrom As Long, Optional pTo As Long)
Dim i As Long Dim j As Long Dim l_Part As Variant Dim l_From As Long Dim l_To As Long If IsMissing(pFrom) Then l_From = LBound(pArray()) Else l_From = pFrom End If
If IsMissing(pTo) Then l_To = UBound(pArray()) Else l_To = pTo End If While (l_To > l_From) i = l_From j = l_To l_Part = pArray(l_From) While (i < j) While (pArray(j) > l_Part) j = j - 1 Wend pArray(i) = pArray(j) While ((i < j) And pArray(i) <= l_Part) i = i + 1 Wend pArray(j) = pArray(i) Wend pArray(i) = l_Part QuickSort(pArray, l_From, i - 1) l_From = i + 1 Wend End Sub |
ArrayPrim |
Arrays |
ReverseVector |
Basic |
|
361 |
21 |
Function ReverseVector(ByRef pVector As Variant) As Variant
Dim i As Long Dim j As Long Dim l_Last As Long Dim l_Half As Long
l_Last = UBound(pVector) l_Half = Int(l_Last / 2)
For i = 0 To l_Half SwapValues(pVector(i), pVector(l_Last - i)) Next i ReverseVector = pVector End Function |
ArrayPrim |
Arrays |
ShellSort |
Basic |
|
383 |
31 |
Sub ShellSort(ByRef pArray() As Variant) Dim l_Total As Long Dim l_Offset As Long Dim l_Limit As Long Dim l_Swap As Boolean Dim i As Long Dim l_Tmp As Variant
l_Total = UBound(pArray()) - LBound(pArray() + 1 l_Offset = l_Total / 2 Do While (l_Offset > 0) l_Limit = l_Total - l_Offset Do l_Swap = False For i = 0 To l_Limit If (pArray(i) > pArray(i + l_Offset)) Then SwapValues(pArray(i), pArray(i + l_Offset)) l_Tmp = pArray(i) pArray(i) = pArray(i + l_Offset) pArray(i + l_Offset) = l_Tmp l_Swap = True l_Limit = i - l_Offset End If Next Loop While l_Swap l_Offset = l_Offset / 2 Loop End Sub |
ArrayPrim |
Arrays |
SortVectorBubble |
Basic |
|
415 |
37 |
Function SortVectorBubble(ByRef pVector As Variant, Optional ByRef pAsc As Boolean) Dim l_Max As Long Dim nn As Long Dim j As Long If IsMissing(pAsc) Then pAsc = True l_Max = UBound(pVector) Do nn = -1 For j = LBound(pVector) to l_Max - 1 If pAsc Then If (pVector(j) > pVector(j + 1)) Then SwapValues(pVector(j), pVector(j + 1)) End If Else If (pVector(j) < pVector(j + 1)) Then SwapValues(pVector(j), pVector(j + 1)) End If End If nn = j Next j l_Max = nn Loop Until nn = -1
SortVectorBubble = pVector End Function |
ArrayPrim |
Arrays |
StringPosInArray |
Basic |
|
453 |
34 |
Function StringPosInArray(ByRef pArray() As String, pStr as String, Optional pCompare as Integer) as Long
Dim l_Max As Long Dim l_Compare As Integer Dim l_Pos As Long Dim i as Long l_Pos = -1 If IsMissing(pCompare) Then l_Compare = 1 Else If (pCompare < 0) Or (pCompare > 1) Then l_Compare = 1 Else l_Compare = pCompare End If End If l_Max = UBound(pArray()) For i = 0 To l_Max If (InStr(1, pArray(i), pStr, l_Compare) <> 0) Then l_Pos = i Exit For End If Next StringPosInArray() = l_Pos End Function |
ArrayPrim |
Arrays |
SwapValues |
Basic |
ReverseVector (Procedure) ShellSort (Procedure) SortVectorBubble (Procedure) VectorFromStringNums (Procedure) |
488 |
12 |
Sub SwapValues(ByRef pVal1 As Variant, pVal2 As Variant)
Dim l_Tmp As Variant l_Tmp = pVal1 pVal1 = pVal2 pVal2 = l_Tmp End Sub |
ArrayPrim |
Arrays |
VectorFromStringNums |
Basic |
_TestVectorFromStringNums (Procedure) |
501 |
58 |
Function VectorFromStringNums(ByRef pInputStr As String, pSepChar As String, pRangeChar As String, pAsLongs As Boolean) As Variant
Dim l_Array As Variant Dim l_AllStr As String Dim l_ItemStr As String Dim i As Long Dim j As Long Dim l_Pos As Long Dim l_Min As Long Dim l_Max As Long If (Trim(pSepChar) <> "") Or (Trim(pRangeChar) <> "") Then l_AllStr = "" l_Array = Split(pInputStr, pSepChar) For i = 0 To UBound(l_Array) l_ItemStr = Trim(l_Array(i)) l_Pos = InStr(l_ItemStr, pRangeChar) If (l_Pos > 1) Then l_Min = CLng(Left(l_ItemStr, l_Pos - 1)) l_Max = CLng(Right(l_ItemStr, Len(l_ItemStr) - l_Pos)) If (l_Max < l_Min) Then SwapValues(l_Min, l_Max) For j = l_Min To l_Max l_AllStr = l_AllStr & CStr(j) & Chr(13) Next j Else l_AllStr = l_AllStr & l_ItemStr & Chr(13) End If Next i If (l_AllStr <> "") Then l_AllStr = Left(l_AllStr, Len(l_AllStr) - 1) l_Array = Split(l_AllStr, Chr(13)) If pAsLongs Then For i = 0 To UBound(l_Array) l_Array(i) = CLng(l_Array(i)) Next i End If End If End If VectorFromStringNums = l_Array End Function |
ArrayPrim |
Arrays |
VectorToDataArray |
Basic |
_VectorToDataArrayTest (Procedure) |
570 |
29 |
Function VectorToDataArray(ByRef pVector As Variant, Optional pRaw As Boolean) As Variant
Dim i As Integer Dim l_Arr0 As Variant Dim l_DataArray As Variant Dim l_Data As Variant If IsMissing(pRaw) Then pRaw = True
l_DataArray = Array(pVector) If Not pRaw Then For i = 0 To UBound(pVector) l_Data = l_DataArray(0)(i) If Not pRaw And IsEmpty(l_Data) Then l_Data = "" l_DataArray(0)(i) = l_Data Next i End If VectorToDataArray = l_DataArray End Function |
CalcPrim |
Document |
SecureCalcUI |
Basic |
|
35 |
29 |
Sub SecureCalcUI(ByRef pSecure As Boolean, Optional ByRef pDoc As Object)
Static l_IsSecured As Boolean
If IsMissing(pDoc) Then pDoc = ThisComponent
If pSecure Then If Not l_IsSecure Then pDoc.lockControllers pDoc.addActionLock l_IsSecure = True End If Else If l_IsSecure Then pDoc.removeActionLock pDoc.unlockControllers l_IsSecure = False End If End If
End Sub |
CalcPrim |
Functions |
_CalcFuncRange |
Basic |
CalcFunc_CountIf (Procedure) CalcFunc_Match (Procedure) CalcFunc_VLookup (Procedure) |
40 |
14 |
Function _CalcFuncRange(ByRef pRange As Object) As Object
Dim lo_Range As Object
If pRange.SupportsService("com.sun.star.sheet.SheetCellRange") Then lo_Range = pRange ElseIf pRange.SupportsService("com.sun.star.sheet.NamedRange") Then lo_Range = pRange.ReferredCells End If
_CalcFuncRange = lo_Range End Function |
CalcPrim |
Functions |
CalcFunc_CountIf |
Basic |
|
57 |
25 |
Function CalcFunc_CountIf(ByRef pRange As Object, pCriterion As Variant) As Variant
Dim lo_FuncAccess As Object Dim lo_Range As Object Dim l_Result As Variant l_Result = Null lo_Range = _CalcFuncRange(pRange)
On Local Error Goto ErrHandler lo_FuncAccess = CreateUnoService(SERV_SPREADFUNC) l_Result = lo_FuncAccess.callFunction("COUNTIF", Array(lo_Range, pCriterion))
ErrHandler: CalcFunc_CountIf = l_Result End Function |
CalcPrim |
Functions |
CalcFunc_FilterXML |
Basic |
|
83 |
21 |
Function CalcFunc_FilterXML(ByRef pXMLdoc As String, pXPath As String) As Variant
Dim lo_FuncAccess As Object Dim l_Result As Variant l_Result = Null On Local Error Goto ErrHandler lo_FuncAccess = CreateUnoService(SERV_SPREADFUNC) l_Result = lo_FuncAccess.callFunction("FILTERXML", Array(pXMLdoc, pXPath))
ErrHandler: CalcFunc_FilterXML = l_Result End Function |
CalcPrim |
Functions |
CalcFunc_Match |
Basic |
|
105 |
29 |
Function CalcFunc_Match(ByRef pSearch As Variant, pSelVector As Object, Optional pMode As Integer) As Long
Dim lo_FuncAccess As Object Dim lo_Range As Object Dim l_Result As Long l_Result = -1 If IsMissing(pMode) Then pMode = 1 lo_Range = _CalcFuncRange(pSelVector) On Local Error Goto ErrHandler lo_FuncAccess = CreateUnoService(SERV_SPREADFUNC) l_Result = lo_FuncAccess.callFunction("MATCH", Array(pSearch, lo_Range, pMode))
ErrHandler: CalcFunc_Match = l_Result End Function |
CalcPrim |
Functions |
CalcFunc_VLookup |
Basic |
|
135 |
28 |
Function CalcFunc_VLookup(ByRef pSearch As Variant, pSelRange As Object, pLookup As Integer, Optional pExact As Byte) As Variant
Dim lo_FuncAccess As Object Dim lo_Range As Object Dim l_Result As Variant l_Result = Null If IsMissing(pExact) Then pExact = 0 lo_Range = _CalcFuncRange(pSelRange)
On Local Error Goto ErrHandler lo_FuncAccess = CreateUnoService(SERV_SPREADFUNC) l_Result = lo_FuncAccess.callFunction("VLOOKUP", Array(pSearch, lo_Range, pLookUp, pExact))
ErrHandler: CalcFunc_VLookup = l_Result End Function |
CalcPrim |
Functions |
CalcFunc_WebService |
Basic |
|
164 |
20 |
Function CalcFunc_WebService(Byref pURI As String) As Variant
Dim lo_FuncAccess As Object Dim l_Result As Variant l_Result = Null On Local Error Goto ErrHandler lo_FuncAccess = CreateUnoService(SERV_SPREADFUNC) l_Result = lo_FuncAccess.callFunction("WEBSERVICE", Array(pURI))
ErrHandler: CalcFunc_WebService = l_Result End Function |
CalcPrim |
Functions |
GetCalcFunctionObject |
Basic |
|
185 |
9 |
Function GetCalcFunctionObject() As Object
Dim lo_CalcFunc As Object
lo_CalcFunc = CreateUnoService(SERV_SPREADFUNC) GetCalcFunctionObject = lo_CalcFunc End Function |
CalcPrim |
Functions |
GetI8NSpreadsheetFuncName |
Basic |
|
195 |
13 |
Function GetI8NSpreadsheetFuncName(ByRef pLocalName As String) As String
Dim l_Name As String l_Name = pLocalName GetI8NSpreadsheetFuncName = UCase(Trim(l_Name)) End Function |
CalcPrim |
Functions |
RunSpreadsheetFunction |
Basic |
|
209 |
30 |
Function RunSpreadsheetFunction(ByRef pFuncName As String, pArrParams() As Variant) As Variant
Dim l_Result As Variant Dim l_FuncName As String Dim lo_Func As Object l_Result = NULL l_FuncName = UCase(Trim(pFuncName)) If (l_FuncName <> "") Then lo_Func = CreateUnoService(SERV_SPREADFUNC) On Local Error Resume Next l_Result = lo_Func.callFunction(l_FuncName, pArrParams()) End If RunSpreadsheetFunction = l_Result End Function |
CalcPrim |
RangeCell |
ArrayFromVectorRangeName |
Basic |
|
63 |
39 |
Function ArrayFromVectorRangeName(ByRef pRangeName As String, Optional pIgnoreEmpty As Boolean, _ Optional ByRef pDoc As Object) As Variant
Dim lo_Range As Object Dim l_ArrData As Variant Dim l_Array As Variant Dim i As Long Dim j As Long If IsMissing(pIgnoreEmpty) Then pIgnoreEmpty = True If IsMissing(pDoc) Then pDoc = ThisComponent If pDoc.NamedRanges.hasByName(pRangeName) Then lo_Range = pDoc.NamedRanges.getByName(pRangeName) l_ArrData = lo_Range.ReferredCells.DataArray Redim l_Array(UBound(l_ArrData)) j = 0 For i = 0 To UBound(l_ArrData) If (l_ArrData(i)(0) <> "") Or Not pIgnoreEmpty Then l_Array(i) = l_ArrData(i)(0) j = j + 1 End If Next If pIgnoreEmpty Then Redim Preserve l_Array(j - 1) End If End If ArrayFromVectorRangeName = l_Array End Function |
CalcPrim |
RangeCell |
CalcValue |
Basic |
UpdateRangeMultiColumnValuesArray (Procedure) |
103 |
35 |
Function CalcValue(ByRef pValue As Variant) As Variant
Const CALC_DATAUNSUPP = 0
Dim l_Value As Variant
l_Value = pValue If (VarType(l_Value) = 7) Then l_Value = CDbl(l_Value) ElseIf (VarType(l_Value) = 11) Then l_Value = CInt(pValue) ElseIf (VarType(l_Value) = 9) Then If IsUnoStruct(l_Value) Then If (InStr(l_Value.Dbg_Properties, "com.sun.star.util.Date") > 0) Then l_Value = CDbl(CDateFromUnoDate(l_Value)) ElseIf (InStr(l_Value.Dbg_Properties, "com.sun.star.util.DateTime") > 0) Then l_Value = CDbl(CDateFromUnoDateTime(l_Value)) ElseIf (InStr(l_Value.Dbg_Properties, "com.sun.star.util.Duration") > 0) Then l_Value = CALC_DATAUNSUPP End If Else l_Value = CALC_DATAUNSUPP End If End If CalcValue = l_Value End Function |
CalcPrim |
RangeCell |
CellAddressFromReference |
Basic |
|
139 |
18 |
Function CellAddressFromReference(ByRef pCellRef As String, Optional ByRef pDoc As Object) As Object
Dim lo_Cell As Object Dim l_Address As Object If IsMissing(pDoc) Then pDoc = ThisComponent
On Local Error GoTo ErrHandler lo_Cell = pDoc.Sheets(0).getCellRangeByName(pCellRef) l_Address = lo_Cell.CellAddress
ErrHandler: CellAddressFromReference = l_Address End Function |
CalcPrim |
RangeCell |
ClearRange |
Basic |
ClearRangeContents (Procedure) |
158 |
44 |
Function ClearRange(ByRef pRange As Object, pMode As Integer, Optional pPwd As String) As Long
Dim lo_Sheet As Object Dim l_Protected As Boolean Dim l_Err As Long
l_Err = ERR_RANGE_NOEXEC If Not IsNull(pRange) Then If IsMissing(pPwd) Then pPwd = "" lo_Sheet = pRange.SpreadSheet l_Protected = lo_Sheet.isProtected
On Local Error Goto ErrHandler: If l_Protected Then lo_Sheet.unProtect(pPwd) pRange.ClearContents(pMode) If l_Protected Then lo_Sheet.protect(pPwd) l_Err = ERR_RANGE_OK Else l_Err = ERR_RANGE_UNK End If ErrHandler: If Err Then l_Err = Err ClearRange = l_Err End Function |
CalcPrim |
RangeCell |
ClearRangeContents |
Basic |
ClearRanges (Procedure) |
203 |
33 |
Function ClearRangeContents(ByRef pSheetRef As Variant, pRangeRef As Variant, pMode As Integer, Optional pPwd As String, Optional pDoc As Object) As Long
Dim lo_Range As Object Dim l_Err As Long
l_Err = ERR_RANGE_NOEXEC If IsMissing(pDoc) Then pDoc = ThisComponent If IsMissing(pPwd) Then pPwd = "" lo_Range = GetRange(pSheetRef, pRangeRef, pDoc) l_Err = ClearRange(lo_Range, pMode, pPwd) ClearRangeContents = l_Err End Function |
CalcPrim |
RangeCell |
ClearRanges |
Basic |
|
237 |
58 |
Function ClearRanges(ByRef pRangeInfo As Variant, pMode As Integer, Optional ByRef pDoc As Object, Optional pProgress As Object) As Long
Dim l_Err As Long Dim i As Integer l_Err = ERR_RANGE_NOEXEC If ArrayExists(pRangeInfo) Then If IsMissing(pDoc) Then pDoc = ThisComponent If IsMissing(pProgress) Then pProgress = Null For i = 0 To UBound(pRangeInfo) If Not IsNull(pProgress) Then pProgress.Text = pRangeInfo(i)(2) pProgress.Value = i + 1 End If l_Err = ClearRangeContents(pRangeInfo(i)(0), pRangeInfo(i)(2), pMode, pRangeInfo(i)(1), pDoc) If (l_Err <> 0) Then Exit For Next i Else l_Err = ERR_RANGE_ARRAY End If ClearRanges = l_Err End Function |
CalcPrim |
RangeCell |
ColumnIndexFromReference |
Basic |
|
296 |
26 |
Function ColumnIndexFromReference(ByRef pCellRef As String, Optional ByRef pDoc As Object) As Long
Dim lo_Cell As Object Dim l_Index As Long l_Index = -1 If IsMissing(pDoc) Then pDoc = ThisComponent
On Local Error GoTo ErrHandler lo_Cell = pDoc.Sheets(0).getCellRangeByName(pCellRef & "1") l_Index = lo_Cell.CellAddress.Column
ErrHandler: ColumnIndexFromReference = l_Index End Function |
CalcPrim |
RangeCell |
CopyUsedRange |
Basic |
|
323 |
51 |
Function CopyUsedRange(ByRef pSourceDoc As Object, pSourceSheetName As String, pTargetDoc As Object, pTargetSheetName As String, Optional ByRef pOrigin As String) As Long
Dim lo_SrcSheet As Object Dim lo_SrcRange As Object Dim lo_TgtSheet As Object Dim lo_TgtRange As Object Dim lo_Tferable As Object Dim l_Err As Long
l_Err = ERR_RANGE_NOEXEC lo_SrcSheet = GetSheet(pSourceSheetName) If Not IsNull(lo_SrcSheet) Then lo_TgtSheet = GetSheet(pTargetSheetName) If Not IsNull(lo_TgtSheet) Then lo_SrcRange = UsedRange(lo_SrcSheet) If IsNull(lo_SrcRange) Then l_Err = ERR_RANGE_NONE Else If IsMissing(pOrigin) Then pOrigin = CELL_ORIGIN pSourceDoc.CurrentController.select(lo_SrcRange) lo_Tferable = pSourceDoc.CurrentController.getTransferable() lo_TgtRange = lo_TgtSheet.getCellRangeByName(pOrigin) pTargetDoc.CurrentController.select(lo_TgtRange) pTargetDoc.CurrentController.insertTransferable(lo_Tferable) l_Err = ERR_RANGE_OK End If Else l_Err = ERR_RANGE_TGTSHEET End If Else l_Err = ERR_RANGE_SRCSHEET End If CopyUsedRange = l_Err End Function |
CalcPrim |
RangeCell |
CreateCalcRangeEnumerator |
Basic |
UpdateRangeColumnValues (Procedure) UpdateRangeMultiColumnValues (Procedure) |
375 |
17 |
Function CreateCalcRangeEnumerator(ByRef pRange As Object) As Object
Dim lo_Ranges As Object Dim lo_Enum As Object If Not IsNull(pRange) Then lo_Ranges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges") lo_Ranges.insertByName("MyRange", pRange) lo_Enum = lo_Ranges.Cells.CreateEnumeration End If CreateCalcRangeEnumerator = lo_Enum End Function |
CalcPrim |
RangeCell |
FetchInRangeColumn |
Basic |
|
393 |
35 |
Function FetchInRangeColumn(ByRef pSearch As Variant, pRange As Object, pSearchCol As Integer, pFetchCol As Integer) As Variant
Dim l_DataArray As Variant Dim l_Value As Variant Dim i As Long l_Value = Null On Local Error Goto ErrHandler l_DataArray = pRange.DataArray For i = 0 To UBound(l_DataArray) If (l_DataArray(i)(pSearchCol) = pSearch) Then l_Value = l_DataArray(i)(pFetchCol) Exit For End If Next i
ErrHandler: If IsNull(l_Value) Then l_Value = pSearch End If
FetchInRangeColumn = l_Value End Function |
CalcPrim |
RangeCell |
FormatRange |
Basic |
|
429 |
45 |
Function FormatRange(ByRef pRange As Object, pFormatStr As String, Optional pIsTemp As Boolean, Optional pDoc As Object) As Long
Dim lo_Formats As Object Dim l_Loc As New com.sun.star.lang.Locale Dim l_ID As Long Dim l_IsNew As Boolean Dim l_Err As Long l_Err = 0
If IsMissing(pIsTemp) Then pIsTemp = True If IsMissing(pDoc) Then pDoc = ThisComponent
On Local Error Goto ErrHandler
lo_Formats = pDoc.NumberFormats l_ID = lo_Formats.queryKey(pFormatStr, l_Loc, False) If (l_ID < 0) Then l_ID = lo_Formats.addNew(pFormatStr, l_Loc) l_IsNew = True End If pRange.NumberFormat = l_ID If pIsTemp And l_IsNew Then lo_Formats.removeByKey(l_ID) End If ErrHandler: If Err Then l_Err = Err
FormatRange = l_Err End Function |
CalcPrim |
RangeCell |
GetAdjustedRange |
Basic |
|
475 |
19 |
Function GetAdjustedRange(ByRef pRefRange As Object, pTopLeftCell As Object) As Object
Dim lo_AdjRange As Object If Not IsNull(pTopLeftCell) And Not IsNull(pRefRange) Then lo_AdjRange = pTopLeftCell.SpreadSheet.getCellRangeByPosition(pTopLeftCell.CellAddress.Column, _ pTopLeftCell.CellAddress.Row, _ pTopLeftCell.CellAddress.Column + pRefRange.Columns.Count - 1, _ pTopLeftCell.CellAddress.Row + pRefRange.Rows.Count -1) End If GetAdjustedRange = lo_AdjRange End Function |
CalcPrim |
RangeCell |
GetDataArea |
Basic |
|
495 |
42 |
Function GetDataArea(ByRef pDoc As Object, pSheetRef As Variant, Optional pTopLeftCellAddr As Variant) As Object
Dim lo_Dispatch As Object Dim lo_TLCell As Object Dim lo_Sheet As Object Dim lo_DataRange As Object lo_Sheet = _GetSheet(pSheetRef, pDoc) If Not IsNull(lo_Sheet) Then If IsMissing(pTopLeftCellAddr) Then lo_TLCell = lo_Sheet.getCellRangeByName("A1") Else lo_TLCell = lo_Sheet.getCellRangeByPosition(pTopLeftCellAddr.StartColumn, pTopLeftCellAddr.StartRow, _ pTopLeftCellAddr.EndColumn, pTopLeftCellAddr.EndRow) End If pDoc.CurrentController.select(lo_TLCell) lo_Dispatch = createUnoService("com.sun.star.frame.DispatchHelper") lo_Dispatch.executeDispatch(pDoc.CurrentController.Frame, ".uno:SelectData", "", 0, Array()) lo_DataRange = pDoc.currentSelection End If GetDataArea = lo_DataRange End Function |
CalcPrim |
RangeCell |
GetNamedCell |
Basic |
GetNamedCellString (Procedure) GetNamedCellValue (Procedure) SetNamedCellValue (Procedure) |
538 |
26 |
Function GetNamedCell(ByRef pName As String, Optional ByRef pDoc As Object) As Object
Dim lo_Doc As Object Dim lo_Ranges As Object Dim lo_Range As Object Dim lo_Cell As Object Dim l_CellType As Integer If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Ranges = pDoc.NamedRanges If lo_Ranges.hasByName(pName) Then lo_Range = lo_Ranges.getByName(pName) l_CellType = GetRangeType(lo_Range) If (l_CellType = RANGETYPE_CELL) Or (l_CellType = RANGETYPE_RANGE) Or (l_CellType = RANGETYPE_NAMED) Then lo_Cell = lo_Range(0) End If End If GetNamedCell = lo_Cell End Function |
CalcPrim |
RangeCell |
GetNamedCellString |
Basic |
|
565 |
20 |
Function GetNamedCellString(ByRef pName As String, Optional ByRef pDoc As Object) As String
Dim lo_Cell As Object Dim l_Str As String l_Str = "" If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Cell = GetNamedCell(pName, pDoc) If Not IsNull(lo_Cell) Then l_Str = lo_Cell.ReferredCells.String End If
GetNamedCellString = l_Str End Function |
CalcPrim |
RangeCell |
GetNamedCellValue |
Basic |
|
586 |
20 |
Function GetNamedCellValue(ByRef pName As String, Optional ByRef pDoc As Object) As Variant
Dim lo_Cell As Object Dim l_Value As Variant l_Value = Null If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Cell = GetNamedCell(pName, pDoc) If Not IsNull(lo_Cell) Then l_Value = lo_Cell.ReferredCells.Value End If
GetNamedCellValue = l_Value End Function |
CalcPrim |
RangeCell |
GetNamedRange |
Basic |
ShowColumns (Procedure) ShowRows (Procedure) |
607 |
22 |
Function GetNamedRange(ByRef pSheetName As String, pRangeName As String, Optional ByRef pDoc As Object) As Object
Dim lo_Sheet As Object Dim lo_Range As Object If IsMissing(pDoc) Then pDoc = ThisComponent
If pDoc.Sheets.hasByName(pSheetName) Then lo_Sheet = pDoc.Sheets.getByName(pSheetName) On Local Error Resume Next lo_Range = lo_Sheet.getCellRangeByName(pRangeName) End If
GetNamedRange = lo_Range End Function |
CalcPrim |
RangeCell |
GetRange |
Basic |
ClearRangeContents (Procedure) |
630 |
64 |
Function GetRange(Optional pRangeRef As Variant, Optional ByRef pSheetRef As Variant, Optional pDoc As Object) As Object
Dim lo_Sheet As Object Dim lo_Range As Object
If IsMissing(pDoc) Then pDoc = ThisComponent If IsMissing(pSheetRef) Then lo_Sheet = pDoc.CurrentController.ActiveSheet Else lo_Sheet = GetSheet(pSheetRef, pDoc) End If If Not IsNull(lo_Sheet) Then If IsMissing(pRangeRef) Then lo_Range = GetActiveRange(pDoc) ElseIf (VarType(pRangeRef) = 8) Then On Local Error Resume Next lo_Range = lo_Sheet.GetCellRangeByName(pRangeRef) ElseIf IsArray(pRangeRef) Then If ArrayExists(pRangeRef) Then If (UBound(pRangeRef) = 3) Then On Local Error Resume Next lo_Range = lo_Sheet.getCellRangeByPosition(pRangeRef(0), pRangeRef(1), pRangeRef(2), pRangeRef(3)) End If End If ElseIf IsUnoStruct(pRangeRef) Then If (InStr(pRangeRef.Dbg_Properties, "com.sun.star.table.CellRangeAddress") > 0) Then lo_Range = lo_Sheet.getCellRangeByPosition(pRangeRef.StartColumn, pRangeRef.StartRow, pRangeRef.EndColumn, pRangeRef.EndRow) End If ElseIf (VarType(pRangeRef) = 9) Then lo_Range = pRangeRef End If End If GetRange = lo_Range End Function |
CalcPrim |
RangeCell |
GetRangeColumn |
Basic |
GetRangeRow (Procedure) |
695 |
15 |
Function GetRangeColumn(ByRef pRange As Object, pColNum As Integer) As Object
Dim lo_Column As Object lo_Column = pRange.getCellRangeByPosition(pColNum - 1, 0, pColNum - 1, pRange.Rows.Count - 1)
GetRangeColumn = lo_Column End Function |
CalcPrim |
RangeCell |
GetRangeFromColumns |
Basic |
|
711 |
22 |
Function GetRangeFromColumns(ByRef pSheet As Object, pStartColumn As Integer, Optional pEndColumn As Integer) As Object
Dim lo_Cursor As Object Dim lo_Range As Object If IsMissing(pEndColumn) Then pEndColumn = pStartColumn lo_Range = pSheet.getCellRangeByPosition(pStartColumn, 0, pEndColumn, 0) lo_Cursor = pSheet.createCursorByRange(lo_Range) lo_Cursor.expandToEntireColumns() GetRangeFromColumns = lo_Cursor End Function |
CalcPrim |
RangeCell |
GetRangeFromRows |
Basic |
|
734 |
22 |
Function GetRangeFromRows(ByRef pSheet As Object, pStartRow As Integer, Optional pEndRow As Integer) As Object
Dim lo_Cursor As Object Dim lo_Range As Object If IsMissing(pEndCol) Then pEndRow = pStartRow lo_Range = pSheet.getCellRangeByPosition(0, pStartRow, 0, pEndRow) lo_Cursor = pSheet.createCursorByRange(lo_Range) lo_Cursor.expandToEntireRows() GetRangeFromRows = lo_Cursor End Function |
CalcPrim |
RangeCell |
GetRangeRow |
Basic |
|
757 |
15 |
Function GetRangeRow(ByRef pRange As Object, pRowNum As Integer) As Object
Dim lo_Row As Object lo_Row = pRange.getCellRangeByPosition(0, pRowNum - 1, pRange.Columns.Count - 1, pRowNum - 1)
GetRangeColumn = lo_Row End Function |
CalcPrim |
RangeCell |
GetRangeType |
Basic |
GetNamedCell (Procedure) |
773 |
27 |
Function GetRangeType(ByRef pRange As Object) As Integer Dim l_Type As Integer If IsNull(pRange) Then l_Type = RANGETYPE_NULL ElseIf IsMultiRange(pRange) Then l_Type = RANGETYPE_RANGES ElseIf IsSingleCell(pRange) Then l_Type = RANGETYPE_CELL ElseIf IsSingleRange(pRange) Then l_Type = RANGETYPE_RANGE ElseIf IsNamedRange(pRange) Then l_Type = RANGETYPE_NAMED Else l_Type = RANGETYPE_UNK End If GetRangeType = l_Type End Function |
CalcPrim |
RangeCell |
GotoLastCell |
Basic |
|
801 |
22 |
Sub GotoLastCell(ByRef pSheet As Object, pSearchColNum As Integer, pColNum As Integer, Optional ByRef pDoc As Object)
Dim lo_Cell As Object Dim l_RowNum As Long If IsMissing(pDoc) Then pDoc = ThisComponent l_RowNum = LastRowIndex(pSearchColNum, pSheet) If (l_RowNum > -1) Then lo_Cell = pSheet.getCellByPosition(pColNum, l_RowNum) pDoc.CurrentController.select(lo_Cell) End If End Sub |
CalcPrim |
RangeCell |
IsMultiRange |
Basic |
GetRangeType (Procedure) |
824 |
4 |
Function IsMultiRange(ByRef pRange As Object) As Boolean IsMultiRange = pRange.supportsService(SERV_CELLRANGES) End Function |
CalcPrim |
RangeCell |
IsNamedRange |
Basic |
GetRangeType (Procedure) |
829 |
4 |
Function IsNamedRange(ByRef pRange As Object) As Boolean IsNamedRange = pRange.supportsService(SERV_NAMEDRANGE) End Function |
CalcPrim |
RangeCell |
IsRangeInRange |
Basic |
IsRangeInRanges (Procedure) |
834 |
38 |
Function IsRangeInRange(ByRef pInnerRange As Object, pOuterRange As Object) As Boolean
Dim lo_InnerRange As Object Dim lo_OuterRange As Object Dim l_StartCol As Long Dim l_EndCol As Long Dim l_StartRow As Long Dim l_EndRow As Long Dim l_OK As Boolean
l_OK = False If Not IsNull(pOuterRange) And Not IsNull(pInnerRange) Then lo_OuterRange = RangeAsSheetCellRange(pOuterRange) lo_InnerRange = RangeAsSheetCellRange(pInnerRange)
With lo_OuterRange.rangeAddress l_StartCol = .startColumn l_EndCol = .endColumn l_StartRow = .startRow l_EndRow = .endRow End With With lo_InnerRange.rangeAddress l_OK = (l_StartCol <= .startColumn) And (l_EndCol >= .endColumn) _ And (l_StartRow <= .startRow) And (l_EndRow >= .endRow) End With End If
IsRangeInRange = l_OK End Function |
CalcPrim |
RangeCell |
IsRangeInRanges |
Basic |
|
873 |
24 |
Function IsRangeInRanges(ByRef pInnerRange As Object, pOuterRanges As Variant) As Integer
Dim l_OK As Boolean Dim l_Index As Integer Dim i As Integer l_Index = -1 If Not IsNull(pOuterRanges) And Not IsNull(pInnerRange) Then For i = 0 To UBound(pOuterRanges) If IsRangeInRange(pInnerRange, pOuterRanges(i)) Then l_Index = i Exit For End If Next i End If
IsRangeInRanges = l_Index End Function |
CalcPrim |
RangeCell |
IsSingleCell |
Basic |
GetRangeType (Procedure) |
898 |
4 |
Function IsSingleCell(ByRef pRange As Object) As Boolean IsSingleCell = pRange.supportsService(SERV_CELL) End Function |
CalcPrim |
RangeCell |
IsSingleRange |
Basic |
GetRangeType (Procedure) |
903 |
4 |
Function IsSingleRange(ByRef pRange As Object) As Boolean IsSingleRange = pRange.supportsService(SERV_CELLRANGE) End Function |
CalcPrim |
RangeCell |
PasteSpecial |
Basic |
|
908 |
54 |
Sub PasteSpecial(ByRef pSrcDoc As Object, pSrcRange As Object, pTgtDoc As Object, pTgtRange As Object)
Dim lo_Dispatch As Object lo_Dispatch = createUnoService("com.sun.star.frame.DispatchHelper")
pSrcDoc.CurrentController.select(pSrcRange) lo_Dispatch.executeDispatch(pSrcDoc.CurrentController.Frame, ".uno:Copy", "", 0, Array()) pTgtDoc.CurrentController.select(pTgtRange) dim args1(5) as new com.sun.star.beans.PropertyValue args1(0).Name = "Flags" args1(0).Value = "SVD" args1(1).Name = "FormulaCommand" args1(1).Value = 0 args1(2).Name = "SkipEmptyCells" args1(2).Value = False args1(3).Name = "Transpose" args1(3).Value = False args1(4).Name = "AsLink" args1(4).Value = False args1(5).Name = "MoveMode" args1(5).Value = 4 lo_Dispatch.executeDispatch(pTgtDoc.CurrentController.Frame, ".uno:InsertContents", "", 0, args1()) End Sub |
CalcPrim |
RangeCell |
PasteTransferable |
Basic |
|
963 |
18 |
Sub PasteTransferable(ByRef pSrcDoc As Object, pSrcRange As Object, pTgtDoc As Object, pTgtRange As Object)
Dim lo_Tfer As Object pSrcDoc.CurrentController.select(pSrcRange) lo_Tfer = pSrcDoc.CurrentController.getTransferable() pTgtDoc.CurrentController.select(pTgtRange) pTgtDoc.CurrentController.insertTransferable(lo_Tfer) End Sub |
CalcPrim |
RangeCell |
RangeAddressFromReference |
Basic |
|
982 |
24 |
Function RangeAddressFromReference(ByRef pRangeRef As String, Optional ByRef pDoc As Object) As Object
Dim lo_Range As Object Dim l_Address As Variant If IsMissing(pDoc) Then pDoc = ThisComponent
On Local Error GoTo ErrHandler lo_Range = pDoc.Sheets(0).getCellRangeByName(pRangeRef) l_Address = lo_Range.RangeAddress
ErrHandler: RangeAddressFromReference = l_Address End Function |
CalcPrim |
RangeCell |
RangeAddrString |
Basic |
|
1007 |
25 |
Function RangeAddrString(ByRef pDocument As Object, pRangeAddr As Object) As String
Dim lo_Range As Object Dim l_Str As String On Local Error GoTo OffLimit l_Str = "" lo_Range = pDocument.Sheets(pRangeAddr.Sheet).getCellRangeByPosition(pRangeAddr.StartColumn, pRangeAddr.StartRow, pRangeAddr.EndColumn, pRangeAddr.EndRow) l_Str = Join(Split(lo_Range.AbsoluteName, "$"), "") GoTo Finally OffLimit: err = 14 Finally: RangeAddrString = l_Str
End Function |
CalcPrim |
RangeCell |
RangeAsSheetCellRange |
Basic |
IsRangeInRange (Procedure) |
1033 |
21 |
Function RangeAsSheetCellRange(ByRef pRange As Object) As Object
Dim lo_Range As Object
If pRange.SupportsService("com.sun.star.sheet.SheetCellRange") Then lo_Range = pRange ElseIf pRange.SupportsService("com.sun.star.sheet.NamedRange") Then lo_Range = pRange.ReferredCells Else lo_Range = Nothing End If
RangeAsSheetCellRange = lo_Range End Function |
CalcPrim |
RangeCell |
SetActiveCellByName |
Basic |
|
1055 |
25 |
Function SetActiveCellByName(ByRef pCellName As String, ByRef pSheetName As String, Optional ByRef pDoc As Object) As Object
Dim lo_Sheet As Object Dim lo_Range As Object lo_Range = Nothing If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Sheet = SetActiveSheetByName(pSheetName, pDoc) If Not IsNull(lo_Sheet) Then On Local Error Resume Next lo_Range = lo_Sheet.getCellRangeByName(pCellName) If Not Err Then pDoc.CurrentController.select(lo_Range) End If End If SetActiveCellByName = lo_Range End Function |
CalcPrim |
RangeCell |
SetActiveSheetByName |
Basic |
SetActiveCellByName (Procedure) |
1081 |
23 |
Function SetActiveSheetByName(ByRef pSheetName As String, Optional pDoc As Object) As Object
Dim lo_Sheet As Object lo_Sheet = Nothing If IsMissing(pDoc) Then pDoc = ThisComponent
If pDoc.Sheets.hasByName(pSheetName) Then lo_Sheet = pDoc.Sheets.getByName(pSheetName) If Not (pDoc.CurrentController.ActiveSheet.Name = pSheetName) Then pDoc.CurrentController.ActiveSheet = lo_Sheet End If End If SetActiveSheetByName = lo_Sheet End Function |
CalcPrim |
RangeCell |
SetNamedCellValue |
Basic |
|
1105 |
18 |
Sub SetNamedCellValue(ByRef pName As String, pValue As Variant, Optional ByRef pDoc As Variant)
Dim lo_Cell As Object If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Cell = GetNamedCell(pName, pDoc) If Not IsNull(lo_Cell) Then lo_Cell.ReferredCells.Value = pValue End If
End Sub |
CalcPrim |
RangeCell |
ShiftRange |
Basic |
|
1124 |
26 |
Function ShiftRange(ByRef pOldRange As Object, pNewTLCell As Object) As Object
Dim lo_Sheet As Object Dim lo_NewRange As Object Dim l_RangeWidth As Long Dim l_RangeHeight As Long
l_RangeWidth = pOldRange.RangeAddress.EndColumn - pOldRange.RangeAddress.StartColumn l_RangeHeight = pOldRange.RangeAddress.EndRow - pOldRange.RangeAddress.StartRow lo_Sheet = pNewTLCell.Spreadsheet
On Local Error Resume Next lo_NewRange = lo_Sheet.getCellRangeByPosition(pNewTLCell.CellAddress.Column, pNewTLCell.CellAddress.Row, _ pNewTLCell.CellAddress.Column + l_RangeWidth, pNewTLCell.CellAddress.Row + l_RangeHeight)
ShiftRange = lo_NewRange End Function |
CalcPrim |
RangeCell |
UpdateRangeColumnValues |
Basic |
|
1151 |
62 |
Function UpdateRangeColumnValues(ByRef pSearch As Variant, pRange As Object, pLookupIndex As Integer, pUpdateIndex As Integer, pValue As Variant) As Long
Dim lo_Column As Object Dim lo_CurCell As Object Dim lo_TgtCell As Object Dim lo_Enum As Object Dim l_Result As Long Dim i As Long Dim l_Err As Long If ((pLookupIndex > 0) And (pLookupIndex <= pRange.Columns.Count)) _ And ((pUpdateIndex > 0) And (pUpdateIndex <= pRange.Columns.Count)) Then l_Err = ERR_RANGE_OK On Local Error Goto ErrHandler lo_Column = pRange.getCellRangeByPosition(pLookupIndex - 1, 0, pLookupIndex - 1, pRange.Rows.Count - 1) lo_Enum = CreateCalcRangeEnumerator(lo_Column) If Not IsNull(lo_Enum) Then i = 0 Do While lo_Enum.hasMoreElements lo_CurCell = lo_Enum.NextElement If (lo_CurCell.Value = pSearch) Then lo_TgtCell = pRange.getCellByPosition(pUpdateIndex - 1, i) lo_TgtCell.Value = pValue End If i = i + 1 Loop Else l_Err = ERR_RANGE_ENUMERATOR End If Else l_Err = ERR_RANGE_OUTOFBOUNDS End If
ErrHandler: If Err Then l_Err = Err
UpdateRangeColumnValues = l_Err End Function |
CalcPrim |
RangeCell |
UpdateRangeMultiColumnValues |
Basic |
|
1214 |
116 |
Function UpdateRangeMultiColumnValues(ByRef pSearch As Variant, pRange As Object, pLookupIndex As Integer, pUpdateValues As Variant) As Long
Dim lo_Column As Object Dim lo_CurCell As Object Dim lo_TgtCell As Object Dim lo_Enum As Object Dim l_Result As Long Dim i As Long Dim j As Long Dim l_Err As Long Dim l_Index As Integer Dim l_Value As Variant Dim l_Mode As Integer Dim l_NOK As Boolean
l_Err = ERR_RANGE_OK
If Not ArrayExists(pUpdateValues) Then l_Err = ERR_RANGE_BADSRCARRAY ElseIf (pLookupIndex < 1) And (pLookupIndex > pRange.Columns.Count) Then l_Err = ERR_RANGE_OUTOFBOUNDS Else For i = 0 To UBound(pUpdateValues) l_Index = pUpdateValues(i)(0) l_NOK = (l_Index < 1) Or (l_Index > pRange.Columns.Count) If l_NOK Then l_Err = ERR_RANGE_OUTOFBOUNDS Exit For End If Next i End If
If (l_Err = 0) Then On Local Error Goto ErrHandler lo_Column = pRange.getCellRangeByPosition(pLookupIndex - 1, 0, pLookupIndex - 1, pRange.Rows.Count - 1) lo_Enum = CreateCalcRangeEnumerator(lo_Column) If Not IsNull(lo_Enum) Then i = 0 Do While lo_Enum.hasMoreElements lo_CurCell = lo_Enum.NextElement If (lo_CurCell.Value = pSearch) Then For j = 0 To UBound(pUpdateValues) lo_TgtCell = pRange.getCellByPosition(pUpdateValues(j)(0) - 1, i) l_Value = pUpdateValues(j)(1) l_Mode = pUpdateValues(j)(2) Select Case l_Mode Case com.sun.star.sheet.CellFlags.FORMULA lo_TgtCell.Formula = l_Value Case com.sun.star.sheet.CellFlags.VALUE lo_TgtCell.Value = l_Value Case com.sun.star.sheet.CellFlags.DATETIME lo_TgtCell.Value = CDbl(l_Value) Case com.sun.star.sheet.CellFlags.STRING lo_TgtCell.String = l_Value End Select Next j End If i = i + 1 Loop Else l_Err = ERR_RANGE_ENUMERATOR End If End If
ErrHandler: If Err Then l_Err = Err
UpdateRangeMultiColumnValues = l_Err End Function |
CalcPrim |
RangeCell |
UpdateRangeMultiColumnValuesArray |
Basic |
|
1331 |
88 |
Function UpdateRangeMultiColumnValuesArray(ByRef pSearch As Variant, pRange As Object, pLookupIndex As Integer, pUpdateValues As Variant) As Long
Dim i As Long Dim j As Long Dim l_Err As Long Dim l_RangeArray As Variant Dim l_Value As Variant Dim l_Value2 As Variant Dim l_Lookup As Variant Dim l_ColIndex As Long Dim l_NOK As Boolean
l_Err = 0
If Not ArrayExists(pUpdateValues) Then l_Err = -4 Else For i = 0 To UBound(pUpdateValues) l_ColIndex = pUpdateValues(i)(0) l_NOK = (l_ColIndex < 1) Or (l_ColIndex > pRange.Columns.Count) If l_NOK Then l_Err = -2 Exit For End If Next i End If
If (l_Err = 0) Then l_RangeArray = pRange.DataArray For i = 0 To UBound(l_RangeArray) - 1 l_Lookup = l_RangeArray(i)(pLookupIndex - 1) If (l_Lookup = pSearch) Then For j = 0 To UBound(pUpdateValues) l_Value = pUpdateValues(j)(1) l_Value = CalcValue(l_Value) l_RangeArray(i)(pUpdateValues(j)(0) - 1) = l_Value Next j End If Next i pRange.DataArray = l_RangeArray End If
ErrHandler: If Err Then l_Err = Err
UpdateRangeMultiColumnValuesArray = l_Err End Function |
CalcPrim |
RangeCell |
UsedRange |
Basic |
CopyUsedRange (Procedure) |
1420 |
21 |
Function UsedRange(ByRef pSheet As Object, Optional ByRef pOrigin As String) As Object
Dim lo_UsedRange As Object Dim lo_CellCur As Object If IsMissing(pOrigin) Then pOrigin = CELL_ORIGIN lo_CellCur = pSheet.createCursorByRange(pSheet.getCellRangeByName(pOrigin)) lo_CellCur.gotoEndOfUsedArea(True) lo_UsedRange = pSheet.getCellRangeByName(lo_CellCur.AbsoluteName)
UsedRange = lo_UsedRange End Function |
CalcPrim |
RangeCell |
VLookupCell |
Basic |
|
1442 |
34 |
Function VLookupCell(ByRef pSearch As Variant, pRange As Object, pLookupIndex As Integer, pMatchType As Integer) As Object
Dim lo_FuncAccess As Object Dim lo_Col As Object Dim lo_Cell As Object Dim l_Result As Long If ((pLookupIndex > 0) And (pLookupIndex <= pRange.Columns.Count)) Then lo_Col = pRange.getCellRangeByPosition(0, 0, 0, pRange.Rows.Count - 1) On Local Error Goto ErrHandler lo_FuncAccess = CreateUnoService(SERV_SPREADFUNC) l_Result = lo_FuncAccess.callFunction("MATCH", Array(pSearch, lo_Col, pMatchType)) If (l_Result > -1) Then lo_Cell = pRange.getCellByPosition(pLookupIndex - 1, l_Result - 1) End If End If ErrHandler: VLookupCell = lo_Cell End Function |
CalcPrim |
Sheet |
CopyRangeAt |
Basic |
|
50 |
21 |
Function CopyRangeAt(ByRef pSrcRange As Object, pTgtSheet As Object, pRefCell As Object) As Long
Dim l_Err As Long
l_Err = 0 On Local Error Resume Next pTgtSheet.copyRange(pRefCell.CellAddress, pSrcRange.RangeAddress) l_Err = Err
CopyRangeAt = l_Err End Function |
CalcPrim |
Sheet |
FixRowCols |
Basic |
|
72 |
24 |
Sub FixRowCols(pSheetName As String, pColNum As Integer, pRowNum As Integer, Optional ByRef pDoc As Object)
Dim lo_Ctrlr As Object If IsMissing(pDoc) Then pDoc = ThisComponent If pDoc.Sheets.hasByName(pSheetName) Then lo_Ctrlr = pDoc.CurrentController If Not (lo_Ctrlr.ActiveSheet.Name = pSheetName) Then lo_Ctrlr.ActiveSheet = pDoc.Sheets.getByName(pSheetName) End If lo_Ctrlr.freezeAtPosition(pColNum, pRowNum) End If
End Sub |
CalcPrim |
Sheet |
GetColNameFromNumber |
Basic |
|
97 |
29 |
Function GetColNameFromNumber(ByRef pNum As Long) As String
Dim l_Str As String Dim l_Div As Long Dim l_Mod As Long l_Str = "" If (pNum < 0) Or (pNum > MAXCOL400) Then l_Str = "?" Else l_Div = pNum + 1 l_Str = "" Do While (l_Div > 0) l_Mod = (l_Div - 1) Mod 26 l_Str = Chr(65 + l_Mod) + l_Str l_Div = Int((l_Div - l_Mod)/26) Loop End If GetColNameFromNumber = l_Str End Function |
CalcPrim |
Sheet |
GetSheet |
Basic |
CopyUsedRange (Procedure) GetRange (Procedure) LastRowIndex (Procedure) |
127 |
42 |
Function GetSheet(Optional ByRef pSheetRef As Variant, Optional pDoc As Object) As Object
Dim lo_Sheet As Object Dim i As Long
If IsMissing(pDoc) Then pDoc = ThisComponent
If IsMissing(pSheetRef) Then lo_Sheet = pDoc.CurrentController.ActiveSheet ElseIf IsNumeric(pSheetRef) Then i = Fix(pSheetRef) If (i >= 0) And (i < pDoc.Sheets.Count) Then lo_Sheet = pDoc.Sheets(i) End If ElseIf (VarType(pSheetRef) = 8) Then If pDoc.Sheets.hasByName(pSheetRef) Then lo_Sheet = pDoc.Sheets.GetByName(pSheetRef) End If ElseIf (VarType(pSheetRef) = 9) Then lo_Sheet = pSheetRef End If GetSheet = lo_Sheet End Function |
CalcPrim |
Sheet |
LastRowIndex |
Basic |
GotoLastCell (Procedure) |
170 |
90 |
Function LastRowIndex(ByRef pColRef As Variant, Optional ByRef pSheetRef As Variant, Optional ByRef pDoc As Object) As Long
Dim lo_Sheet As Object Dim lo_Cols As Object Dim lo_Col As Object Dim lo_SearchDesc As Object Dim lo_SearchRes As Object Dim l_ResultName As String Dim l_arrNameItems As Variant If IsMissing(pDoc) Then pDoc = ThisComponent If IsMissing(pSheetRef) Then lo_Sheet = pDoc.CurrentController.ActiveSheet Else lo_Sheet = GetSheet(pSheetRef, pDoc) If IsNull(lo_Sheet) Then LastRowIndex = ERR_ROWINDEX_UNKSHEET Exit Function End If End If lo_Cols = lo_Sheet.getColumns() If IsNumeric(pColRef) then If (pColRef >= 0) AND (pColRef < lo_Cols.getCount()) Then lo_Col = lo_Cols.getByIndex(pColRef) Else LastRowIndex = ERR_ROWINDEX_UNKCOLINDEX Exit Function EndIf Else If lo_Cols.hasByName(pColRef) Then lo_Col = lo_Cols.getByName(pColRef) Else LastRowIndex = ERR_ROWINDEX_UNKCOLNAME Exit Function EndIf EndIf lo_SearchDesc = lo_Col.createSearchDescriptor lo_SearchDesc.searchRegularExpression = True lo_SearchDesc.SearchString = "." lo_SearchRes = lo_Col.FindAll(lo_SearchDesc) If Not IsNull(lo_SearchRes) Then l_ResultName = lo_SearchRes.AbsoluteName l_arrNameItems = Split(l_ResultName, "$") LastRowIndex = Val(l_arrNameItems(UBound(l_arrNameItems))) - 1 Else LastRowIndex = ERR_ROWINDEX_EMPTY End If
End Function |
CalcPrim |
Sheet |
LastUsedCell |
Basic |
LastUsedColumn (Procedure) LastUsedRow (Procedure) |
261 |
19 |
Function LastUsedCell(ByRef pSheet As Object) As Object
Dim l_Origin As String Dim lo_UsedRange As Object Dim lo_CellCur As Object l_Origin = "A1" lo_CellCur = pSheet.createCursorByRange(pSheet.getCellRangeByName(l_Origin)) lo_CellCur.gotoEndOfUsedArea(False) lo_UsedRange = pSheet.getCellRangeByName(lo_CellCur.AbsoluteName)
LastUsedCell = lo_UsedRange End Function |
CalcPrim |
Sheet |
LastUsedColumn |
Basic |
|
281 |
17 |
Function LastUsedColumn(ByRef pSheet As Object) As Long
Dim lo_UsedRange As Object Dim l_Col As Long l_Col = -1 lo_UsedRange = LastUsedCell(pSheet) l_Col = lo_UsedRange.RangeAddress.EndColumn
LastUsedColumn = l_Col End Function |
CalcPrim |
Sheet |
LastUsedRow |
Basic |
|
299 |
17 |
Function LastUsedRow(ByRef pSheet As Object) As Long
Dim lo_UsedRange As Object Dim l_Row As Long l_Row = -1 lo_UsedRange = LastUsedCell(pSheet) l_Row = lo_UsedRange.RangeAddress.EndRow
LastUsedRow = l_Row End Function |
CalcPrim |
Sheet |
ProtectSheet |
Basic |
ProtectSheetByName (Procedure) |
317 |
30 |
Function ProtectSheet(ByRef pSheet As Object, pProtect As Boolean, Optional pPwd As String) As Integer
Dim l_Err As Integer
l_Err = -1 If Not IsNull(pSheet) Then If IsMissing(pPwd) Then pPwd = "" On Local Error Resume Next If pProtect Then pSheet.protect(pPwd) Else pSheet.unprotect(pPwd) End If l_Err = Err End If
ProtectSheet = l_Err End Function |
CalcPrim |
Sheet |
ProtectSheetByName |
Basic |
|
348 |
25 |
Function ProtectSheetByName(ByRef pSheetName As String, pProtect As Boolean, pPwd As String, Optional ByRef pDoc As Object) As Integer
Dim oSheet As Object Dim l_Err As Integer If IsMissing(pDoc) Then pDoc = ThisComponent
l_Err = -1 If pDoc.Sheets.hasByName(pSheetName) Then pSheet = pDoc.Sheets.getByName(pSheetName) l_Err = ProtectSheet(oSheet, pProtect, pPwd) End If
ProtectSheetByName = l_Err End Function |
CalcPrim |
Sheet |
ShowSheetByName |
Basic |
|
374 |
22 |
Sub ShowSheetByName(ByRef pSheetName As String, pVisible As Boolean, Optional ByRef pDoc As Object)
Dim oDoc As Object Dim oSheet As Object
If IsMissing(pDoc) Then oDoc = ThisComponent Else oDoc = pDoc End If
If oDoc.Sheets.hasByName(pSheetName) Then oSheet = oDoc.Sheets.getByName(pSheetName) oSheet.IsVisible = pVisible End If
End Sub |
CalcPrim |
Spreadsheet |
ShowColumns |
Basic |
|
40 |
20 |
Sub ShowColumns(ByRef pSheetName As String, pRangeName As String, pVisible As Boolean, Optional ByRef pDoc As Object)
Dim lo_Range As Object Dim lo_Cols As Object If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Range = GetNamedRange(pSheetName, pRangeName, pDoc) If Not IsNull(lo_Range) Then lo_Cols = lo_Range.Columns lo_Cols.IsVisible = pVisible End If End Sub |
CalcPrim |
Spreadsheet |
ShowInputLine |
Basic |
|
61 |
19 |
Sub ShowInputLine(ByRef pVisible As Boolean)
Dim l_Args(0) As New com.sun.star.beans.PropertyValue l_Args(0).Name = "InputLineVisible" l_Args(0).Value = pVisible LibOPrim.App._UNOCommand("InputLineVisible", l_Args()) End Sub |
CalcPrim |
Spreadsheet |
ShowRows |
Basic |
|
81 |
20 |
Sub ShowRows(ByRef pSheetName As String, pRangeName As String, pVisible As Boolean, Optional ByRef pDoc As Object)
Dim lo_Range As Object Dim lo_Rows As Object If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Range = GetNamedRange(pSheetName, pRangeName, pDoc) If Not IsNull(lo_Range) Then lo_Rows = lo_Range.Rows lo_Rows.IsVisible = pVisible End If End Sub |
CalcPrim |
Spreadsheet |
ToggleGrid |
Basic |
|
102 |
6 |
Sub ToggleGrid()
LibOPrim.App._UNOCommand("ToggleSheetGrid", Array())
End Sub |
DataStructPrim |
Collections |
AddCollectionItem |
Basic |
|
33 |
47 |
Function AddCollectionItem(ByRef pColl As Object, ByRef pItem As Variant, pKey As String, Optional ByRef pForce As Boolean) As Long
Dim l_Err As Long l_Err = 0 If IsMissing(pForce) Then pForce = False
On Local Error Goto ErrHandler: If Not IsNull(pColl) Then pColl.Add(pItem, pKey) Else l_Err = 1 End If Goto FuncEnd: ErrHandler: If pForce Then pColl.Remove(pKey) pColl.Add(pItem, pKey) l_Err = Err Else l_Err = 2 End If FuncEnd: AddCollectionItem = l_Err End Function |
DialogPrim |
Dialogs |
BrowseForDir |
Basic |
|
34 |
24 |
Function BrowseForDir(ByRef pDefDir As String, pTitle As String, pDescription As String) As String
Dim lo_FP As Object Dim l_Dir As String l_Dir = "" lo_FP = CreateUnoService("com.sun.star.ui.dialogs.FolderPicker") lo_FP.DisplayDirectory = ConvertToURL(pDefDir) lo_FP.Description = pDescription lo_FP.Title = pTitle If (lo_FP.execute = com.sun.star.ui.dialogs.ExecutableDialogResults.OK) Then l_Dir = lo_FP.Directory & "/" End If BrowseForDir = l_Dir End Function |
DialogPrim |
Dialogs |
CreateDialog |
Basic |
|
59 |
31 |
Function CreateDialog(ByRef pLibName As String, pModuleName As String, Optional ByRef pLibCtnr As Object) As Object
Dim lo_Lib As Object Dim lo_ModName As Object Dim lo_UnoDlg As Object lo_UnoDlg = Nothing
If IsMissing(pLibCtnr) Then pLibCtnr = DialogLibraries If pLibCtnr.hasByName(pLibName) Then pLibCtnr.LoadLibrary(pLibName) lo_Lib = pLibCtnr.getByName(pLibName) If lo_Lib.hasByName(pModuleName) Then lo_ModName = lo_Lib.getByName(pModuleName) On Local Error Resume Next lo_UnoDlg = CreateUnoDialog(lo_ModName) End If End If CreateDialog = lo_UnoDlg End Function |
DialogPrim |
Dialogs |
YesNoDialog |
Basic |
|
91 |
9 |
Function YesNoDialog(ByRef pTitle As String, pMsg As String) As Boolean
YesNoDialog = (MsgBox(pMsg, 4 + 32, pTitle) = 6) End Function |
FormPrim |
Widgets |
CheckBoxCount |
Basic |
|
48 |
55 |
Function CheckBoxCount(ByRef pFormName As String, Optional ByRef pDoc As Object, Optional pChecked As Boolean, Optional pNonPrintable As Boolean) As Long
Dim lo_Form As Object Dim lo_Controls As Object Dim lo_CurControl As Object Dim i As Long Dim l_Checked As Long Dim l_CheckCount As Long If IsMissing(pDoc) Then pDoc = ThisComponent If IsMissing(pChecked) Then l_Checked = 1 Else l_Checked = CBool(pChecked) End If If IsMissing(pNonPrintable) Then pNonPrintable = False l_CheckCount = ERR_FORMPRIM_NODOC If Not IsNull(pDoc) Then If pDoc.DrawPage.Forms.hasByName(pFormName) Then lo_Form = pDoc.DrawPage.Forms.getByName(pFormName) lo_Controls = lo_Form.getControlModels For i = 0 To UBound(lo_Controls) - 1 lo_CurControl = lo_Controls(i) If (lo_CurControl.ClassID = WIDG_ID_CBX) Then If (l_CheckCount = -1) Then l_CheckCount = 0 If (lo_CurControl.State = l_Checked) And (pNonPrintable Or lo_CurControl.Printable) Then l_CheckCount = l_CheckCount + 1 End If End If Next i Else l_CheckCount = ERR_FORMPRIM_NOFORM End If End If CheckBoxCount = l_CheckCount End Function |
FormPrim |
Widgets |
GetFormControl |
Basic |
|
104 |
53 |
Function GetFormControl(ByRef pFormName As String, ByRef pCtrlName As String, Optional ByRef pDoc As Object) As Object
Dim lo_Form As Object Dim lo_Ctrl As Object Dim l_DocType As Long lo_Ctrl = Nothing If IsMissing(pDoc) Then pDoc = ThisComponent If Not IsNull(pDoc) Then l_DocType = GetLibODocumentType(pDoc) Select Case l_DocType Case LOPRIM_DOCTYPECALC
Case LOPRIM_DOCTYPEWRITER If pDoc.DrawPage.Forms.hasByName(pFormName) Then lo_Form = pDoc.DrawPage.Forms.getByName(pFormName) If lo_Form.hasByName(pCtrlName) Then lo_Ctrl = lo_Form.getByName(pCtrlName) End If End If
Case LOPRIM_DOCTYPEIMPRESS
Case LOPRIM_DOCTYPEDRAW
Case LOPRIM_DOCTYPEBASE Case LOPRIM_DOCTYPEUNK, ERR_LOPRIM_DOCTYPE End Select End If If (l_DocType > LOPRIM_DOCTYPEUNK) Then If lo_Form.hasByName(pCtrlName) Then lo_Ctrl = lo_Form.getByName(pCtrlName) End If End If
GetFormControl = lo_Ctrl End Function |
IOPrim |
Files |
ChangeFileExt |
Basic |
|
43 |
28 |
Function ChangeFileExt(ByRef pFileName As String, pNewExt As String) As String
Dim l_FileName As String Dim l_Array As Variant l_FileName = ExtractFileName(pFileName) l_FileName = SuppressMultipleChars(l_FileName, IOPRIM_EXTSEPCHAR) l_Array = Split(l_FileName, IOPRIM_EXTSEPCHAR) If (UBound(l_Array) = 0) Then ReDim Preserve l_Array(1) l_Array(1) = pNewExt Else l_Array(UBound(l_Array)) = pNewExt End If ChangeFileExt = Join(l_Array, IOPRIM_EXTSEPCHAR) End Function |
IOPrim |
Files |
ExtractFileExt |
Basic |
|
72 |
20 |
Function ExtractFileExt(ByRef pFileName As String) As String
Dim l_URLName As String Dim l_Array() As String Dim l_Ext As String l_Ext = "" l_URLName = ConvertToURL(pFileName) l_Array = Split(l_URLName, IOPRIM_EXTSEPCHAR) If (UBound(l_Array) > 0) Then l_Ext = l_Array(UBound(l_Array)) End If ExtractFileExt = l_Ext End Function |
IOPrim |
Files |
ExtractFileName |
Basic |
ChangeFileExt (Procedure) JustFileName (Procedure) CalcShareFileName (Procedure) LockFileName (Procedure) |
93 |
16 |
Function ExtractFileName(ByRef pFileName As String) As String
Dim l_URLName As String Dim l_Array() As String l_URLName = ConvertToURL(pFileName) l_Array = Split(l_URLName, IOPRIM_PATHSEPCHAR) ExtractFileName = l_Array(UBound(l_Array)) End Function |
IOPrim |
Files |
ExtractFilePath |
Basic |
GetParentFolder (Procedure) CalcShareFileName (Procedure) LockFileName (Procedure) |
110 |
21 |
Function ExtractFilePath(ByRef pFileName As String) As String
Dim l_URLName As String Dim l_Array() As String Dim l_Path As String l_Path = "" l_URLName = ConvertToURL(pFileName) l_Array = Split(l_URLName, IOPRIM_PATHSEPCHAR) If (UBound(l_Array) > 0) Then l_Array(UBound(l_Array)) = "" l_Path = Join(l_Array, IOPRIM_PATHSEPCHAR) End If ExtractFilePath = l_Path End Function |
IOPrim |
Files |
GetFileContents |
Basic |
|
132 |
19 |
Function GetFileContents(ByRef pFileName As String) As String
Dim l_URLName As String Dim lo_Type As Object Dim l_Content As String
l_Content = "" l_URLName = ConvertToURL(pFileName) If FileExists(l_URLName) Then lo_Type = createUnoService("com.sun.star.document.TypeDetection") l_Content = lo_Type.queryTypeByURL(l_URLName) End If GetFileContents = l_Content End Function |
IOPrim |
Files |
GetFileDateTimeModified |
Basic |
|
152 |
23 |
Function GetFileDateTimeModified(ByRef pFileName As String) As Date
Dim lo_Date As new com.sun.star.util.DateTime Dim l_Date As Date Dim l_URLName As String Dim lo_SFA As Object l_Date = 0 On Local Error GoTo ErrHandler: l_URLName = ConvertToURL(pFileName) If FileExists(l_URLName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) lo_Date = lo_SFA.getDateTimeModified(l_URLName) l_Date = CDateFromUnoDateTime(lo_Date) End If ErrHandler: GetFileDateTimeModified = l_Date End Function |
IOPrim |
Files |
GetFileSize |
Basic |
|
176 |
23 |
Function GetFileSize(ByRef pFileName As String) As Long
Dim l_Size As Long Dim l_URLName As String Dim lo_SFA As Object l_Size = -1 On Local Error Goto ErrHandler: l_URLName = ConvertToURL(pFileName) If FileExists(l_URLName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) l_Size = lo_SFA.getSize(l_URLName) End If ErrHandler: GetFileSize = l_Size End Function |
IOPrim |
Files |
GetSafeDateTimeStr |
Basic |
|
200 |
24 |
Function GetSafeDateTimeStr(ByRef pDate As Date, Optional pWithTime As Boolean) As String
Dim l_DateStr As String Dim l_TimeStr As String l_TimeStr = "" If IsMissing(pWithTime) Then pWithTime = True l_DateStr = CDateToISO(pDate) If pWithTime Then l_TimeStr = Format(pDate, "hhmmss") l_TimeStr = IOPRIM_DATETIMESEPCHAR & l_TimeStr End If
GetSafeDateTimeStr = l_DateStr & l_TimeStr End Function |
IOPrim |
Files |
IsHidden |
Basic |
|
225 |
24 |
Function IsHidden(ByRef pFileName As String) As Boolean
Dim l_Hidden As Boolean Dim l_URLName As String Dim lo_SFA As Object l_Hidden = True On Local Error Goto ErrHandler: l_URLName = ConvertToURL(pFileName) If FileExists(l_URLName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) l_Hidden = lo_SFA.isHidden(l_URLName) End If ErrHandler: IsHidden = l_Hidden End Function |
IOPrim |
Files |
IsReadOnly |
Basic |
|
250 |
24 |
Function IsReadOnly(ByRef pFileName As String) As Boolean
Dim l_RO As Boolean Dim l_URLName As String Dim lo_SFA As Object l_RO = True On Local Error Goto ErrHandler: l_URLName = ConvertToURL(pFileName) If FileExists(l_URLName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) l_RO = lo_SFA.isReadOnly(l_URLName) End If ErrHandler: IsReadOnly = l_RO End Function |
IOPrim |
Files |
JustFileName |
Basic |
|
275 |
16 |
Function JustFileName(ByRef pFileName As String) As String
Dim l_FileName As String Dim l_Array() As String l_FileName = ExtractFileName(pFileName) l_Array = Split(l_FileName, IOPRIM_EXTSEPCHAR) JustFileName = l_Array(0) End Function |
IOPrim |
Files |
NTFSFileNameString |
Basic |
|
292 |
59 |
Function NTFSFileNameString(ByRef pFileName As String, Optional ByRef pExtended As Boolean) As String
Const NTFS_CHARSTRIP = """*/:<>?\|" Const NTFS_CHARSTRIPEX = "()[]{};,.!-+$'&#%–" Const NTFS_CONFLICT = "AUX,CLOCK$,COM,CON,LPT,NUL,PRN,.,.." Dim l_Name As String Dim l_Str As String Dim l_Char As String Dim l_CharStrip As String Dim l_arrConflicts As Variant Dim i As Long Dim j As Long If IsMissing(pExtended) Then pExtended = False
l_arrConflicts = Split(NTFS_CONFLICT, ",") l_CharStrip = NTFS_CHARSTRIP If pExtended Then l_CharStrip = l_CharStrip & NTFS_CHARSTRIPEX End If
For i = 0 To UBound(l_arrConflicts) If (Left(l_Name, Len(l_arrConflicts(i))) = l_arrConflicts(i)) Then l_Name = "_" & l_Name End If Next l_Name = FilterNonPrintableStr(pFileName) If pExtended Then l_Name = NoAccentStr(l_Name) l_Name = ReplaceStr(l_Name, " ", "_") l_Name = StripChars(l_Name, l_CharStrip)
NTFSFileNameString = l_Name End Function |
IOPrim |
Files |
SetHidden |
Basic |
|
352 |
29 |
Function SetHidden(ByRef pFileName As String, pHide As Boolean) As Long
Dim l_Err As Long Dim l_URLName As String Dim lo_SFA As Object On Local Error Goto IOERROR l_Err = ERR_IOPRIM_NOERR l_URLName = ConvertToURL(pFileName) If FileExists(l_URLName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) lo_SFA.SetReadOnly(l_URLName, pHide) Else l_Err = ERR_IOPRIM_NOSUCHFILE End If
IOERROR: If (Err <> 0) Then l_Err = ERR_IOPRIM_FILEHIDE Resume FEXIT End If FEXIT: SetHidden = l_Err End Function |
IOPrim |
Files |
SetReadOnly |
Basic |
|
382 |
29 |
Function SetReadOnly(ByRef pFileName As String, pRO As Boolean) As Long
Dim l_Err As Long Dim l_URLName As String Dim lo_SFA As Object On Local Error Goto IOERROR l_Err = ERR_IOPRIM_NOERR l_URLName = ConvertToURL(pFileName) If FileExists(l_URLName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) lo_SFA.SetReadOnly(l_URLName, pRO) Else l_Err = ERR_IOPRIM_NOSUCHFILE End If
IOERROR: If (Err <> 0) Then l_Err = ERR_IOPRIM_FILEREADONLY Resume FEXIT End If FEXIT: SetReadOnly = l_Err End Function |
IOPrim |
Folders |
CheckPathStr |
Basic |
GetParentFolder (Procedure) |
45 |
11 |
Function CheckPathStr(ByRef pPath As String) As String
Dim l_Path As String l_Path = ConvertToURL(pPath) CheckPathStr = ConvertFromURL(l_Path) End Function |
IOPrim |
Folders |
CopyFolder |
Basic |
|
57 |
45 |
Function CopyFolder(ByRef pSourceFolder As String, pTargetFolder As String) As Long
Dim l_Err As Long Dim l_SrcURL As String Dim l_TgtURL As String Dim lo_SFA as Object l_Err = ERR_IOPRIM_NOERR On Local Error Goto ErrHandler If FolderExists(pSourceFolder) Then If Not FolderExists(pTargetFolder) Then l_Err = CreateFolder(pTargetFolder) If (l_Err = ERR_IOPRIM_NOERR) Then l_SrcURL = ConvertToURL(pSourceFolder) l_TgtURL = ConvertToURL(pTargetFolder) If (l_SrcURL = l_TgtURL) Then l_Err = ERR_IOPRIM_FOLDERTOSELF Else lo_SFA = createUnoService(IOPRIM_SERV_SFA) lo_SFA.copy(l_SrcURL, l_TgtURL) End If End If Else l_Err = ERR_IOPRIM_NOSUCHFOLDER End If ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_FOLDERCOPY End If CopyFolder = l_Err End Function |
IOPrim |
Folders |
CreateFolder |
Basic |
CopyFolder (Procedure) |
103 |
29 |
Function CreateFolder(ByRef pFolderName As String) As Long
Dim l_FolderName As String Dim l_Err As Long Dim lo_SFA as Object l_Err = ERR_IOPRIM_NOERR lo_SFA = createUnoService(IOPRIM_SERV_SFA) On Local Error Goto ErrHandler l_FolderName = ConvertToURL(pFolderName) If Not lo_SFA.Exists(l_FolderName) Then lo_SFA.CreateFolder(l_FolderName) Else l_Err = ERR_IOPRIM_FOLDEREXISTS End If
ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_NOSPACE End If
CreateFolder = l_Err End Function |
IOPrim |
Folders |
DeleteFolder |
Basic |
|
133 |
29 |
Function DeleteFolder(ByRef pFolderName As String) As Long
Dim l_FolderName As String Dim l_Err As Long Dim lo_SFA as Object l_Err = ERR_IOPRIM_NOERR On Local Error Goto ErrHandler lo_SFA = createUnoService(IOPRIM_SERV_SFA) l_FolderName = ConvertToURL(pFolderName) If lo_SFA.Exists(l_FolderName) Then lo_SFA.Kill(l_FolderName) Else l_Err = ERR_IOPRIM_NOSUCHFOLDER End If
ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_FOLDERDELETE End If
DeleteFolder = l_Err End Function |
IOPrim |
Folders |
FolderExists |
Basic |
CopyFolder (Procedure) FolderIsEmpty (Procedure) GetFolderContents (Procedure) |
163 |
16 |
Function FolderExists(ByRef pFolderName As String) As Boolean
Dim l_Exists As Boolean Dim lo_SFA as Object l_Exists = False lo_SFA = createUnoService(IOPRIM_SERV_SFA) On Local Error Resume Next l_Exists = lo_SFA.Exists(ConvertToURL(pFolderName)) FolderExists = l_Exists End Function |
IOPrim |
Folders |
FolderIsEmpty |
Basic |
|
180 |
21 |
Function FolderIsEmpty(ByRef pFolderName As String) As Boolean
Dim l_IsEmpty As Boolean Dim l_Array() As String Dim l_FolderName As String Dim lo_SFA as Object l_IsEmpty = False l_FolderName = ConvertToURL(pFolderName) If FolderExists(l_FolderName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) l_Array() = lo_SFA.getFolderContents(l_FolderName, True) l_IsEmpty = ArrayIsEmpty(l_Array()) End If
FolderIsEmpty = l_IsEmpty End Function |
IOPrim |
Folders |
GetFolderContents |
Basic |
|
202 |
60 |
Function GetFolderContents(ByRef pFolderName As String, pFilter As Byte, pContents As Variant) As Long
Dim l_Err As Long Dim l_FolderName As String Dim lo_SFA as Object Dim l_Array As Variant Dim l_Result As String Dim l_FileName As String Dim l_IsFolder As Boolean l_Err = ERR_IOPRIM_NOERR On Local Error Goto ErrHandler l_FolderName = ConvertToURL(pFolderName) If FolderExists(l_FolderName) Then lo_SFA = createUnoService(IOPRIM_SERV_SFA) l_Array = lo_SFA.getFolderContents(l_FolderName, True) Select Case pFilter Case IOPRIM_FOLDERFILTER_FOLDERSONLY, IOPRIM_FOLDERFILTER_FILESONLY If (UBound(l_Array) > -1) Then l_Result = "" For i = 0 To UBound(l_Array) l_FileName = l_Array(i) l_IsFolder = lo_SFA.isFolder(l_FileName) If (l_IsFolder And (pFilter = IOPRIM_FOLDERFILTER_FOLDERSONLY)) _ Or (Not l_IsFolder And (pFilter = IOPRIM_FOLDERFILTER_FILESONLY)) Then l_Result = l_Result & l_FileName & Chr(13) End If Next i pContents = Split(l_Result, Chr(13)) End If Case IOPRIM_FOLDERFILTER_ALL pContents = l_Array End Select Else l_Err = ERR_IOPRIM_NOSUCHFOLDER End If
ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_FOLDERLIST End If
GetFolderContents = l_Err End Function |
IOPrim |
Folders |
GetParentFolder |
Basic |
|
263 |
18 |
Function GetParentFolder(ByRef pFolderName As String) As String
Dim l_Folder As String Dim l_Array() As String l_Folder = ExtractFilePath(CheckPathStr(pFolderName)) l_Array = Split(pFolder, IOPRIM_PATHSEPCHAR) l_Array(UBound(l_Array)) = "" GetParentFolder = Join(l_Array, IOPRIM_PATHSEPCHAR) End Function |
IOPrim |
Folders |
IsFolder |
Basic |
|
282 |
15 |
Function IsFolder(ByRef pName As String) As Boolean
Dim l_IsFolder As Boolean Dim l_Name As String Dim lo_SFA as Object l_IsFolder = False On Local Error Resume Next l_Name = ConvertToURL(pName) lo_SFA = createUnoService(IOPRIM_SERV_SFA) l_IsFolder = lo_SFA.isFolder(l_Name)
IsFolder = l_IsFolder End Function |
IOPrim |
Folders |
IsSubFolder |
Basic |
|
298 |
15 |
Function IsSubFolder(ByRef pParentName As String, pChildName As String) As Boolean Dim l_IsChild As Boolean Dim l_Parent As String Dim l_Child As String l_IsChild = False l_Parent = ConvertToURL(pParentName) l_Child = ConvertToURL(pChildName) l_IsChild = (InStr(l_Child, l_Parent) > 0)
IsSubFolder = l_IsChild End Function |
IOPrim |
Log |
_WriteToLog |
Basic |
LogIt (Procedure) |
250 |
6 |
Sub _WriteToLog(ByRef pMsg As String)
Print #g_LogFileH, pMsg
End Sub |
IOPrim |
Log |
CloseLog |
Basic |
|
76 |
23 |
Function CloseLog() As Long
Dim l_Err As Long l_Err = ERR_IOPRIMLOGNONE
On Local Error GoTo ErrHandler If g_LogOpen Then Close #g_LogFileH g_LogOpen = False g_LogEnabled = False End If
ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_LOGCANTCLOSE End If CloseLog = l_Err End Function |
IOPrim |
Log |
DisableLogging |
Basic |
|
100 |
6 |
Sub DisableLogging()
LogIt("Logging disabled") g_LogEnabled = False End Sub |
IOPrim |
Log |
EnableLogging |
Basic |
|
107 |
6 |
Sub EnableLogging()
g_LogEnabled = True LogIt("Logging enabled") End Sub |
IOPrim |
Log |
LogError |
Basic |
|
114 |
6 |
Function LogError(ByRef pMsg As String) As Long
LogError = LogIt(pMsg, IOPRIM_LOGERROR) End Function |
IOPrim |
Log |
LogInfo |
Basic |
|
121 |
6 |
Function LogInfo(ByRef pMsg As String) As Long
LogInfo = LogIt(pMsg, IOPRIM_LOGINFO) End Function |
IOPrim |
Log |
LogIt |
Basic |
DisableLogging (Procedure) EnableLogging (Procedure) LogError (Procedure) LogInfo (Procedure) |
128 |
69 |
Function LogIt(ByRef pMsg As String, Optional pType As Integer) As Long
Dim l_Err As Long Dim l_Type As Integer Dim l_Prefix As String Dim l_Msg As String On Local Error GoTo ErrHandler l_Err = ERR_IOPRIMLOGNONE l_Err = OpenLog() If (l_Err <> ERR_IOPRIMLOGNONE) Then LogIt = l_Err Exit Function End If If g_LogEnabled Then If IsMissing(pType) Then l_Type = IOPRIM_LOGUNK Else l_Type = pType End If l_Msg = CStr(Now) & IOPRIM_LOGSEP Select Case l_Type Case IOPRIM_LOGUNK : l_Msg = l_Msg & pMsg Case IOPRIM_LOGERROR : l_Msg = l_Msg & "[" & IOPRIM_LOGERRORSTR & "]" & IOPRIM_LOGSEP & pMsg Case IOPRIM_LOGINFO : l_Msg = l_Msg & "[" & IOPRIM_LOGINFOSTR & "]" & IOPRIM_LOGSEP & pMsg Case Else l_Msg = l_Msg & pMsg End Select _WriteToLog(l_Msg) Else l_Err = ERR_IOPRIM_LOGSUSPENDED End If ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_LOGCANTWRITE End If LogIt = l_Err End Function |
IOPrim |
Log |
OpenLog |
Basic |
LogIt (Procedure) |
198 |
35 |
Function OpenLog() As Long
Dim l_Err As Long l_Err = ERR_IOPRIMLOGNONE If g_LogOpen Then OpenLog = l_Err Exit Function End If If Not g_LogSet Then l_Err = ERR_IOPRIM_LOGSET Else On Local Error GoTo ErrHandler If g_LogOverwrite Then Open g_LogFilename For Output As #g_LogFileH Else Open g_LogFilename For Append As #g_LogFileH End If g_LogOpen = True End If
ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_LOGCANTOPEN End If OpenLog = l_Err End Function |
IOPrim |
Log |
SetLogging |
Basic |
|
234 |
15 |
Sub SetLogging(ByRef pLogFileName As String, Optional pOvw As Boolean)
If IsMissing(pOvw) Then g_LogOverwrite = False Else g_LogOverwrite = pOvw End If g_LogFileName = ConvertToURL(pLogName) g_LogFileH = FreeFile g_LogSet = True
End Sub |
IOPrim |
Streams |
CloseTextStream |
Basic |
|
45 |
27 |
Function CloseTextStream(ByRef pStream As Object) As Long
Dim l_Err As Long
l_Err = ERR_IOPRIM_NOERR If IsNull(pStream) Then Else If pStream.supportsService("com.sun.star.io.TextInputStream") Then pStream.closeInput ElseIf pStream.supportsService("com.sun.star.io.TextOutputStream") Then pStream.closeOutput ElseIf pStream.supportsService("com.sun.star.io.Stream") Then pStream.closeInput pStream.closeOutput Else End If End If CloseStream = l_Err End Function |
IOPrim |
Streams |
LoadTextStreamAsString |
Basic |
|
73 |
32 |
Function LoadTextStreamAsString(ByRef pFileName As String, pEncoding As String) As String
Dim l_FileURL As String Dim l_Str As String Dim lo_SFA As Object Dim lo_TextStream As Object Dim lo_Stream As Object l_FileURL = ConvertToURL(pFileName) lo_SFA = createUnoService("com.sun.star.ucb.SimpleFileAccess") If lo_SFA.exists(l_FileURL) Then lo_Stream = lo_SFA.openFileRead(l_FileURL) lo_TextStream = createUnoService("com.sun.star.io.TextInputStream") lo_TextStream.InputStream = lo_Stream If (Trim(pEncoding) <> "") Then lo_TextStream.Encoding = pEncoding End If l_Str = lo_TextStream.readString(Array(), False) lo_TextStream.closeInput lo_Stream.closeInput End If LoadTextStreamAsString = l_Str End Function |
IOPrim |
Streams |
LoadTextStreamAsVector |
Basic |
|
106 |
44 |
Function LoadTextStreamAsVector(ByRef pFileName As String, pEncoding As String) As Variant
Dim l_Array As Variant Dim l_FileURL As String Dim l_Str As String Dim lo_SFA As Object Dim lo_TextStream As Object Dim lo_Stream As Object l_FileURL = ConvertToURL(pFileName) lo_SFA = createUnoService("com.sun.star.ucb.SimpleFileAccess") If lo_SFA.exists(l_FileURL) Then lo_Stream = lo_SFA.openFileRead(l_FileURL) lo_TextStream = createUnoService("com.sun.star.io.TextInputStream") lo_TextStream.InputStream = lo_Stream If (Trim(pEncoding) <> "") Then lo_TextStream.Encoding = pEncoding End If l_Str = "" Do While not lo_TextStream.isEOF() l_Line = lo_TextStream.readLine() If (l_Str = "") Then l_Str = l_Line Else l_Str = l_Str & Chr(10) & l_Line End If Loop l_Array = Split(l_Str, Chr(10)) lo_TextStream.closeInput lo_Stream.closeInput End If LoadTextStreamAsVector = l_Array End Function |
IOPrim |
Streams |
OpenStream |
Basic |
|
151 |
51 |
Function OpenStream(ByRef pFileName As String, pMode As Long) As Object
Dim lo_Stream As Object Dim lo_Text As Object Dim lo_SFA As Object Dim l_URLName As String On Local Error Goto IOERROR l_URLName = ConvertToURL(pFileName) lo_SFA = createUnoService(IOPRIM_SERV_SFA)
Select Case pMode Case IOPRIM_READMODE lo_Stream = lo_SFA.openFileRead(l_URLName) lo_Text = createUNOService ("com.sun.star.io.TextInputStream") lo_Text.setInputStream(lo_Stream) Case IOPRIM_WRITEMODE lo_Stream = lo_SFA.openFileWrite(l_URLName) lo_Text = createUNOService ("com.sun.star.io.TextOutputStream") lo_Text.setOutputStream(lo_Stream) Case IOPRIM_APPENDMODE lo_Stream = lo_SFA.openFileReadWrite(l_URLName) lo_Text = createUNOService ("com.sun.star.io.Stream") lo_Text.setOutputStream(lo_Stream) lo_Text.setInputStream(lo_Stream) End Select
IOERROR: If (Err <> 0) Then lo_Text = Null Resume FEXIT End If FEXIT: OpenStream = lo_Text End Function |
IOPrim |
Streams |
ReadTextStreamAsString |
Basic |
|
203 |
2 |
Function ReadTextStreamAsString(ByRef pStream As Object, pString As String) As String End Function |
IOPrim |
Streams |
StoreToStream |
Basic |
|
206 |
2 |
Function StoreToStream(ByRef pStream As Object, pStr As String) As Long End Function |
IOPrim |
Streams |
WriteTextToStream |
Basic |
|
209 |
2 |
Function WriteTextToStream(ByRef pStream As Object, pString As String) As Long End Function |
IOPrim |
TextFiles |
CloseTextFile |
Basic |
LoadTextFileAsString (Procedure) |
43 |
18 |
Function CloseTextFile(ByRef pHFile As Integer) As Long
Dim l_Err As Long
On Local Error Goto ErrHandler l_Err = ERR_IOPRIM_NOERR Close #pHFile ErrHandler: If (Err <> 0) Then l_Err = ERR_IOPRIM_CANTCLOSETEXT End If CloseTextFile = l_Err End Function |
IOPrim |
TextFiles |
LoadTextFileAsString |
Basic |
LoadTextFileAsVector (Procedure) |
62 |
33 |
Function LoadTextFileAsString(ByRef pFileName As String, pLineSep As String) As String
Dim l_FileURL As String Dim l_Str As String Dim l_Line As String Dim l_Handle As Integer l_FileURL = ConvertToURL(pFileName) If FileExists(l_FileURL) Then l_Str = "" l_Handle = OpenTextFile(l_FileURL) If (l_Handle > 0) Then Do While Not Eof(l_Handle) Line Input #l_Handle, l_Line If (l_Str = "") Then l_Str = l_Line Else l_Str = l_Str & pLineSep & l_Line End If Loop CloseTextFile(l_Handle) End If End If LoadTextFileAsString = l_Str End Function |
IOPrim |
TextFiles |
LoadTextFileAsVector |
Basic |
|
96 |
14 |
Function LoadTextFileAsVector(ByRef pFileName As String) As Variant
Dim l_Str As String Dim l_Array As Variant l_Str = LoadTextFileAsString(pFileName, Chr(10)) l_Array = Split(l_Str, Chr(10)) LoadTextFileAsVector = l_Array End Function |
IOPrim |
TextFiles |
OpenTextFile |
Basic |
LoadTextFileAsString (Procedure) |
111 |
39 |
Function OpenTextFile(ByRef pFileName As String, Optional pMode As Integer) As Integer
Dim l_URLName As String Dim l_FileH As Integer l_FileH = 0 If IsMissing(pMode) Then pMode = IOPRIM_READMODE On Local Error Goto ErrHandler l_URLName = ConvertToURL(pFileName) Select Case pMode Case IOPRIM_READMODE If FileExists(l_URLName) Then l_FileH = FreeFile Open pFilename For Input As #l_FileH End If Case IOPRIM_WRITEMODE l_FileH = FreeFile Open pFilename For Output As #l_FileH Case IOPRIM_APPENDMODE If FileExists(l_URLName) Then l_FileH = FreeFile Open pFilename For Append As #l_FileH End If
End Select
ErrHandler: OpenTextFile = l_FileH End Function |
IOPrim |
TextFiles |
ReadTextAsString |
Basic |
|
151 |
25 |
Function ReadTextAsString(ByRef pHFile As Integer, pLineSep As String) As String
Dim l_Str As String Dim l_Line As String If (pHFile > 0) Then Do While Not Eof(pHFile) Line Input #pHFile, l_Line If (l_Str = "") Then l_Str = l_Line Else l_Str = l_Str & pLineSep & l_Line End If Loop End If ReadTextAsString = l_Str End Function |
IOPrim |
TextFiles |
ReadTextAsVector |
Basic |
|
177 |
14 |
Function ReadTextAsVector(ByRef pHFile As Integer) As Variant
Dim l_Str As String Dim l_Array As Variant l_Str = ReadTextFileAsString(pFileName, Chr(10)) l_Array = Split(l_Str, Chr(10)) ReadTextAsVector = l_Array End Function |
IOPrim |
TextFiles |
ReadTextLine |
Basic |
|
192 |
3 |
Function ReadTextLine(ByRef pHFile As Integer) As String End Function |
IOPrim |
TextFiles |
StoreFromArray |
Basic |
|
196 |
3 |
Function StoreFromArray() As Long End Function |
IOPrim |
TextFiles |
StoreFromString |
Basic |
|
200 |
3 |
Function StoreFromString() As Long End Function |
IOPrim |
TextFiles |
WriteText |
Basic |
|
204 |
3 |
Function WriteText() As Long End Function |
LibOPrim |
App |
_GetPropertyValueByName |
Basic |
|
45 |
21 |
Function _GetPropertyValueByName(ByRef pItems, pName As String) As Variant
Dim l_Value As Variant Dim i As Long
l_Value = Nothing For i = 0 To UBound(pItems) If (pItems(i).Name = pName) Then l_Value = pItems(i).Value End If Next _GetPropertyValueByName = l_Value End Function |
LibOPrim |
App |
_UNOCommand |
Basic |
SetFullScreen (Procedure) ShowNavigator (Procedure) ShowPrinterDialog (Procedure) ShowPrintPreview (Procedure) ShowDocumentProperties (Procedure) ShowSidebar (Procedure) |
67 |
20 |
Sub _UNOCommand(ByRef pUnoCmd As String, Optional pArgs() As Variant)
Dim lo_Frame As Variant Dim lo_Dispatch As Object Dim l_Args() As Variant If Not IsMissing(pArgs) Then l_Args() = pArgs()
lo_Frame = ThisComponent.CurrentController.Frame lo_Dispatch = createUnoService(LOPRIM_SERV_DISPATCH) lo_Dispatch.executeDispatch(lo_Frame, ".uno:" & pUnoCmd, "", 0, l_Args())
End Sub |
LibOPrim |
App |
SetFullScreen |
Basic |
|
88 |
17 |
Sub SetFullScreen(Optional ByRef pShowToolbar As Boolean)
Dim l_Show As Boolean
If IsMissing(pShowToolbar) Then l_Show = True Else l_Show = pShowToolbar End If _UNOCommand("FullScreen") If Not l_Show Then HideToolbar(LOPRIM_TB_FULLSCREEN)
End Sub |
LibOPrim |
App |
ShowDocumentProperties |
Basic |
|
132 |
6 |
Sub ShowDocumentProperties()
_UNOCommand("SetDocumentProperties")
End Sub |
LibOPrim |
App |
ShowNavigator |
Basic |
|
106 |
11 |
Sub ShowNavigator(ByRef pShow As Boolean)
Dim l_Args(0) As New com.sun.star.beans.PropertyValue
l_Args(0).Name = "Navigator" l_Args(0).Value = pShow
_UNOCommand("Navigator", l_Args())
End Sub |
LibOPrim |
App |
ShowPrinterDialog |
Basic |
|
118 |
6 |
Sub ShowPrinterDialog()
_UNOCommand("Print")
End Sub |
LibOPrim |
App |
ShowPrintPreview |
Basic |
|
125 |
6 |
Sub ShowPrintPreview()
_UNOCommand("PrintPreview")
End Sub |
LibOPrim |
App |
ShowSidebar |
Basic |
|
139 |
11 |
Sub ShowSidebar(ByRef pShow As Boolean)
Dim l_Args(0) As New com.sun.star.beans.PropertyValue
l_Args(0).Name = "Sidebar" l_Args(0).Value = pShow
_UNOCommand("Sidebar", l_Args())
End Sub |
LibOPrim |
CustomProperties |
_CreateCustomProperty_Test |
Basic |
|
121 |
41 |
Sub _CreateCustomProperty_Test()
Dim l_Err As Long Dim l_Props As Variant Dim lo_UnoDate As New com.sun.star.util.Date Dim lo_UnoDateTime As New com.sun.star.util.DateTime Dim lo_UnoDuration As New com.sun.star.util.Duration l_Props = Array("TestString", "some text") l_Err = CreateCustomProperty(l_Props) Print l_Err l_Err = CreateCustomProperty(Array("TestDouble", 1.25)) Print l_Err Print CreateCustomProperty(Array("TestInteger", 987)) Print CreateCustomProperty(Array("TestBoolean", True)) Print CreateCustomProperty(Array("TestDate", Date())) lo_UnoDate = CDateToUNODate(Date()) Print CreateCustomProperty(Array("TestUNODate", lo_UnoDate)) lo_UnoDateTime = CDateToUNODateTime(Now()) Print CreateCustomProperty(Array("TestUNODateTime", lo_UnoDateTime)) With lo_UnoDuration .Hours = 10 End With Print CreateCustomProperty(Array("TestUNODuration", lo_UnoDuration))
End Sub |
LibOPrim |
CustomProperties |
_CustomPropertiesToArray_Test |
Basic |
|
221 |
7 |
Sub _CustomPropertiesToArray_Test()
Dim l_Array As Variant l_Array = CustomPropertiesToArray()
End sub |
LibOPrim |
CustomProperties |
_CustomPropertyExists_Test |
Basic |
|
182 |
6 |
Sub _CustomPropertyExists_Test()
Print CustomPropertyExists("TestProperty") Print CustomPropertyExists("Author")
End Sub |
LibOPrim |
CustomProperties |
_CustomPropertyType_Test |
Basic |
|
269 |
3 |
Sub _CustomPropertyType_Test() End Sub |
LibOPrim |
CustomProperties |
_DeleteAllCustomProperties_Test |
Basic |
|
290 |
3 |
Sub _DeleteAllCustomProperties_Test() End Sub |
LibOPrim |
CustomProperties |
_DeleteCustomProperty_Test |
Basic |
|
330 |
3 |
Sub _DeleteCustomProperty_Test()
End Sub |
LibOPrim |
CustomProperties |
_GetCustomProperty_Test |
Basic |
|
349 |
7 |
Sub _GetCustomProperty_Test()
Dim lo_Obj As Object
lo_Obj = GetCustomProperty("Author")
End Sub |
LibOPrim |
CustomProperties |
_GetCustomPropertyValue_Test |
Basic |
|
378 |
8 |
Sub _GetCustomPropertyValue_Test()
Dim l_Value As Variant
l_Value = GetCustomPropertyValue("Author") Print l_Value
End Sub |
LibOPrim |
CustomProperties |
_SetCustomPropertyValue_Test |
Basic |
|
422 |
5 |
Sub _SetCustomPropertyValue_Test()
Print SetCustomPropertyValue("TestProperty", "Test value")
End Sub |
LibOPrim |
CustomProperties |
CreateCustomProperty |
Basic |
_CreateCustomProperty_Test (Procedure) |
64 |
56 |
Function CreateCustomProperty(ByRef pArrProps As Variant, Optional ByRef pDoc As Object) As Long
Dim l_Result As Long Dim l_Type As Integer Dim lo_CProps As Object l_Result = ERR_CPROP_NORUN If IsMissing(pDoc) Then pDoc = ThisComponent lo_CProps = pDoc.DocumentProperties.UserDefinedProperties If (Trim(pArrProps(0)) = "") Then l_Result = ERR_CPROP_NAME ElseIf lo_CProps.PropertySetInfo.hasPropertyByName(pArrProps(0)) Then l_Result = ERR_CPROP_EXISTS Else l_Type = CustomPropertyType(pArrProps(1)) On Local Error GoTo ErrHandler: Select Case l_Type Case CPROP_TYPE_STRING, CPROP_TYPE_YESNO, CPROP_TYPE_UNODATE, CPROP_TYPE_UNODATETIME, CPROP_TYPE_UNODURATION lo_CProps.addProperty(pArrProps(0), com.sun.star.beans.PropertyAttribute.REMOVEABLE, pArrProps(1)) l_Result = ERR_CPROP_OK
Case CPROP_TYPE_DATE lo_CProps.addProperty(pArrProps(0), com.sun.star.beans.PropertyAttribute.REMOVEABLE, CDateToUnoDate(pArrProps(1))) l_Result = ERR_CPROP_OK
Case CPROP_TYPE_NUMBER lo_CProps.addProperty(pArrProps(0), com.sun.star.beans.PropertyAttribute.REMOVEABLE, CreateUnoValue("double", pArrProps(1))) l_Result = ERR_CPROP_OK Case Else l_Result = ERR_CPROP_TYPE End Select End If ErrHandler: CreateCustomProperty = l_Result End Function |
LibOPrim |
CustomProperties |
CustomPropertiesToArray |
Basic |
_CustomPropertiesToArray_Test (Procedure) |
189 |
31 |
Function CustomPropertiesToArray(Optional ByRef pDoc As Object) As Variant
Dim l_Array As Variant Dim lo_arrProps As Variant Dim lo_CProp As Object Dim i As Long
If IsMissing(pDoc) Then pDoc = ThisComponent
lo_arrProps = pDoc.DocumentProperties.UserDefinedProperties.PropertyValues i = UBound(lo_arrProps) ReDim l_Array(i, 2)
i = 0 For Each lo_CProp in lo_arrProps l_Array(i, 0) = lo_CProp.Name l_Array(i, 1) = lo_CProp.Value l_Array(i, 2) = CustomPropertyType(lo_CProp.Value) i = i + 1 Next
CustomPropertiesToArray = l_Array End Function |
LibOPrim |
CustomProperties |
CustomPropertyExists |
Basic |
_CustomPropertyExists_Test (Procedure) |
163 |
18 |
Function CustomPropertyExists(ByRef pName As String, Optional ByRef pDoc As Object) As Boolean
Dim lo_CProps As Object Dim l_Exists As Boolean If IsMissing(pDoc) Then pDoc = ThisComponent
lo_CProps = pDoc.DocumentProperties.UserDefinedProperties l_Exists = lo_CProps.PropertySetInfo.hasPropertyByName(pName)
CustomPropertyExists = l_Exists End Function |
LibOPrim |
CustomProperties |
CustomPropertyType |
Basic |
CreateCustomProperty (Procedure) CustomPropertiesToArray (Procedure) |
229 |
39 |
Function CustomPropertyType(ByRef pValue As Variant) As Integer
Dim l_Type As Integer l_Type = CPROP_TYPE_UNK
If (VarType(pValue) = V_STRING) Then l_Type = CPROP_TYPE_STRING ElseIf IsNumeric(pValue) Then l_Type = CPROP_TYPE_NUMBER ElseIf (VarType(pValue) = V_DATE) Then l_Type = CPROP_TYPE_DATE ElseIf (VarType(pValue) = 11) Then l_Type = CPROP_TYPE_YESNO ElseIf (VarType(pValue) = 9) Then If ImplementsUNOstruct(pValue, "com.sun.star.util.Date") Then l_Type = CPROP_TYPE_UNODATE ElseIf ImplementsUNOstruct(pValue, "com.sun.star.util.DateTime") Then l_Type = CPROP_TYPE_UNODATETIME ElseIf ImplementsUNOstruct(pValue, "com.sun.star.util.Duration") Then l_Type = CPROP_TYPE_UNODURATION End If End If
CustomPropertyType = l_Type End Function |
LibOPrim |
CustomProperties |
DeleteAllCustomProperties |
Basic |
|
273 |
16 |
Sub DeleteAllCustomProperties(Optional ByRef pDoc As Object)
Dim lo_CProps As Object Dim lo_CProp As Object If IsMissing(pDoc) Then pDoc = ThisComponent
lo_CProps = pDoc.DocumentProperties.UserDefinedProperties For Each lo_CProp In lo_CProps lo_CProps.removeProperty(lo_CProp.Name) Next End Sub |
LibOPrim |
CustomProperties |
DeleteCustomProperty |
Basic |
|
294 |
35 |
Function DeleteCustomProperty(ByRef pName As String, Optional ByRef pDoc As Object) As Long
Dim lo_CProps As Object Dim l_Result As Long l_Result = ERR_CPROP_NORUN
If IsMissing(pDoc) Then pDoc = ThisComponent
lo_CProps = pDoc.DocumentProperties.UserDefinedProperties If lo_CProps.PropertySetInfo.hasPropertyByName(pName) Then On Local Error GoTo ErrHandler: lo_CProps.removeProperty(pName) l_Result = ERR_CPROP_OK Else l_Result = ERR_CPROP_NOTFOUND End If ErrHandler: If Err Then l_Result = Err DeleteCustomProperty = l_Result End Function |
LibOPrim |
CustomProperties |
GetCustomProperty |
Basic |
_GetCustomProperty_Test (Procedure) |
334 |
14 |
Function GetCustomProperty(ByRef pName As String, Optional ByRef pDoc As Object) As Object
Dim lo_CProps As Object Dim lo_CProp As Object If IsMissing(pDoc) Then pDoc = ThisComponent
lo_CProps = pDoc.DocumentProperties.UserDefinedProperties If lo_CProps.PropertySetInfo.hasPropertyByName(pName) Then lo_CProp = lo_CProps.PropertySetInfo.getPropertyByName(pName) End If GetCustomProperty = lo_CProp End Function |
LibOPrim |
CustomProperties |
GetCustomPropertyValue |
Basic |
_GetCustomPropertyValue_Test (Procedure) |
357 |
20 |
Function GetCustomPropertyValue(ByRef pName As String, Optional ByRef pDoc As Object) As Variant
Dim lo_CProps As Object Dim l_Value As Variant
If IsMissing(pDoc) Then pDoc = ThisComponent
lo_CProps = pDoc.DocumentProperties.UserDefinedProperties If lo_CProps.PropertySetInfo.hasPropertyByName(pName) Then l_Value = lo_CProps.getPropertyValue(pName) End If GetCustomPropertyValue = l_Value End Function |
LibOPrim |
CustomProperties |
SetCustomPropertyValue |
Basic |
_SetCustomPropertyValue_Test (Procedure) |
387 |
34 |
Function SetCustomPropertyValue(ByRef pName As String, ByRef pValue As Variant, Optional ByRef pDoc As Object) As Long
Dim lo_CProps As Object Dim l_Result As Long l_Result = ERR_CPROP_NORUN
If IsMissing(pDoc) Then pDoc = ThisComponent
lo_CProps = pDoc.DocumentProperties.UserDefinedProperties If lo_CProps.PropertySetInfo.hasPropertyByName(pName) Then On Local Error GoTo ErrHandler: lo_CProps.setPropertyValue(pName, pValue) l_Result = ERR_CPROP_OK Else l_Result = ERR_CPROP_NOTFOUND End If ErrHandler: If Err Then l_Result = Err SetCustomPropertyValue = l_Result End Function |
LibOPrim |
Document |
CreateDocument |
Basic |
|
52 |
45 |
Function CreateDocument(ByRef pType As Long, pHidden As Boolean, pReadOnly As Boolean) As Object
Dim l_TypeStr As String Dim lo_Doc As Object Dim l_Props(1) As New com.sun.star.beans.PropertyValue l_Props(0).Name = "Hidden" l_Props(0).Value = pHidden l_Props(1).Name = "ReadOnly" l_Props(1).Value = pReadOnly Select Case pType Case LOPRIM_DOCTYPECALC l_TypeStr = "private:factory/scalc" Case LOPRIM_DOCTYPEWRITER l_TypeStr = "private:factory/swriter" Case LOPRIM_DOCTYPEIMPRESS l_TypeStr = "private:factory/simpress" Case LOPRIM_DOCTYPEDRAW l_TypeStr = "private:factory/sdraw" Case LOPRIM_DOCTYPEMATH l_TypeStr = "private:factory/smath" Case Else End Select If (l_TypeStr <> "") Then lo_Doc = StarDesktop.loadComponentFromURL(l_TypeStr, "_blank", 0, l_Props()) End If CreateDocument = lo_Doc End Function |
LibOPrim |
Document |
DocumentProtectionFlag |
Basic |
|
98 |
47 |
Function DocumentProtectionFlag(ByRef pDoc As String) As Integer
Const ZIP_DIR_ROOT = "" Const ZIP_DIR_THUMBNAILS = "Thumbnails"
Dim l_Flag As Integer Dim lo_Package As Object Dim l_Arg As New com.sun.star.beans.NamedValue l_Flag = -1 On Local Error Goto ErrHandler: lo_Package = createUnoService("com.sun.star.packages.Package") l_Arg.Name = "PackageFormat" l_Arg.Value = False lo_Package.initialize(Array(ConvertToURL(pDoc)), l_Arg) If lo_Package.hasByHierarchicalName(ZIP_DIR_ROOT) Then If lo_Package.hasByHierarchicalName(ZIP_DIR_THUMBNAILS) Then l_Flag = 0 Else l_Flag = 1 End If End If lo_Package = Nothing ErrHandler: DocumentProtectionFlag = l_Flag End Function |
LibOPrim |
Document |
GetCurrentDirectory |
Basic |
|
146 |
22 |
Function GetCurrentDirectory(Optional pDoc As Object) As String
Dim l_Dir As String Dim l_Array() As String l_Dir = "" If IsMissing(pDoc) Then pDoc = ThisComponent If pDoc.hasLocation Then l_Array = Split(pDoc.Location, IOPRIM_PATHSEPCHAR) If (UBound(l_Array) > 0) Then l_Array(UBound(l_Array)) = "" l_Dir = Join(l_Array, IOPRIM_PATHSEPCHAR) End If End If
GetCurrentDirectory = l_Dir End Function |
LibOPrim |
Document |
GetLibODocType |
Basic |
IsBaseDocument (Procedure) IsCalcDocument (Procedure) IsDrawDocument (Procedure) IsImpressDocument (Procedure) IsMathDocument (Procedure) IsWriterDocument (Procedure) |
169 |
41 |
Function GetLibODocType(Optional ByRef pDoc As Object) As Long
Dim lo_Doc As Object Dim l_Type As Long l_Type = ERR_LOPRIM_DOCTYPE
If IsMissing(pDoc) Then lo_Doc = ThisComponent Else lo_Doc = pDoc End If If Not IsNull(lo_Doc) Then If lo_Doc.SupportsService("com.sun.star.sheet.SpreadsheetDocument") Then l_Type = LOPRIM_DOCTYPECALC ElseIf lo_Doc.SupportsService("com.sun.star.text.TextDocument") Then l_Type = LOPRIM_DOCTYPEWRITER ElseIf lo_Doc.SupportsService("com.sun.star.drawing.DrawingDocument") Then l_Type = LOPRIM_DOCTYPEDRAW ElseIf lo_Doc.SupportsService("com.sun.star.presentation.PresentationDocuments") Then l_Type = LOPRIM_DOCTYPEIMPRESS ElseIf lo_Doc.SupportsService("com.sun.star.formula.FormulaProperties") Then l_Type = LOPRIM_DOCTYPEMATH ElseIf lo_Doc.SupportsService("com.sun.star.sdb.OfficeDatabaseDocument") Then l_Type = LOPRIM_DOCTYPEBASE Else l_Type = LOPRIM_DOCTYPEUNK End If End If
GetLibODocType = l_Type End Function |
LibOPrim |
Document |
IsBaseDocument |
Basic |
|
211 |
8 |
Function IsBaseDocument(Optional ByRef pDoc As Object) As Boolean
If IsMissing(pDoc) Then pDoc = ThisComponent IsBaseDocument = (GetLibODocType(pDoc) = LOPRIM_DOCTYPEBASE)
End Function |
LibOPrim |
Document |
IsCalcDocument |
Basic |
|
220 |
8 |
Function IsCalcDocument(Optional ByRef pDoc As Object) As Boolean
If IsMissing(pDoc) Then pDoc = ThisComponent IsCalcDocument = (GetLibODocType(pDoc) = LOPRIM_DOCTYPECALC)
End Function |
LibOPrim |
Document |
IsDrawDocument |
Basic |
|
229 |
8 |
Function IsDrawDocument(Optional ByRef pDoc As Object) As Boolean
If IsMissing(pDoc) Then pDoc = ThisComponent IsDrawDocument = (GetLibODocType(pDoc) = LOPRIM_DOCTYPEDRAW)
End Function |
LibOPrim |
Document |
IsImpressDocument |
Basic |
|
238 |
8 |
Function IsImpressDocument(Optional ByRef pDoc As Object) As Boolean
If IsMissing(pDoc) Then pDoc = ThisComponent IsImpressDocument = (GetLibODocType(pDoc) = LOPRIM_DOCTYPEIMPRESS)
End Function |
LibOPrim |
Document |
IsMathDocument |
Basic |
|
247 |
8 |
Function IsMathDocument(Optional ByRef pDoc As Object) As Boolean
If IsMissing(pDoc) Then pDoc = ThisComponent IsMathDocument = (GetLibODocType(pDoc) = LOPRIM_DOCTYPEMATH)
End Function |
LibOPrim |
Document |
IsWriterDocument |
Basic |
|
256 |
8 |
Function IsWriterDocument(Optional ByRef pDoc As Object) As Boolean
If IsMissing(pDoc) Then pDoc = ThisComponent IsWriterDocument = (GetLibODocType(pDoc) = LOPRIM_DOCTYPEWRITER)
End Function |
LibOPrim |
Document |
ModuleIdentifierStr |
Basic |
|
265 |
18 |
Function ModuleIdentifierStr(Optional ByRef pDoc As Object) As String
Dim l_Str As String Dim lo_ModuleMgr As Object
If IsMissing(pDoc) Then pDoc = ThisComponent
lo_ModuleMgr = createUnoService("com.sun.star.frame.ModuleManager") l_Str = lo_ModuleMgr.identify(pDoc)
ModuleIdentifierStr = l_Str End Function |
LibOPrim |
Document |
OpenDocument |
Basic |
|
284 |
28 |
Function OpenDocument(ByRef pFileName As String, pHidden As Boolean, pReadOnly As Boolean, pAsTemplate As Boolean) As Object
Dim lo_Doc As Object Dim l_Props(2) As New com.sun.star.beans.PropertyValue l_Props(0).Name = "Hidden" l_Props(0).Value = pHidden l_Props(1).Name = "ReadOnly" l_Props(1).Value = pReadOnly l_Props(2).Name = "AsTemplate" l_Props(2).Value = pAsTemplate On Local Error Resume Next lo_Doc = StarDesktop.loadComponentFromURL(ConvertToURL(pFileName), "_blank", 0, l_Props())
OpenDocument = lo_Doc End Function |
LibOPrim |
Document |
OpenDocumentCopy |
Basic |
|
313 |
34 |
Function OpenDocumentCopy(ByRef pTgtFileName As String, Optional pHidden As Boolean, Optional ByRef pSrcDoc) As Object
Dim l_FileName As String Dim l_Props(0) As New com.sun.star.beans.PropertyValue Dim lo_Doc As Object If IsMissing(pHidden) Then pHidden = False If IsMissing(pSrcDoc) Then pSrcDoc = ThisComponent
l_FileName = ConvertToURL(pTgtFileName) On Local Error Goto ErrHandler pSrcDoc.storeToURL(l_FileName, Array())
l_Props(0).Name = "Hidden" l_Props(0).Value = pHidden lo_Doc = StarDesktop.loadComponentFromURL(l_TgtFileName, "_blank", 0, l_Props())
ErrHandler: OpenDocumentCopy = lo_Doc End Function |
LibOPrim |
Document |
OpenDocumentEx |
Basic |
|
348 |
17 |
Function OpenDocumentEx(ByRef pFileName As String, pOptions As Variant) As Object
OpenDocumentEx = Null End Function |
LibOPrim |
Extensions |
ExtensionDir |
Basic |
|
43 |
20 |
Function ExtensionDir(ByRef pExtID As String) As String
Dim l_Str As String Dim lo_ExtInfo as Object
lo_ExtInfo = GetDefaultContext.getByName(LOPRIM_PACKAGEINFOSING) If Not IsNull(lo_ExtInfo) Then l_Str = lo_ExtInfo.getPackageLocation(pExtID) End If If (l_Str <> "") Then l_Str = l_Str & "/"
ExtensionDir = l_Str End Function |
LibOPrim |
Graphics |
GetGraphicFromResource |
Basic |
|
43 |
19 |
Function GetGraphicFromResource(ByRef pGraphicName As String, Optional ByRef pDoc As Object) As Object
Dim lo_Bitmaps As Object Dim lo_Graphic As Object If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Bitmaps = pDoc.createInstance("com.sun.star.drawing.BitmapTable") If lo_Bitmaps.hasByName(pGraphicName) Then lo_Graphic = GetImage(lo_Bitmaps.getByName(pGraphicName)) End If
GetGraphicFromResource = lo_Graphic End Function |
LibOPrim |
Graphics |
GetImage |
Basic |
GetGraphicFromResource (Procedure) |
63 |
19 |
Function GetImage(ByRef pFileName As String) As Variant
Dim lo_GP Dim lo_Graphic As Object Dim l_aArg As New com.sun.star.beans.PropertyValue
lo_GP = createUnoService("com.sun.star.graphic.GraphicProvider") l_aArg.Name = "URL" l_aArg.Value = ConvertToURL(pFileName)
On Local Error Resume Next lo_Graphic = lo_GP.queryGraphic(Array(l_aArg))
GetImage = lo_Graphic End Function |
LibOPrim |
Graphics |
GetImageManager |
Basic |
|
83 |
22 |
Function GetImageManager(Optional ByRef pDoc As Object) As Object
Dim lo_ModuleMgr As Object Dim l_DocType As String Dim lo_ModuleCfgMgrSupplier As Object Dim lo_ModuleCfgMgr As Object If IsMissing(pDoc) Then pDoc = ThisComponent lo_ModuleMgr = createUnoService("com.sun.star.frame.ModuleManager") l_DocType = lo_ModuleMgr.identify(pDoc) lo_ModuleCfgMgrSupplier = createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") lo_ModuleCfgMgr = lo_ModuleCfgMgrSupplier.getUIConfigurationManager(l_DocType) GetImageManager = lo_ModuleCfgMgr.ImageManager End Function |
LibOPrim |
Graphics |
SetImageURL |
Basic |
|
106 |
26 |
Function SetImageURL(ByRef strImageURL As String, ByRef strImageObjectName As String)
Dim lo_DrawPage as Object Dim lo_Obj As Object Dim i As Integer On Local Error Resume Next lo_DrawPage = ThisComponent.getDrawPages().getByIndex(0) For i = 0 To lo_DrawPage.Count - 1 lo_Obj = lo_DrawPage.getByIndex(i) If lo_Obj.Name = strImageObjectName Then If lo_Obj.getShapeType() = "com.sun.star.drawing.GraphicObjectShape" Then lo_Obj.GraphicURL = ConvertToURL(strImageURL) Exit For End If End If Next i End Function |
LibOPrim |
SpecialFiles |
CalcShareFileName |
Basic |
IsCalcDocumentShared (Procedure) |
54 |
28 |
Function CalcShareFileName(Optional ByRef pDoc As Object) As String
Const SHARE_MASK = ".~sharing.%FILENAME%%23" Dim l_FullName As String Dim l_FileName As String Dim l_PathName As String If IsMissing(pDoc) Then pDoc = ThisComponent
If (Trim(pDoc.Location) <> "") Then l_PathName = ExtractFilePath(pDoc.Location) l_FileName = ExtractFileName(pDoc.Location) l_FileName = ReplaceStr(SHARE_MASK, "%FILENAME%", l_FileName) l_FullName = l_PathName & l_FileName End If
CalcShareFileName = l_FullName End Function |
LibOPrim |
SpecialFiles |
GetLibreOfficeSpecialFileData |
Basic |
|
83 |
35 |
Function GetLibreOfficeSpecialFileData(ByRef pSpecialFileName As String) As Variant
Const SEP = "," Dim l_Array As Variant Dim l_TmpArray As Variant Dim l_TmpSize As Integer Dim i As Long
If FileExists(pSpecialFileName) Then l_TmpArray = ReadTextFileAsVector(pSpecialFileName, "") l_TmpSize = UBound(l_TmpArray) ReDim l_Array(l_TmpSize) For i = 0 To UBound(l_TmpSize) l_Array(i) = Split(l_TmpArray(i), SEP) Next i End If
GetLibreOfficeSpecialFileData = l_Array End Function |
LibOPrim |
SpecialFiles |
IsCalcDocumentShared |
Basic |
|
119 |
21 |
Function IsCalcDocumentShared(Optional ByRef pDoc As Object) As Boolean
Dim l_FullName As String Dim l_Shared As Boolean l_Shared = False If IsMissing(pDoc) Then pDoc = ThisComponent
l_FullName = CalcShareFileName(pDoc) If (l_FullName <> "") Then l_Shared = FileExists(l_FullName) End If
IsCalcDocumentShared = l_Shared End Function |
LibOPrim |
SpecialFiles |
LockFileName |
Basic |
|
141 |
28 |
Function LockFileName(Optional ByRef pDoc As Object) As String
Const LOCK_MASK = ".~lock.%FILENAME%%23" Dim l_FullName As String Dim l_FileName As String Dim l_PathName As String If IsMissing(pDoc) Then pDoc = ThisComponent
If (Trim(pDoc.Location) <> "") Then l_PathName = ExtractFilePath(pDoc.Location) l_FileName = ExtractFileName(pDoc.Location) l_FileName = ReplaceStr(LOCK_MASK, "%FILENAME%", l_FileName) l_FullName = l_PathName & l_FileName End If
LockFileName = l_FullName End function |
LibOPrim |
System |
CreateProperty |
Basic |
|
56 |
18 |
Function CreateProperty(ByRef Optional pName as String, ByRef Optional pValue as Variant) As com.sun.star.beans.PropertyValue
Dim lo_PropertyValue As Variant lo_PropertyValue = createUnoStruct(LOPRIM_PROPERTYVALUE) If Not IsMissing(pName) Then lo_PropertyValue.Name = pName If Not IsMissing(pValue) Then lo_PropertyValue.Value = pValue
CreateProperty = lo_PropertyValue End Function |
LibOPrim |
System |
ExpandMacro |
Basic |
|
75 |
19 |
Function ExpandMacro(ByRef pMacro As String) As String Dim lo_Context as Object Dim lo_MacroExpander as Object lo_Context = getProcessServiceManager().DefaultContext lo_MacroExpander = lo_Context.getValueByName(LOPRIM_THEEXPANDER) ExpandMacro = lo_MacroExpander.ExpandMacros(pMacro) End Function |
LibOPrim |
System |
GetRegKeyContent |
Basic |
|
95 |
48 |
Function GetRegKeyContent(ByRef pKeyName As String, pMode As Long, Optional pLang As String) As Object
Dim lo_ConfigProvider As Object Dim l_AccessMode As String Dim l_ProvName As String Dim l_Args(2) As New com.sun.star.beans.PropertyValue l_Args(0).Name = "nodepath" l_Args(0).Value = keyName l_Args(1).Name = "enableasync" l_Args(1).Value = False l_ProvName = "" If ((pMode And LOPRIM_CONFIGUSER) = LOPRIM_CONFIGUSER) Then l_ProvName = LOPRIM_REGUSERPROV ElseIf ((pMode And LOPRIM_CONFIGADMIN) = LOPRIM_CONFIGADMIN) Then l_ProvName = LOPRIM_REGADMINPROV End If l_AccessMode = LOPRIM_REGREAD If ((pMode And LOPRIM_CONFIGWRITE) = LOPRIM_CONFIGWRITE) Then l_AccessMode = LOPRIM_REGWRITE End If
If Not IsMissing(pLang) Then If (Len(pLang) > 0) Then l_Args(2).Name = "Locale" l_Args(2).Value = pLang End If End If On Local Error Resume Next lo_ConfigProvider = CreateUnoService(l_ProvName) GetRegKeyContent = lo_ConfigProvider.createInstanceWithArguments(l_AccessMode, l_Args()) End Function |
LibOPrim |
Toolbars |
_GetPropertyValueByName |
Basic |
GetToolbarResName (Procedure) |
68 |
21 |
Function _GetPropertyValueByName(ByRef pItems, pName As String) As Variant
Dim l_Value As Variant Dim i As Long
l_Value = Nothing For i = 0 To UBound(pItems) If (pItems(i).Name = pName) Then l_Value = pItems(i).Value End If Next _GetPropertyValueByName = l_Value End Function |
LibOPrim |
Toolbars |
_ToolbarCommand |
Basic |
DeleteToolbar (Procedure) DisplayToolbar (Procedure) HideToolbar (Procedure) ToolbarVisible (Procedure) |
90 |
64 |
Function _ToolbarCommand(ByRef pToolbarName As String, pAction As String, pDoc As Object) As Long
Dim lo_Frame As Object Dim lo_LOMgr As Object Dim l_res As String Dim l_Err As Long l_Err = ERR_TBAR_NONE lo_Frame = pDoc.CurrentController.Frame lo_LOMgr = lo_Frame.LayoutManager If (InStr(pToolbarName, LOPRIM_TB_ROOT) > 0) Then l_res = pToolbarName Else l_res = GetToolbarResName(pToolBarName, pDoc) End If If IsNull(lo_LOMgr.getElement(l_res)) Then l_Err = ERR_TBAR_UNKNOWN Else Select Case pAction Case LOPRIM_TBCMD_VIS If lo_LOMgr.isElementVisible(l_res) Then l_Err = ERR_TBAR_VISIBLE Else l_Err = ERR_TBAR_HIDDEN End If Case LOPRIM_TBCMD_VIEW lo_LOMgr.showElement(l_res) Case LOPRIM_TBCMD_HIDE lo_LOMgr.hideElement(l_res) Case LOPRIM_TBCMD_DEL If (Instr(l_res, "custom_toolbar") > 0) Then lo_LOMgr.destroyElement(l_res) Else l_Err = ERR_TBAR_DEL End If Case Else l_Err = ERR_LOPRIM_CMDUNK End Select End If _ToolbarCommand = l_Err End Function |
LibOPrim |
Toolbars |
CustomToolbarsToArray |
Basic |
|
155 |
28 |
Function CustomToolbarsToArray(Optional ByRef pDoc As Object) As Variant
Dim lo_CustomTB As Object Dim lo_aTB As Object Dim l_arrTB() As Variant Dim i As Long
If IsMissing(pDoc) Then pDoc = ThisComponent lo_CustomTB = pDoc.getUIConfigurationManager.getUIElementsInfo(com.sun.star.ui.UIElementType.TOOLBAR) ReDim l_arrTB(UBound(lo_CustomTB), 2) As Variant i = 0 For Each lo_aTB In lo_CustomTB l_arrTB(i, 0) = lo_aTB(0).Value l_arrTB(i, 1) = lo_aTB(1).Value i = i + 1 Next CustomToolbarsToArray = l_arrTB() End Function |
LibOPrim |
Toolbars |
DeleteToolbar |
Basic |
|
184 |
13 |
Function DeleteToolbar(ByRef pToolbarName As String, Optional ByRef pDoc As Object) As Long
If IsMissing(pDoc) Then pDoc = ThisComponent
DeleteToolbar = _ToolbarCommand(pToolbarName, LOPRIM_TBCMD_DEL, pDoc) End Function |
LibOPrim |
Toolbars |
DisplayToolbar |
Basic |
|
198 |
14 |
Function DisplayToolbar(ByRef pToolbarName As String, Optional ByRef pDoc As Object) As Long
If IsMissing(pDoc) Then pDoc = ThisComponent
DisplayToolbar = _ToolbarCommand(pToolbarName, LOPRIM_TBCMD_VIEW, pDoc) End Function |
LibOPrim |
Toolbars |
GetToolbarResName |
Basic |
_ToolbarCommand (Procedure) |
213 |
30 |
Function GetToolbarResName(ByRef pDoc As Object, pUIToolbarName As String) As String
Dim lo_Mgr As Object Dim l_Items As Variant Dim l_Item As Variant Dim i As Long Dim l_Str As String l_Str = ""
If IsMissing(pDoc) Then pDoc = ThisComponent lo_Mgr = pDoc.getUIConfigurationManager() l_Items = lo_Mgr.getUIElementsInfo(com.sun.star.ui.UIElementType.TOOLBAR) For i = 0 To UBound(l_Items) l_Item = l_Items(i) If (_GetPropertyValueByName(l_Item, LOPRIM_TB_UINAME) = pUIToolbarName) Then If Not IsNull(l_Item) Then l_Str = _GetPropertyValueByName(l_Item, LOPRIM_TB_RESNAME) End If Exit For End If Next
GetToolbarResName = l_Str End Function |
LibOPrim |
Toolbars |
HideToolbar |
Basic |
SetFullScreen (Procedure) |
244 |
13 |
Function HideToolbar(ByRef pToolbarName As String, Optional ByRef pDoc As Object) As Long
If IsMissing(pDoc) Then pDoc = ThisComponent
HideToolbar = _ToolbarCommand(pToolbarName, LOPRIM_TBCMD_HIDE, pDoc) End Function |
LibOPrim |
Toolbars |
ToolbarVisible |
Basic |
|
258 |
15 |
Function ToolbarVisible(ByRef pToolbarName As String, Optional ByRef pDoc As Object) As Long
If IsMissing(pDoc) Then pDoc = ThisComponent
ToolbarVisible = _ToolbarCommand(pToolbarName, LOPRIM_TBCMD_VIS, pDoc) End Function |
LibOPrim |
UNO |
ImplementsUNOstruct |
Basic |
CustomPropertyType (Procedure) |
43 |
18 |
Function ImplementsUNOstruct(ByRef pStruct As Object, ByRef pStructName As String) As Boolean
Dim l_OK As Boolean l_OK = False If IsUnoStruct(pStruct) Then l_OK = (InStr(pStruct.Dbg_Properties, pStructName) > 0) End If ImplementsUNOstruct = l_OK End Function |
MathPrim |
Math |
_AverageTest |
Basic |
|
61 |
8 |
Sub _AverageTest()
Dim l_Array As Variant l_Array = Array(1, 10, 100) MsgBox Average(l_Array)
End Sub |
MathPrim |
Math |
Average |
Basic |
_AverageTest (Procedure) |
46 |
14 |
Function Average(ByRef pArray() As Variant) As Double
Dim l_Value As Double Dim i As Long l_Value = pArray(LBound(pArray)) For i = LBound(pArray) + 1 To UBound(pArray) l_Value = l_Value + pArray(i) Next Average = l_Value / (LBound(pArray) + UBound(pArray) + 1) End Function |
MathPrim |
Math |
BankersRound |
Basic |
|
70 |
25 |
Function BankersRound(ByRef pDecimals As Integer)
Dim l_Value As Double Dim l_Mult As Long On Local Error Goto ErrHandler: l_Mult = 10 ^ pDecimals l_Value = (pValue * l_Mult) + .05 l_Value = l_Value / l_Mult
ErrHandler: If Err Then l_Value = 0.0 BankersRound = l_Value end Function |
MathPrim |
Math |
Init |
Basic |
|
96 |
5 |
Sub Init()
SetEpsilon(MATH_DELTA) End Sub |
MathPrim |
Math |
IsDifferent |
Basic |
|
102 |
9 |
Function IsDifferent(ByRef pValue1 As Double, pValue2 As Double) As Boolean
IsDifferent = (Abs(pValue1 - pValue2) > mEpsilon) End Function |
MathPrim |
Math |
IsEqual |
Basic |
IsGreaterEqual (Procedure) IsLowerEqual (Procedure) |
112 |
9 |
Function IsEqual(ByRef pValue1 As Double, pValue2 As Double) As Boolean
IsEqual = (Abs(pValue1 - pValue2) <= mEpsilon) End Function |
MathPrim |
Math |
IsGreater |
Basic |
IsGreaterEqual (Procedure) IsInRange (Procedure) Max (Procedure) MaxInArray (Procedure) |
122 |
10 |
Function IsGreater(ByRef pValue1 As Double, pValue2 As Double) As Boolean
IsGreater = ((pValue1 - pValue2) > mEpsilon) End Function |
MathPrim |
Math |
IsGreaterEqual |
Basic |
IsInRange (Procedure) |
133 |
10 |
Function IsGreaterEqual(ByRef pValue1 As Double, pValue2 As Double) As Boolean
IsGreaterEqual = IsEqual(pValue1, pValue2) Or IsGreater(pValue1, pValue2) End Function |
MathPrim |
Math |
IsInRange |
Basic |
|
166 |
18 |
Function IsInRange(ByRef pValue As Double, pMin As Double, pMax As Double, Optional pExclusive As Boolean) As Boolean
If IsMissing(pExclusive) Then pExclusive = False If pExclusive Then IsInRange = IsGreater(pValue, pMin) And IsLower(pValue, pMax) Else IsInRange = IsGreaterEqual(pValue, pMin) And IsLowerEqual(pValue, pMax) End If End Function |
MathPrim |
Math |
IsLower |
Basic |
IsLowerEqual (Procedure) IsInRange (Procedure) Min (Procedure) MinInArray (Procedure) |
144 |
10 |
Function IsLower(ByRef pValue1 As Double, pValue2 As Double) As Boolean
IsLower = ((pValue1 - pValue2) < -mEpsilon) End Function |
MathPrim |
Math |
IsLowerEqual |
Basic |
IsInRange (Procedure) |
155 |
10 |
Function IsLowerEqual(ByRef pValue1 As Double, pValue2 As Double) As Boolean
IsLowerEqual = IsEqual(pValue1, pValue2) Or IsLower(pValue1, pValue2) End Function |
MathPrim |
Math |
Max |
Basic |
|
185 |
17 |
Function Max(ByRef pValue1 As Double, pValue2 As Double) As Double
Dim l_Value As Double If IsGreater(pValue1, pValue2) Then l_Value = pValue1 Else l_Value = pValue2 End If Max = l_Value End Function |
MathPrim |
Math |
MaxInArray |
Basic |
|
203 |
18 |
Function MaxInArray(ByRef pArray() As Variant) As Double
Dim l_Value As Double Dim i As Long l_Value = pArray(LBound(pArray)) For i = LBound(pArray) + 1 To UBound(pArray) If IsGreater(pArray(i), l_Value) Then l_Value = pArray(i) End If Next MaxInArray = l_Value End Function |
MathPrim |
Math |
MaxLng |
Basic |
|
222 |
14 |
Function MaxLng(ByRef pNum1 As Long, pNum2 As Long) As Long
If (pNum1 > pNum2) Then MaxLng = pNum1 Else MaxLng = pNum2 End If
End Function |
MathPrim |
Math |
Median |
Basic |
|
237 |
33 |
Function Median(ByRef pArray() As Variant) As Double
Dim l_Array As Variant Dim l_Item1 As Long Dim l_Item2 As Long Dim l_Sum As Double Dim l_Count As Long Dim l_Result As Double l_Array = QuickSort(pArray) l_Count = (UBound(l_Array) - LBound(l_Array)) + 1
If (UBound(l_Array) Mod 2 = 0) Then l_Item1 = (UBound(l_Array) / 2) + (LBound(l_Array) / 2) Else l_Item1 = Int(UBound(l_Array) / 2) + Int(LBound(l_Array) / 2) + 1 End If If (l_Count Mod 2 <> 0) Then l_Result = l_Array(l_Item1) Else l_Item2 = l_Item1 + 1 l_Sum = l_Array(l_Item1) + l_Array(l_Item2) l_Result = l_Sum / 2 End If
Median = l_Result End Function |
MathPrim |
Math |
Min |
Basic |
|
271 |
17 |
Function Min(ByRef pValue1 As Double, pValue2 As Double) As Double
Dim l_Value As Double If IsLower(pValue1, pValue2) Then l_Value = pValue1 Else l_Value = pValue2 End If Min = l_Value End Function |
MathPrim |
Math |
MinInArray |
Basic |
|
289 |
18 |
Function MinInArray(ByRef pArray() As Variant) As Double
Dim l_Value As Double Dim i As Long l_Value = pArray(LBound(pArray)) For i = LBound(pArray) + 1 To UBound(pArray) If IsLower(pArray(i), l_Value) Then l_Value = pArray(i) End If Next MinInArray = l_Value End Function |
MathPrim |
Math |
Round |
Basic |
|
308 |
25 |
Function Round(ByRef pValue As Double, pDecimals As Integer) As Double
Dim l_Value As Double Dim l_Mult As Long l_Value = 0.0 On Local Error Goto ErrHandler: l_Mult = 10 ^ pDecimals l_Value = (pValue * l_Mult) + .05 l_Value = l_Value / l_Mult ErrHandler: If Err Then l_Value = 0.0 Round = l_Value End Function |
MathPrim |
Math |
SetEpsilon |
Basic |
Init (Procedure) |
334 |
3 |
Sub SetEpsilon(ByRef pNewValue As Double) mEpsilon = pNewValue End Sub |
MathPrim |
Math |
SwapValues |
Basic |
|
338 |
9 |
Sub SwapValues(ByRef pValue1 As Variant, ByRef pValue2 As Variant)
Dim l_Tmp As Variant
l_Tmp = pValue1 pValue1 = pValue2 pValue2 = l_Tmp End Sub |
OSPrim |
OS |
GetOSName |
Basic |
IsLinux (Procedure) IsOSX (Procedure) IsWindows (Procedure) |
47 |
21 |
Function GetOSName() As String
Dim l_Num As Long Dim l_Name As String
l_Name = "" l_Num = GetGUIType() Select Case l_Num Case 1 l_Name = OSPRIM_OSWIN Case 3 l_Name = OSPRIM_OSMAC Case 4 l_Name = IIf(InStr(Environ("PATH"),"/usr/local/bin") = 0, OSPRIM_OSOSX, OSPRIM_OSLINUX) End Select GetOSName = l_Name End Function |
OSPrim |
OS |
IsLinux |
Basic |
|
69 |
8 |
Function IsLinux() As Boolean
Dim l_Name As String l_Name = GetOSName() IsLinux = (l_Name = OSPRIM_OSLINUX) End Function |
OSPrim |
OS |
IsOSX |
Basic |
|
78 |
8 |
Function IsOSX() As Boolean
Dim l_Name As String l_Name = GetOSName() IsOSX = (l_Name = OSPRIM_OSOSX) End Function |
OSPrim |
OS |
IsWindows |
Basic |
|
87 |
8 |
Function IsWindows() As Boolean
Dim l_Name As String l_Name = GetOSName() IsWindows = (l_Name = OSPRIM_OSWIN) End Function |
OSPrim |
OS |
RunCommand |
Basic |
|
96 |
8 |
Function RunCommand() As Long
Dim lo_ShellExec As Object
lo_ShellExec = createUnoService("com.sun.star.system.SystemShellExecute") End Function |
Standard |
Install |
_AddLibrary |
Basic |
AddBasicLibrary (Procedure) |
28 |
30 |
Function _AddLibrary(ByRef pLib, pGlobalLib As Object, ByVal pSrcLib, pDestLib As String, pForce As Boolean)
Dim oSrcLib As Object Dim oDestLib As Object Dim i As Integer Dim sSrcModules() As String
If Not pGlobalLib.hasByName(pDestLib) Then pGlobalLib.createLibrary(pDestLib) Else _AddLibrary = 1 Exit Function End If
If pLib.hasByName(pSrcLib) Then pLib.loadLibrary(pSrcLib) oSrcLib = pLib.getByName(pSrcLib) sSrcModules = oSrcLib.getElementNames() i = LBound(sSrcModules()) While( i <= uBound(sSrcModules())) oDestLib = pGlobalLib.getByName(pDestLib) If Not oDestLib.hasByName(sSrcModules(i)) Then oDestLib.insertByName(sSrcModules(i), oSrcLib.getByName(sSrcModules(i))) End If i = i + 1 Wend End If _AddLibrary = 0 End Function |
Standard |
Install |
_CheckLibrary |
Basic |
AddBasicLibrary (Procedure) |
7 |
19 |
Function _CheckLibrary(ByRef pGlobalLib As Object, ByVal pDestLib As String)
Dim l_OK Dim i As Integer
If pGlobalLib.hasByName(pDestLib) Then l_OK = (MsgBox("The " & pDestLib & " global library already exists." & Chr(13) & Chr(13) & "Do you want to replace it?", _ MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION, _ "Confirmation") = IDYES) If l_OK Then pGlobalLib.removeLibrary(pDestLib) End If Else l_OK = True End If
_CheckLibrary = l_OK End Function |
Standard |
Install |
AddBasicLibrary |
Basic |
|
60 |
28 |
Sub AddBasicLibrary
Dim SrcLibraryName As String Dim DestLibraryName As String Dim oLib As Object Dim oGlobalLib As Object Dim l_Err As Integer SrcLibraryName = "CSVlib" DestLibraryName = "CSVlib" l_Err = -1 oLib = BasicLibraries oGlobalLib = GlobalScope.BasicLibraries If _CheckLibrary(oGlobalLib, DestLibraryName) Then l_Err = _AddLibrary(oLib, oGlobalLib, SrcLibraryName, DestLibraryName) End If
If (l_Err = 0) Then MsgBox("The " & DestLibraryName & " library was installed.") Else MsgBox("The " & DestLibraryName & " already exists!") End If End Sub |
StringsPrim |
Strings |
DelChar |
Basic |
DelSpaces (Procedure) |
44 |
9 |
Function DelChar(ByRef pStr As String, pChar As String) As String
DelChar = Join(Split(pStr, pChar), "") End Function |
StringsPrim |
Strings |
DelSpaces |
Basic |
|
54 |
22 |
Function DelSpaces(ByRef pStr As String, Optional pUnBreak As Boolean) As String
Dim l_Str As String If IsMissing(pUnBreak) Then pUnBreak = False l_Str = DelChar(pStr, Chr(32)) If pUnBreak Then l_Str = DelChar(l_Str, Chr(160)) DelSpaces = l_Str End Function |
StringsPrim |
Strings |
FilterNonPrintableStr |
Basic |
NTFSFileNameString (Procedure) |
77 |
21 |
Function FilterNonPrintableStr(ByRef pStr As String) As String
Dim l_Char As String Dim l_Str As String Dim i As Long Dim j As Long
l_Str = "" For i = 1 To Len(pStr) l_Char = Mid(pStr, i, 1) If (Asc(l_Char) > 31) Then l_Str = l_Str & l_Char End If Next i FilterNonPrintableStr = l_Str End Function |
StringsPrim |
Strings |
LeftPad |
Basic |
|
99 |
9 |
Function LeftPad(ByRef pStr As String, pPadChar As String, pLength As Long) As String
LeftPad = Right(String(pLength, pPadChar) & pStr, pLength) End Function |
StringsPrim |
Strings |
NoAccentStr |
Basic |
NTFSFileNameString (Procedure) |
109 |
28 |
Function NoAccentStr(ByRef pStr As String) As String
Const CHAR_ACC = "ÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöùúûüýÿ" Const CHAR_NOACC = "AAAAACEEEEIIIINOOOOOUUUUYaaaaaaceeeeiiiinooooouuuuyy"
Dim i As Long Dim j As Long Dim l_Char As String Dim l_Str As String
l_Str = "" For i = 1 To Len(pStr) l_Char = Mid(pStr, i, 1) j = InStr(CHAR_ACC, l_Char) If (j > 0) Then l_Str = l_Str & Mid(CHAR_NOACC, j, 1) Else l_Str = l_Str & l_Char End If Next i NoAccentStr = l_Str End Function |
StringsPrim |
Strings |
QuoteStr |
Basic |
|
138 |
19 |
Function QuoteStr(ByRef pStr As String, pQuoteChar As String) As String
If (Left(pStr, 1) <> pQuoteChar) Or (Right(pStr, 1) <> pQuoteChar) Then QuoteStr = pQuoteChar & pStr & pQuoteChar Else QuoteStr = pStr End If End Function |
StringsPrim |
Strings |
ReplaceStr |
Basic |
NTFSFileNameString (Procedure) CalcShareFileName (Procedure) LockFileName (Procedure) SuppressMultipleChars (Procedure) |
158 |
7 |
Function ReplaceStr(ByRef pStr As String, pSearchStr As String, pReplStr As String) As String
ReplaceStr = Join(Split(pStr, pSearchStr), pReplStr) End Function |
StringsPrim |
Strings |
RightPad |
Basic |
|
166 |
15 |
Function RightPad(ByRef pStr As String, pPadChar As String, pLength As Long) As String
RightPad = Left(pStr & String(pLength, pPadChar), pLength) End Function |
StringsPrim |
Strings |
StripChars |
Basic |
NTFSFileNameString (Procedure) |
182 |
24 |
Function StripChars(ByRef pStr As String, pStripChars As String) As String
Dim l_Str As String Dim l_Char As String Dim i As Long
l_Str = "" For i = 1 To Len(pStr) l_Char = Mid(pStr, i, 1) If (InStr(pStripChars, l_Char) = 0) Then l_Str = l_Str & l_Char End If Next i
StripChars = l_Str End Function |
StringsPrim |
Strings |
SuppressMultipleChars |
Basic |
ChangeFileExt (Procedure) |
207 |
16 |
Function SuppressMultipleChars(ByRef pStr As String, pChar As String) As String
Dim l_Search As String l_Search = Left(pChar, 1) & Left(pChar, 1) Do While InStr(1, pStr, l_Search) pStr = ReplaceStr(pStr, l_Search, pChar) Loop
SuppressMultipleChars = pStr End Function |
StringsPrim |
Strings |
TitleCase |
Basic |
|
223 |
49 |
Function TitleCase(ByRef pStr As String) As String
Dim l_Str As String Dim l_StrUC As String Dim l_SplitChars As String Dim l_arrItems As Variant Dim l_StrTmp As String Dim l_CurSplit As String Dim j As Long Dim i As Long
If (pStr = "") Then l_Str = pStr Else l_SplitChars = " '’-" & Chr(160) l_Str = LCase(pStr) l_Str = UCase(Left(l_Str, 1)) & Right(l_Str, Len(l_Str) - 1) For i = 1 to Len(l_SplitChars) l_CurSplit = Mid(l_SplitChars, i, 1) l_arrItems = Split(l_Str, l_CurSplit) If (UBound(l_arrItems) > 0) Then l_StrTmp = "" l_Str = "" For j = 0 to UBound(l_arrItems) l_StrUC = UCase(Left(l_arrItems(j), 1)) & Right(l_arrItems(j), Len(l_arrItems(j)) - 1) If (j > 0) Then l_StrTmp = l_StrTmp & l_CurSplit & l_StrUC Else l_StrTmp = l_StrTmp & l_StrUC End If Next l_Str = l_Str & l_StrTmp End If Next End If TitleCase = l_Str End Function |
StringsPrim |
Strings |
TrimEx |
Basic |
|
273 |
49 |
Function TrimEx(ByRef pStr As String) As String
Dim l_Str As String Dim l_Char As String Dim i As Long Dim l_Nb160 As Long l_Str = Trim(pStr) If (Len(l_Str) > 0) Then l_Nb160 = 0 For i = 1 To Len(l_Str) l_Char = Mid(l_Str, i, 1) If (Asc(l_Char) = Chr(160)) Then l_Nb160 = l_Nb160 + 1 Else Exit For End If Next If (l_Nb160 > 0) Then l_Str = Right(l_Str, Len(l_Str) - l_Nb160) End If l_Nb160 = 0 For i = Len(l_Str) To 1 Step -1 l_Char = Mid(l_Str, i, 1) If (Asc(l_Char) = Chr(160)) Then l_Nb160 = l_Nb160 + 1 Else Exit For End If Next If (l_Nb160 > 0) Then l_Str = Left(l_Str, Len(l_Str) - l_Nb160) End If End If
TrimEx = l_Str End Function |
StringsPrim |
Strings |
UnQuoteStr |
Basic |
|
323 |
10 |
Function UnQuoteStr(ByRef pStr As String, pQuoteChar As String) As String
If (Left(pStr, 1) = pQuoteChar) And (Right(pStr, 1) = pQuoteChar) Then UnQuoteStr = Mid(pStr, 2, Len(pStr) - 2) Else UnQuoteStr = pStr End If End Function |
WriterPrim |
Autotexts |
_CreateHiddenDocument |
Basic |
AddAutoTexts (Procedure) |
371 |
13 |
Function _CreateHiddenDocument() As Object
Dim lo_Doc As Object Dim l_Props(0) As New com.sun.star.beans.PropertyValue l_Props(0).Name = "Hidden" l_Props(0).Value = True lo_Doc = StarDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, l_Props()) _CreateHiddenDocument = lo_Doc End Function |
WriterPrim |
Autotexts |
AddAutoText |
Basic |
|
66 |
61 |
Function AddAutoText(ByRef pGroupName As String, pTitle As String, pShortcut As String, _ pText As Object, Optional pUpdate As Boolean) As Long
Dim lo_AutotextGroup As Object Dim lo_AutoText As Object Dim l_Shortcut As String Dim l_Err As Long
l_Err = ERR_AUTOTEXT_NONE If IsMissing(pUpdate) Then pUpdate = False
l_Shortcut = Trim(pShortcut) If (l_Shortcut <> "") Then lo_AutotextGroup = GetAutoTextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then If lo_AutotextGroup.hasByName(l_Shortcut) And pUpdate Then l_Err = UpdateAutoText(pGroupName, pTitle, l_Shortcut, pText) Else If Not lo_AutotextGroup.hasByName(l_Shortcut) Then On Local Error Resume Next lo_AutoText = lo_AutotextGroup.insertNewByName(l_Shortcut, pTitle, pText) If Err Then l_Err = ERR_AUTOTEXT_CANTCREATE End If Else l_Err = ERR_AUTOTEXT_EXISTS End If End If Else l_Err = ERR_AUTOTEXTGROUP_UNKNOWN End If Else l_Err = ERR_AUTOTEXT_SHORTCUT End If AddAutoText = l_Err End Function |
WriterPrim |
Autotexts |
AddAutotextGroup |
Basic |
|
128 |
50 |
Function AddAutotextGroup(ByRef pGroupName As String, Optional ByRef pLocal As Boolean, _ Optional ByRef pReplace As Boolean) As Long
Dim lo_AutoTextContainer As Object Dim lo_AutotextGroup As Object Dim l_Err As Long
l_Err = ERR_AUTOTEXT_NONE
If IsMissing(pLocal) Then pLocal = True If IsMissing(pReplace) Then pReplace = False
lo_AutoTextContainer = CreateAutoTextContainer()
If lo_AutoTextContainer.hasByName(pGroupName) And pReplace Then lo_AutoTextContainer.removeByName(pGroupName) End If If Not lo_AutoTextContainer.hasByName(pGroupName) Then On Local Error Resume Next lo_AutotextGroup = lo_AutoTextContainer.insertNewByName(AutotextGroupID(pGroupName, pLocal)) If Err Then l_Err = ERR_AUTOTEXTGROUP_CANTCREATE Else lo_AutotextGroup.Title = pGroupName End If Else l_Err = ERR_AUTOTEXTGROUP_EXISTS End If
AddAutotextGroup = l_Err End Function |
WriterPrim |
Autotexts |
AddAutoTexts |
Basic |
|
179 |
40 |
Function AddAutoTexts(ByRef pGroupName As String, ByRef pAutoTextArray() As Variant) As Long
Dim lo_Doc As Object Dim l_Props(0) As New com.sun.star.beans.PropertyValue Dim lo_AutotextGroup As Object Dim lo_AutoText As Object Dim lo_TextCursor As Object Dim l_Count As Long Dim i As Long l_Count = -1 lo_AutotextGroup = GetAutoTextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then lo_Doc = _CreateHiddenDocument() If Not IsNull(lo_Doc) Then lo_TextCursor = lo_Doc.Text.CreateTextCursor l_Count = 0 For i = 0 To UBound(pAutoTextArray()) If Trim(pAutoTextArray(i, 0) <> "") Then lo_TextCursor.String = pAutoTextArray(i, 2) lo_AutoText = NewAutoText(lo_AutotextGroup, pAutoTextArray(i, 1), pAutoTextArray(i, 0), lo_TextCursor) If Not IsNull(lo_AutoText) Then l_Count = l_Count + 1 End If Next lo_Doc = Nothing End If End If AddAutoTexts = l_Count End Function |
WriterPrim |
Autotexts |
AddRawAutoTexts |
Basic |
|
220 |
34 |
Function AddRawAutoTexts(ByRef pGroupName As String, ByRef pAutoTextArray() As Variant) As Long
Dim lo_AutotextGroup As Object Dim lo_AutoText As Object Dim lo_TextRange As Object Dim l_Count As Long Dim i As Long l_Count = -1 lo_AutotextGroup = GetAutoTextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then l_Count = 0 lo_TextRange = CreateUnoService(SVC_TEXTRANGE) For i = 0 To UBound(pAutoTextArray()) If Trim(pAutoTextArray(i, 0) <> "") Then lo_TextRange.String = pAutoTextArray(i, 2) lo_AutoText = NewAutoText(lo_AutotextGroup, pAutoTextArray(i, 1), pAutoTextArray(i, 0), lo_TextRange) If Not IsNull(lo_AutoText) Then l_Count = l_Count + 1 End If Next End If AddRawAutoTexts = l_Count End Function |
WriterPrim |
Autotexts |
AutoTextExists |
Basic |
|
318 |
18 |
Function AutoTextExists(ByRef pGroupName As String, pShortcut As String) As Boolean
Dim lo_AutotextGroup As Object Dim l_Exists As Boolean l_Exists = False lo_AutotextGroup = GetAutoTextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then l_Exists = lo_AutotextGroup.hasByName(pShortcut) End If
AutotextGroupExists = l_Exists End Function |
WriterPrim |
Autotexts |
AutotextGroupExists |
Basic |
AutoTextExists (Procedure) |
255 |
12 |
Function AutotextGroupExists(ByRef pGroupName As String) As Boolean
Dim l_Exists As Boolean l_Exists = (AutotextGroupNameIndex(pGroupName) > -1)
AutotextGroupExists = l_Exists End Function |
WriterPrim |
Autotexts |
AutotextGroupID |
Basic |
AddAutotextGroup (Procedure) NewAutotextGroup (Procedure) |
268 |
19 |
Function AutotextGroupID(ByRef pGroupName As String, ByRef pLocal As Boolean) As String
Dim l_ID As String
l_ID = Trim(pGroupName) & "*" & CStr(Abs(CInt(pLocal))) AutotextGroupID = l_ID End Function |
WriterPrim |
Autotexts |
AutotextGroupNameIndex |
Basic |
AutotextGroupExists (Procedure) GetAutotextGroupByName (Procedure) |
288 |
29 |
Function AutotextGroupNameIndex(ByRef pGroupName As String) As Long
Dim lo_AutoTextContainer As Object Dim l_Exists As Boolean Dim i As Long lo_AutoTextContainer = CreateAutoTextContainer() i = 0 l_Exists = False Do While (i < lo_AutoTextContainer.Count) And Not l_Exists l_Exists = (lo_AutoTextContainer.ElementNames(i) = pGroupName) i = i + 1 Loop If l_Exists Then i = i - 1 Else i = -1 End If AutotextGroupNameIndex = i End Function |
WriterPrim |
Autotexts |
AutoTextShortcutIndex |
Basic |
RenameAutoText (Procedure) UpdateAutoText (Procedure) UpdateAutoTextTitle (Procedure) |
337 |
25 |
Function AutoTextShortcutIndex(ByRef pGroup As Object, pShortcut As String) As Long
Dim l_Exists As Boolean Dim i As Long i = 0 l_Exists = False Do While (i < pGroup.Count) And Not l_Exists l_Exists = (pGroup.ElementNames(i) = pShortcut) i = i + 1 Loop If l_Exists Then i = i - 1 Else i = -1 End If AutoTextShortcutIndex = i End Function |
WriterPrim |
Autotexts |
CreateAutoTextContainer |
Basic |
AddAutotextGroup (Procedure) AutotextGroupNameIndex (Procedure) DeleteAutotextGroupByName (Procedure) GetAutotextGroupByIndex (Procedure) GetAutotextGroupNames (Procedure) NewAutotextGroup (Procedure) |
363 |
7 |
Function CreateAutoTextContainer() As Object
CreateAutoTextContainer = CreateUnoService(SVC_AUTOCONTAINER) End Function |
WriterPrim |
Autotexts |
DeleteAutoTextByShortcut |
Basic |
|
415 |
40 |
Function DeleteAutoTextByShortcut(ByRef pGroupName As String, pShortcut As String) As Long
Dim lo_AutotextGroup As Object Dim l_Shortcut As String Dim l_Err As Long
l_Err = ERR_AUTOTEXT_NONE l_Shortcut = Trim(pShortcut) If (l_Shortcut <> "") Then lo_AutotextGroup = GetAutoTextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then If lo_AutotextGroup.hasByName(l_Shortcut) Then On Local Error Resume Next lo_AutotextGroup.removeByName(l_ShortCut) If Err Then l_Err = ERR_AUTOTEXT_CANTDELETE End If End If Else l_Err = ERR_AUTOTEXTGROUP_UNKNOWN End If Else l_Err = ERR_AUTOTEXT_SHORTCUT End If
DeleteAutoTextByShortcut = l_Err End Function |
WriterPrim |
Autotexts |
DeleteAutotextGroupByName |
Basic |
|
385 |
29 |
Function DeleteAutotextGroupByName(ByRef pGroupName As String) As Long
Dim lo_AutoTextContainer As Object Dim l_Err As Long
l_Err = ERR_AUTOTEXT_NONE lo_AutoTextContainer = CreateAutoTextContainer() If lo_AutoTextContainer.hasByName(pGroupName) Then On Local Error Resume Next lo_AutoTextContainer.removeByName(pGroupName) If Err Then l_Err = ERR_AUTOTEXTGROUP_CANTDELETE End If Else l_Err = ERR_AUTOTEXTGROUP_UNKNOWN End If
DeleteAutotextGroupByName = l_Err End Function |
WriterPrim |
Autotexts |
GetAutoTextByShortcut |
Basic |
|
515 |
19 |
Function GetAutoTextByShortcut(ByRef pGroupName As String, pShortcut As String) As Object
Dim lo_AutotextGroup As Object Dim lo_AutoText As Object lo_AutotextGroup = GetAutoTextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then If lo_AutotextGroup.hasByName(pShortcut) Then lo_AutoText = lo_AutotextGroup.getByName(pShortcut) End If End If GetAutoTextByShortcut = lo_AutoText End Function |
WriterPrim |
Autotexts |
GetAutotextGroupByIndex |
Basic |
GetAutotextGroupByName (Procedure) |
456 |
17 |
Function GetAutotextGroupByIndex(ByRef pIndex As Long) As Object
Dim lo_AutoTextContainer As Object Dim lo_AutotextGroup As Object If (pIndex > -1) Then lo_AutoTextContainer = CreateAutoTextContainer() On Local Error Resume Next lo_AutotextGroup = lo_AutoTextContainer.getByIndex(pIndex) End If GetAutotextGroupByIndex = lo_AutotextGroup End Function |
WriterPrim |
Autotexts |
GetAutotextGroupByName |
Basic |
AddAutoText (Procedure) AddAutoTexts (Procedure) AddRawAutoTexts (Procedure) AutoTextExists (Procedure) DeleteAutoTextByShortcut (Procedure) GetAutoTextByShortcut (Procedure) GetAutoTextShortcuts (Procedure) GetAutoTextTitles (Procedure) RenameAutoText (Procedure) UpdateAutoText (Procedure) UpdateAutoTextTitle (Procedure) |
474 |
16 |
Function GetAutotextGroupByName(ByRef pGroupName As String) As Object
Dim lo_AutotextGroup As Object Dim i As Long i = AutotextGroupNameIndex(pGroupName) If (i > -1) Then lo_AutotextGroup = GetAutotextGroupByIndex(i) End If GetAutotextGroupByName = lo_AutotextGroup End Function |
WriterPrim |
Autotexts |
GetAutotextGroupNames |
Basic |
|
491 |
23 |
Function GetAutotextGroupNames() As Variant
Dim lo_AutoTextContainer As Object Dim lo_AutotextGroup As Object Dim l_Array() As Variant Dim i As Long lo_AutoTextContainer = CreateAutoTextContainer()
i = lo_AutoTextContainer.Count - 1 ReDim l_Array(i) For i = 0 To lo_AutoTextContainer.Count - 1 lo_AutotextGroup = lo_AutoTextContainer.getByIndex(i) l_Array(i) = lo_AutotextGroup.Title Next
GetAutotextGroupNames = l_Array() End Function |
WriterPrim |
Autotexts |
GetAutoTextShortcuts |
Basic |
|
535 |
16 |
Function GetAutoTextShortcuts(ByRef pGroupName As String) As Variant
Dim lo_AutotextGroup As Object Dim l_Array() As Variant
lo_AutotextGroup = GetAutotextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then l_Array = lo_AutotextGroup.ElementNames
GetAutoTextShortcuts = l_Array() End Function |
WriterPrim |
Autotexts |
GetAutoTextTitles |
Basic |
|
552 |
16 |
Function GetAutoTextTitles(ByRef pGroupName As String) As Variant
Dim lo_AutotextGroup As Object Dim l_Array() As Variant
lo_AutotextGroup = GetAutotextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then l_Array = lo_AutotextGroup.Titles
GetAutoTextTitles = l_Array() End Function |
WriterPrim |
Autotexts |
NewAutoText |
Basic |
AddAutoTexts (Procedure) AddRawAutoTexts (Procedure) RenameAutoText (Procedure) |
610 |
35 |
Function NewAutoText(ByRef pGroup As Object, pTitle As String, pShortcut As String, _ pText As Object, Optional pUpdate As Boolean) As Object
Dim lo_AutoText As Object
If IsMissing(pUpdate) Then pUpdate = False
If Not IsNull(pGroup) Then If pGroup.hasByName(pShortcut) And pUpdate Then UpdateAutoText(pGroup.Title, pTitle, pShortcut, pText) Else If Not pGroup.hasByName(pShortcut) Then On Local Error Resume Next lo_AutoText = pGroup.insertNewByName(pShortcut, pTitle, pText) End If End If End If
NewAutoText = lo_AutoText End Function |
WriterPrim |
Autotexts |
NewAutotextGroup |
Basic |
|
569 |
40 |
Function NewAutotextGroup(ByRef pGroupName As String, ByRef pLocal As Boolean, _ Optional ByRef pReplace As Boolean) As Object
Dim lo_AutoTextContainer As Object Dim lo_AutotextGroup As Object If IsMissing(pReplace) Then pReplace = False
lo_AutoTextContainer = CreateAutoTextContainer()
If lo_AutoTextContainer.hasByName(pGroupName) And pReplace Then On Local Error Resume Next lo_AutoTextContainer.removeByName(pGroupName) End If If Not lo_AutoTextContainer.hasByName(pGroupName) Then On Local Error Resume Next lo_AutotextGroup = lo_AutoTextContainer.insertNewByName(AutotextGroupID(pGroupName, pLocal)) If Not IsNull(lo_AutotextGroup) Then lo_AutotextGroup.Title = pGroupName End If Else lo_AutotextGroup = lo_AutoTextContainer.getByName(pGroupName) End If
NewAutotextGroup = lo_AutotextGroup End Function |
WriterPrim |
Autotexts |
RenameAutoText |
Basic |
UpdateAutoText (Procedure) |
646 |
60 |
Function RenameAutoText(ByRef pGroupName As String, ByRef pOldShortcut As String, ByRef pNewShortcut As String) As Long
Dim lo_AutotextGroup As Object Dim l_OldShortcut As String Dim l_NewShortcut As String Dim l_OldIndex As Long Dim lo_OldAutoText As Object Dim lo_NewAutoText As Object Dim l_Err As Long l_Err = ERR_AUTOTEXT_NONE l_OldShortcut = Trim(pOldShortcut) l_NewShortcut = Trim(pNewShortcut) If (l_OldShortcut <> "") And (l_NewShortcut <> "") Then lo_AutotextGroup = GetAutotextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then If lo_AutotextGroup.hasByName(l_OldShortcut) Then l_OldIndex = AutoTextShortcutIndex(lo_AutotextGroup, l_OldShortcut) lo_OldAutoText = lo_AutotextGroup.getByIndex(l_OldIndex) If Not lo_AutotextGroup.hasByName(l_NewShortcut) Then lo_NewAutoText = NewAutoText(lo_AutotextGroup, lo_AutotextGroup.Titles(l_OldIndex), l_NewShortCut, lo_OldAutoText.Text) If Not IsNull(lo_NewAutoText) Then lo_AutotextGroup.removeByName(l_OldShortcut) Else l_Err = ERR_AUTOTEXT_CANTCREATE End If Else l_Err = ERR_AUTOTEXT_EXISTS End If Else l_Err = ERR_AUTOTEXT_UNKNOWN End If Else l_Err = ERR_AUTOTEXTGROUP_UNKNOWN End If Else l_Err = ERR_AUTOTEXT_SHORTCUT End If RenameAutoText = l_Err End Function |
WriterPrim |
Autotexts |
UpdateAutoText |
Basic |
AddAutoText (Procedure) NewAutoText (Procedure) |
707 |
73 |
Function UpdateAutoText(ByRef pGroupName As String, pTitle As String, pShortcut As String, pNewText As Object) As Long
Dim lo_AutotextGroup As Object Dim lo_UpdAutoText As Object Dim l_Shortcut As String Dim l_TempShortcut As String Dim l_Title As String Dim i As Long Dim l_Err As Long l_Err = ERR_AUTOTEXT_NONE l_Shortcut = Trim(pShortcut) If (l_Shortcut <> "") Then lo_AutotextGroup = GetAutotextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then If lo_AutotextGroup.hasByName(l_Shortcut) Then If (Trim(pTitle) = "") Then i = AutoTextShortcutIndex(lo_AutotextGroup, l_Shortcut) l_Title = lo_AutotextGroup.Titles(i) Else l_Title = pTitle End If l_TempShortcut = l_Shortcut & "_TEMPUPD" l_Err = RenameAutoText(pGroupName, l_ShortCut, l_TempShortcut) If (l_Err = ERR_AUTOTEXT_NONE) Then On Local Error Resume Next lo_UpdAutoText = lo_AutotextGroup.insertNewByName(l_Shortcut, l_Title, pNewText) If Err Then l_Err = ERR_AUTOTEXT_CANTCREATE Else lo_AutotextGroup.removeByName(l_TempShortcut) End If End If Else l_Err = ERR_AUTOTEXT_UNKNOWN End If Else l_Err = ERR_AUTOTEXTGROUP_UNKNOWN End If Else l_Err = ERR_AUTOTEXT_SHORTCUT End If UpdateAutoText = l_Err End Function |
WriterPrim |
Autotexts |
UpdateAutoTextTitle |
Basic |
|
781 |
55 |
Function UpdateAutoTextTitle(ByRef pGroupName As String, pNewTitle As String, pShortcut As String) As Long
Dim lo_AutotextGroup As Object Dim lo_TextRange As Object Dim lo_CurAutoText As Object Dim lo_UpdAutoText As Object Dim l_Shortcut As String Dim l_TempShortcut As String Dim i As Long Dim l_Err As Long l_Err = ERR_AUTOTEXT_NONE l_Shortcut = Trim(pShortcut) If (l_Shortcut <> "") Then If (Trim(pNewTitle) <> "") Then lo_AutotextGroup = GetAutotextGroupByName(pGroupName) If Not IsNull(lo_AutotextGroup) Then i = AutoTextShortcutIndex(lo_AutotextGroup, l_Shortcut) If (i > -1) Then lo_AutotextGroup.Titles(i) = pNewTitle Else l_Err = ERR_AUTOTEXT_UNKNOWN End If Else l_Err = ERR_AUTOTEXTGROUP_UNKNOWN End If Else l_Err = ERR_AUTOTEXT_TITLE End If Else l_Err = ERR_AUTOTEXT_SHORTCUT End If
UpdateAutoTextTitle = l_Err End Function |
WriterPrim |
Bookmarks |
CreateBookmark |
Basic |
|
42 |
30 |
Function CreateBookmark(ByRef pBookmarkName As String, ByRef pCursor As Object, Optional ByRef pDoc As Object) As Object
Dim lo_Anchor As Object If IsMissing(pDoc) Then pDoc = ThisComponent
If Not IsNull(pCursor) And (Trim(pBookmarkName) <> "") Then lo_Anchor = pDoc.createInstance("com.sun.star.text.Bookmark") lo_Anchor.setName(pBookmarkName) On Local Error GoTo ErrHandler: pDoc.Text.insertTextContent(pCursor, lo_Anchor, False) End If ErrHandler: CreateBookmark = lo_Anchor End Function |
WriterPrim |
Bookmarks |
GotoBookmark |
Basic |
|
73 |
37 |
Function GotoBookmark(ByRef pBookmarkName As String, Optional ByRef pSelect As Boolean, Optional ByRef pVisible As Boolean, Optional ByRef pDoc As Object) As Object
Dim lo_Bookmark As Object Dim lo_Cur As Object Dim lo_Bookmarks As Object If IsMissing(pSelect) Then pSelect = False If IsMissing(pVisible) Then pVisible = True If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Bookmarks = pDoc.Bookmarks If lo_Bookmarks.hasByName(pBookmarkName) Then lo_Bookmark = lo_Bookmarks.getByName(pBookmarkName) If pVisible Then lo_Cur = pDoc.CurrentController.ViewCursor Else lo_Cur = pDoc.Text.createTextCursor End If lo_Cur.gotoRange(lo_Bookmark.Anchor, pSelect) End If GotoBookmark = lo_Bookmark End Function |
WriterPrim |
Bookmarks |
GotoBookmarkFromCursor |
Basic |
|
111 |
30 |
Function GotoBookmarkFromCursor(ByRef pBookmarkName As String, ByRef pCursor As Object, Optional pSelect As Boolean, Optional ByRef pDoc As Object) As Object
Dim lo_Bookmark As Object Dim lo_Cur As Object Dim lo_Bookmarks As Object If IsMissing(pSelect) Then pSelect = False If IsMissing(pDoc) Then pDoc = ThisComponent
lo_Bookmarks = pDoc.Bookmarks If lo_Bookmarks.hasByName(pBookmarkName) Then lo_Bookmark = lo_Bookmarks.getByName(pBookmarkName) pCursor.gotoRange(lo_Bookmark.Anchor, pSelect) End If GotoBookmarkFromCursor = lo_Bookmark End Function |
WriterPrim |
Bookmarks |
RemoveBookmark |
Basic |
|
142 |
33 |
Function RemoveBookmark(ByRef pBookmarkName As String, Optional ByRef pDoc As Object) As Boolean
Dim lo_Bookmarks As Object Dim lo_Bookmark As Object Dim lo_Anchor As Object Dim l_OK As Boolean If IsMissing(pDoc) Then pDoc = ThisComponent l_OK = False lo_Bookmarks = pDoc.Bookmarks If lo_Bookmarks.hasByName(pBookmarkName) Then lo_Bookmark = lo_Bookmarks.getByName(pBookmarkName) On Local Error GoTo ErrHandler: pDoc.Text.removeTextContent(lo_Bookmark) l_OK = True End If ErrHandler: RemoveBookmark = l_OK End Function |
WriterPrim |
Fields |
CreateMasterField |
Basic |
ExportMasterFields (Procedure) |
54 |
37 |
Function CreateMasterField(ByRef pFieldName As String, Optional pValue As Variant, Optional pDoc As Object) As Boolean
Dim lo_Masters As Object Dim lo_Master As Object Dim l_OK As Boolean l_OK = False If (Trim(pFieldName) <> "") Then If IsMissing(pDoc) Then pDoc = ThisComponent On Local Error Goto ErrHandler: lo_Masters = pDoc.TextFieldMasters If Not lo_Masters.hasByName(MFLD_USERSERVICE & pFieldName) Then lo_Master = pDoc.createInstance(MFLD_USERINSTANCE) lo_Master.Name = pFieldName End If If Not IsMissing(pValue) Then lo_Master = lo_Masters.getByName(MFLD_USERSERVICE & pFieldName) lo_Master.Content = pValue End If End If
ErrHandler: If Err Then l_OK = False CreateMasterField = l_OK End Function |
WriterPrim |
Fields |
DeleteAllMasterFields |
Basic |
|
92 |
34 |
Function DeleteAllMasterFields(Optional pDoc As Object) As Boolean
Dim lo_Masters As Object Dim lo_Master As Object Dim l_MasterName As String Dim l_OK As Boolean Dim i As Long l_OK = False If IsMissing(pDoc) Then pDoc = ThisComponent
On Local Error Goto ErrHandler lo_Masters = pDoc.TextFieldMasters For i = UBound(lo_Masters.ElementNames()) To LBound(lo_Masters.ElementNames()) Step -1 l_MasterName = lo_MastersSrc.ElementNames(i) If IsMasterFieldUser(l_MasterName) Then If lo_Masters.hasByName(l_MasterName) Then lo_Master = lo_Masters.getByName(l_MasterName) lo_Master.dispose l_OK = True End If End If Next i ErrHandler: l_OK = Not Err
DeleteAllMasterFields = l_OK End Function |
WriterPrim |
Fields |
DeleteMasterField |
Basic |
|
127 |
28 |
Function DeleteMasterField(ByRef pFieldName As String, Optional pDoc As Object) As Boolean
Dim lo_Masters As Object Dim lo_Master As Object Dim l_OK As Boolean l_OK = False If IsMissing(pDoc) Then pDoc = ThisComponent
On Local Error Goto ErrHandler: lo_Masters = pDoc.TextFieldMasters If lo_Masters.hasByName(MFLD_USERSERVICE & pFieldName) Then lo_Master = lo_Masters.getByName(MFLD_USERSERVICE & pFieldName) lo_Master.dispose l_OK = True End If ErrHandler: l_OK = Not Err
DeleteMasterField = l_OK End Function |
WriterPrim |
Fields |
ExportMasterFields |
Basic |
|
156 |
37 |
Function ExportMasterFields(ByRef pTargetDoc As Object, Optional pSourceDoc As Object) As Boolean
Dim lo_MastersSrc As Object Dim l_FieldName As String Dim l_Value As Variant Dim l_OK As Boolean Dim i As Long l_OK = False If IsMissing(pSourceDoc) Then pSourceDoc = ThisComponent
On Local Error Goto FuncEnd:
lo_MastersSrc = pSourceDoc.TextFieldMasters For i = LBound(lo_MastersSrc.ElementNames()) To UBound(lo_MastersSrc.ElementNames()) l_FieldName = lo_MastersSrc.ElementNames(i) If IsMasterFieldUser(l_FieldName) Then l_FieldName = GetMasterFieldNameOnly(l_FieldName) l_Value = GetMasterFieldValue(l_FieldName, pSourceDoc) CreateMasterField(l_FieldName, l_Value, pTargetDoc) End If Next l_OK = True FuncEnd: ExportMasterFields = l_OK End Function |
WriterPrim |
Fields |
GetMasterFieldNameOnly |
Basic |
ExportMasterFields (Procedure) |
194 |
20 |
Function GetMasterFieldNameOnly(ByRef pFieldName As String) As String
Dim l_Name As String Dim l_arrParts() As String l_Name = ""
If (Trim(pFieldName) <> "") Then l_arrParts = Split(pFieldName, ".") l_Name = l_arrParts(UBound(l_arrParts)) End If GetMasterFieldNameOnly = l_Name End Function |
WriterPrim |
Fields |
GetMasterFieldType |
Basic |
|
215 |
23 |
Function GetMasterFieldType(ByRef pFieldName As String) As Long
Dim l_IsUser As Boolean Dim l_IsExpr As Boolean Dim l_Type As Long l_Type = MFLD_TYPE_UNK l_IsUser = (InStr(pFieldName, UF_TYPEUSERID) > 0) If l_IsUser Then l_Type = MFLD_TYPE_USER Else l_IsExpr = (InStr(pFieldName, UF_TYPEEXPRID) > 0) If l_IsExpr Then l_Type = MFLD_TYPE_EXPR End If End If
GetMasterFieldType = l_Type End Function |
WriterPrim |
Fields |
GetMasterFieldValue |
Basic |
ExportMasterFields (Procedure) |
239 |
27 |
Function GetMasterFieldValue(ByRef pFieldName As String, Optional pDoc As Object) As Variant
Dim lo_Masters As Object Dim lo_Master As Object Dim l_Result As Variant
l_Result = Nothing
If (Trim(pFieldName) <> "") Then If IsMissing(pDoc) Then pDoc = ThisComponent lo_Masters = pDoc.TextFieldMasters lo_Master = lo_Masters.getByName(MFLD_USERSERVICE & pFieldName) IF Not IsNull(lo_Master) Then l_Result = lo_Master.Content End If End If GetUserFieldValue = l_Result End Function |
WriterPrim |
Fields |
IsMasterFieldUser |
Basic |
DeleteAllMasterFields (Procedure) ExportMasterFields (Procedure) |
267 |
17 |
Function IsMasterFieldUser(ByRef pFieldName As String) As Boolean
Dim l_IsUser As Boolean l_IsUser = False If (Trim(pFieldName) <> "") Then l_IsUser = (InStr(pFieldName, MFLD_TYPEUSERID) > 0) End If
IsMasterFieldUser = l_IsUser End Function |
WriterPrim |
Fields |
SetMasterFieldValue |
Basic |
|
285 |
24 |
Sub SetMasterFieldValue(ByRef pFieldName As String, pValue As Variant, Optional pDoc As Object)
Dim lo_Masters As Object Dim lo_Master As Object
If (Trim(pFieldName) <> "") Then If IsMissing(pDoc) Then pDoc = ThisComponent lo_Masters = pDoc.TextFieldMasters lo_Master = lo_Masters.getByName(MFLD_USERSERVICE & pFieldName) IF Not IsNull(lo_Master) Then lo_Master.Content = pValue End If End If End Sub |
WriterPrim |
Styles |
GetStyleAtCursor |
Basic |
GetTableActualWidth (Procedure) |
48 |
56 |
Function GetStyleAtCursor(ByRef pTextCursor As Object, pStyleFamily As String) As Object
Dim lo_Styles As Object Dim lo_Style As Object Dim l_Name As String If Not IsNull(pTextCursor) Then Select Case pStyleFamily Case STY_WFAMPAGES l_Name = pTextCursor.PageStyleName Case STY_WFAMPARAS l_Name = pTextCursor.ParaStyleName
Case STY_WFAMCHARS If Not IsNull(pTextCursor.CharStyleNames) Then l_Name = pTextCursor.CharStyleNames(0) Else l_Name = "" End If Case STY_WFAMFRAMES l_Name = "" Case STY_WFAMNUMBER l_Name = pTextCursor.NumberingStyleName Case STY_WFAMTABLES l_Name = "" Case Else l_Name = "" End Select If (l_Name <> "") Then lo_Styles = ThisComponent.StyleFamilies.getByName(pStyleFamily) If lo_Styles.hasByName(l_Name) Then lo_Style = lo_Styles.getByName(l_Name) End If End If End If GetStyleAtCursor = lo_Style End Function |
WriterPrim |
Tables |
GetColumnWidths |
Basic |
|
43 |
71 |
Function GetColumnWidths(ByRef pTableName As String, pRowNum As Long, Optional pDoc As Object) As Variant
Dim l_arrWidths As Long Dim l_Width As Long Dim l_RelWidth As Long Dim l_ActualWidth As Long Dim l_ColWidth As Double Dim l_Total As Long Dim lo_Table As Object Dim l_ColCount As Long Dim l_Seps As Variant Dim i As Long If IsMissing(pDoc) Then pDoc = ThisComponent If pDoc.TextTables.hasByName(pTableName) Then lo_Table = ThisComponent.TextTables.getByName(pTableName) l_RelWidth = lo_Table.TableColumnRelativeSum l_ActualWidth = GetTableActualWidth(lo_Table) If lo_Table.IsWidthRelative Then l_Width = Int(lo_Table.RelativeWidth * l_ActualWidth / 100) Else l_Width = lo_Table.Width End If
If (pRowNum = -1) Then l_Seps = lo_Table.TableColumnSeparators Else If (pRowNum > -1) And (pRowNum < lo_Table.Rows.Count) Then l_Seps = lo_Table.Rows(pRowNum).TableColumnSeparators Else GetColumnWidths = l_arrWidths Exit Function End If End If l_ColCount = UBound(l_Seps) + 2 ReDim l_arrWidths(l_ColCount - 1) l_Total = 0 For i = 0 To l_ColCount - 1 If (i = l_ColCount - 1) Then l_ColWidth = l_Width - l_Total ElseIf (i = 0) Then l_ColWidth = l_Seps(i).Position / l_RelWidth * l_Width Else l_ColWidth = (l_Seps(i).Position - l_Seps(i-1).Position) / l_RelWidth * l_Width End If l_arrWidths(i) = Int(l_ColWidth / l_Width * l_ActualWidth) l_Total = l_Total + l_ColWidth Next End If GetColumnWidths = l_arrWidths() End Function |
WriterPrim |
Tables |
GetTableActualWidth |
Basic |
GetColumnWidths (Procedure) |
115 |
18 |
Function GetTableActualWidth(ByRef pTable As Object) As Long
Dim l_Width As Long Dim lo_Style As Object lo_Style = GetStyleAtCursor(pTable.getCellByPosition(0, 0).Text.createTextCursor, STY_WFAMPAGES) If Not IsNull(lo_Style) Then l_Width = lo_Style.Width - lo_Style.LeftMargin - lo_Style.RightMargin - pTable.LeftMargin - pTable.RightMargin End If GetTableActualWidth = l_Width End Function |
WriterPrim |
Tables |
GetTableColCountByName |
Basic |
|
134 |
26 |
Function GetTableColCountByName(ByRef pTableName As String, pRowNum As Long, Optional pDoc As Object) As Long
Dim lo_Table As Object Dim l_Seps As Variant Dim l_ColCount As Long If IsMissing(pDoc) Then pDoc = ThisComponent
l_ColCount = -1 If pDoc.TextTables.hasByName(pTableName) Then lo_Table = ThisComponent.TextTables.getByName(pTableName) If (pRowNum > -1) And (pRowNum < lo_Table.Rows.Count) Then l_Seps = lo_Table.Rows(pRowNum).TableColumnSeparators l_ColCount = UBound(l_Seps) + 2 End If End If
GetTableColCountByName = l_ColCount End Function |
WriterPrim |
Tables |
GetTableRowCountByName |
Basic |
|
161 |
22 |
Function GetTableRowCountByName(ByRef pTableName As String, Optional pDoc As Object) As Long
Dim lo_Table As Object Dim l_RowCount As Long If IsMissing(pDoc) Then pDoc = ThisComponent If pDoc.TextTables.hasByName(pTableName) Then lo_Table = ThisComponent.TextTables.getByName(pTableName) l_RowCount = lo_Table.Rows.Count Else l_RowCount = -1 End If
GetTableRowCountByName = l_RowCount End Function |
WriterPrim |
Tables |
LockCell |
Basic |
|
184 |
15 |
Sub LockCell(ByRef pTableName As String, pCellName As String, pLock As Boolean)
Dim lo_Table As Object Dim lo_Cell As Object lo_Table = ThisComponent.TextTables.getByName(pTableName) If Not IsNull(lo_Table) Then lo_Cell = lo_Table.getCellByName(pCellName) If Not IsNull(l_Cell) Then lo_Cell.IsProtected = pLock End If End If
End Sub |
WriterPrim |
Text |
GetSelection |
Basic |
|
43 |
32 |
Function GetSelection(Optional pNearestWord As Boolean, Optional ByRef pDoc As Object) As Object
Dim lo_VCur As Object Dim lo_TCur As Object Dim lo_Text As Object If IsMissing(pDoc) Then pDoc = ThisComponent If IsNull(pDoc) Then Exit Function If IsMissing(pNearestWord) Then pNearestWord = False lo_VCur = pDoc.CurrentController.ViewCursor lo_Text = lo_VCur.Text lo_TCur = lo_Text.CreateTextCursorByRange(lo_VCur) If (lo_TCur.String = "") And pNearestWord Then lo_TCur.gotoStartOfWord(False) lo_TCur.gotoEndOfWord(True) End If GetSelection = lo_TCur End Function |
WriterPrim |
Text |
HasSelection |
Basic |
|
76 |
44 |
Function HasSelection(Optional ByRef pDoc As Object) As Boolean
Dim lo_Sel As Object Dim lo_ASel As Object Dim lo_TCur As Object Dim l_Found As Boolean
l_Found = False If IsMissing(pDoc) Then pDoc = ThisComponent If IsNull(pDoc) Then Exit Function
lo_Sel = pDoc.CurrentSelection If Not IsNull(lo_Sel) Then Select Case lo_Sel.Count Case 0 Case 1 lo_ASel = lo_Sel.getByIndex(0) lo_TCur = pDoc.Text.CreateTextCursorByRange(oSel) l_Found = Not lo_TCur.IsCollapsed() Case Else l_Found = True End Select End If HasSelection = l_Found End Function |