?prevdifflink? - Blame
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Properties" script:language="StarBasic">REM ***** BASIC *****
Option Explicit
'
' TODO
' - check if the added expansion is valid
'
' *****************************************************************************
REM Gets document object properties
Function GetUserProperties (oDoc As Object) As Object
GetUserProperties = oDoc.DocumentProperties.UserDefinedProperties
End Function
' *****************************************************************************
' *** CLASSES *****************************************************************
' *****************************************************************************
' *** Property name: ClassSheet
' *** Format:
' *** - List = ClassSheet
' *** - | ClassSheet ';' List
' *** - ClassSheet = name ',' range ',' depth ',' color
' *** note: the order of the items consists of a depth-first traversal
' FIXME remove Global
Global Const PropertyClasses = "ClassSheet"
' *****************************************************************************
' *** EXPANSIONS **************************************************************
' *****************************************************************************
' *** Property name: ClassSheetExp
' *** Format:
' *** - List = Expansion
' *** - | Expansion ';' List
' *** - Expansion = classname ',' range ',' Type
' *** - Type = 0 // expand columns
' *** - | n // expand rows, where n >= 1, and is unique for each class
' *** note: the list is ordered by classname and then by expansion type
Const PropertyExpansions = "ClassSheetExp"
REM Adds an expansion to the list
Function AddExpansion (oDoc As Object, class As String, oRange As Object, expType As Integer) As String
Dim exp As String
Dim expansions As Object
Dim newList(0) As String
Dim pos As Integer
Dim newExp As String : newExp = ""
expansions = Split( GetUserProperties( oDoc ), ";" )
If LBound( expansions ) <= UBound( expansions ) Then
ReDim newList(UBound(expansions) + 1) As String
End If
' try to insert the expansion in the list
For i = LBound( expansions ) To UBound( expansions )
exp = expansions(i)
If class = GetExpansionName( exp ) And expType = GetExpansionType( expType ) Then
AddExpansion = ""
Exit Function
End If
If class < GetExpansionName( exp ) Then
' insert here
newExp = class & "," & HaExcel.RangeToString( oDoc, oRange ) & "," & expType
newList(i) = newExp
pos = i
Exit For
End If
newList(i) = expansions(i)
Next i
' add to the end of the list if it was not inserted
If newExp = "" Then
newExp
newList( pos ) = class & "," & HaExcel.RangeToString( oDoc, oRange ) & "," & expType
pos = pos + 1
Else
' copy the rest to the list
For i = pos To UBound( expansions )
newList(i+1) = expansions(i)
Next i
End If
AddExpansion = join(newList, ";")
End Function
' *****************************************************************************
REM Gets the expansions from the list
Function GetExpansions (oDoc As Object) As Object
Dim oUserProperties, exps As Object
Dim strExps As String
oUserProperties = GetUserProperties( oDoc )
strExps = oUserProperties.getPropertyValue( PropertyExpansions )
exps = Split( strExps, ";" )
GetExpansions = exps
End Function
' *****************************************************************************
REM Gets data of expansion from the list
Function GetExpansion (class As String, expType As Integer) As String
Dim expansions As Object
expansions = Split( GetUserProperties( oDoc ), ";" )
For i = LBound( expansions ) To UBound( expansions )
c = GetExpansionName( expansions(i) )
t = GetExpansionType( expansions(i) )
If c = class And t = expType Then
GetExpansion = expansions(i)
Exit Function
End If
Next i
GetExpansion = ""
End Function
' *****************************************************************************
REM Gets the name of the given expansion
Function GetExpansionName (expansion As String) As String
Dim values As Object
values = Split( expansion, "," )
GetExpansionName = values(0)
End Function
' *****************************************************************************
REM Gets the range (as string) of the given expansion
Function GetExpansionRangeName (expansion As String) As String
Dim values As Object
values = Split( expansion, "," )
GetExpansionRangeName = values(1)
End Function
' *****************************************************************************
REM Gets the type of the given expansion
Function GetExpansionType (expansion As String) As Integer
Dim values As Object
values = Split( expansion, "," )
GetExpansionType = CInt( values(2) )
End Function
</script:module>
Generated by GNU Enscript 1.6.5.90.
|