1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Common" script:language="StarBasic">REM ***** BASIC ***** 4Option Explicit 5 6 7Function LoadNewStyles(oDocument as Object, oDialogModel as Object, CurIndex as Integer, SourceFile as String, Styles() as String, TextureDir as String) as Boolean 8Dim BackGroundURL as String 9Dim oBackGraph as Object 10Dim i, BackColor as Long 11Dim bLocWithBackGraphic as Boolean 12Dim oFamilies as Object, oFamily as Object', oStyle as Object 13Dim StylesOptions(0) as New com.sun.star.beans.PropertyValue 14 15 If SourceFile <> "" Then 16 StylesOptions(0).Name = "OverwriteStyles" 17 StylesOptions(0).Value = True 18 oDocument.StyleFamilies.LoadStylesFromURL(SourceFile, StylesOptions()) 19 End If 20 21 ' Read array fields for background, bullet & graphics 22 BackgroundURL = Styles(CurIndex, 7) 23 If Left(BackgroundURL, 1) <> "#" Then 24 BackgroundURL = TextureDir + BackgroundURL 25 bLocWithBackGraphic = True 26 Else 27 BackColor = clng("&H" & Right(BackgroundURL, Len(BackgroundURL)-1)) 28 bLocWithBackGraphic = False 29 End If 30 oFamilies = oDocument.StyleFamilies 31 oFamily = oFamilies.GetbyName("PageStyles") 32 For i = 0 To oFamily.Count - 1 33 If oFamily.GetByIndex(i).IsInUse Then 34 oStyle = oFamily.GetbyIndex(i) 35 If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then 36 If Left(BackgroundURL, 1) = "#" Then 37 oStyle.BackGraphicURL = "" 38 oStyle.BackColor = BackColor 39 oStyle.BackTransparent = False 40 Else 41 oStyle.BackGraphicUrl = BackGroundURL 42 SetTileBackgroundorNot(oDialogModel, oStyle) 43 End If 44 Exit For 45 End If 46 End If 47 Next i 48 LoadNewStyles() = bLocWithBackGraphic 49ErrorOcurred: 50 If Err <> 0 Then 51 MsgBox (WebWiz_gErrWhileLoadStyles$, 16, WebWiz_gWizardName$) 52 RESUME EXITSUB 53EXITSUB: 54 End If 55End Function 56 57 58 59Sub ChangeBackGraphicUrl(SavePath as String) 60Dim oPageFamily as Object 61Dim i as Integer 62 oPageFamily = oBaseDocument.StyleFamilies.GetbyName("PageStyles") 63 For i = 0 To oPageFamily.Count - 1 64 If oPageFamily.GetByIndex(i).IsInUse Then 65 oStyle = oPageFamily.GetbyIndex(i) 66 If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then 67 If oStyle.BackGraphicUrl <> "" Then 68 oStyle.BackGraphicUrl = CopyFile(oStyle.BackGraphicUrl, SavePath) 69 Exit Sub 70 End If 71 End If 72 End If 73 Next i 74End Sub 75 76 77Sub SetBackGraphicStyle(oEvent as Object) 78Dim oFamilies as Object 79Dim oFamily as Object 80Dim i as Integer 81Dim oOptModel as Object 82Dim iBackgroundValue as Integer 83Dim oLocDocument as Object 84 ooptModel = oEvent.Source.Model 85 iBackgroundValue = Val(ooptModel.Tag) 86 oLocDocument = StarDesktop.ActiveFrame.Controller.Model 87 oLocDocument.LockControllers 88 oFamilies = oLocDocument.StyleFamilies 89 oFamily = oFamilies.GetbyName("PageStyles") 90 For i = 0 To oFamily.Count - 1 91 If oFamily.GetByIndex(i).IsInUse Then 92 oStyle = oFamily.GetbyIndex(i) 93 If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then 94 oStyle.BackGraphicLocation = iBackgroundValue 95 End If 96 End If 97 Next i 98 oLocDocument.UnlockControllers 99End Sub 100 101 102Sub SetTileBackgroundorNot(DialogModel as Object, oStyle as Object) 103 If Not IsNull(DialogModel) Then 104 If DialogModel.optTiled.State = 1 Then 105 oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.TILED 106 Else 107 oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.AREA 108 End If 109 End If 110End Sub 111 112 113Sub ToggleOptionButtons(DialogModel as Object, bDoEnable as Integer) 114 If Not IsNull(DialogModel) Then 115 DialogModel.optTiled.Enabled = bDoEnable 116 DialogModel.optArea.Enabled = bDoEnable 117 DialogModel.hlnBackground.Enabled = bDoEnable 118 End If 119End Sub 120 121 122Function GetCurIndex(oListbox as Object, sList() as String, FileIndex as Integer) 123Dim i as Integer 124Dim n as Integer 125Dim SelValue as String 126Dim MaxIndex as Integer 127 If IsNull(oListBox) Then 128 ' Startup for WebWizard 129 SelValue = sList(0,1) 130 Else 131 n = oListbox.SelectedItems(0) 132 SelValue = oListbox.StringItemList(n) 133 End If 134 ' Find field index for chosen list entry 135 MaxIndex = Ubound(sList) 136 For i = 0 To MaxIndex 137 If sList(i,1) = SelValue Then 138 FileStr = sList(i, FileIndex) 139 Exit For 140 End If 141 Next 142 GetCurIndex = i 143End Function 144 145</script:module>