1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*3e02b54dSAndrew Rist<!--*********************************************************** 4*3e02b54dSAndrew Rist * 5*3e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 6*3e02b54dSAndrew Rist * or more contributor license agreements. See the NOTICE file 7*3e02b54dSAndrew Rist * distributed with this work for additional information 8*3e02b54dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 9*3e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the 10*3e02b54dSAndrew Rist * "License"); you may not use this file except in compliance 11*3e02b54dSAndrew Rist * with the License. You may obtain a copy of the License at 12*3e02b54dSAndrew Rist * 13*3e02b54dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 14*3e02b54dSAndrew Rist * 15*3e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing, 16*3e02b54dSAndrew Rist * software distributed under the License is distributed on an 17*3e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18*3e02b54dSAndrew Rist * KIND, either express or implied. See the License for the 19*3e02b54dSAndrew Rist * specific language governing permissions and limitations 20*3e02b54dSAndrew Rist * under the License. 21*3e02b54dSAndrew Rist * 22*3e02b54dSAndrew Rist ***********************************************************--> 23cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Common" script:language="StarBasic">REM ***** BASIC ***** 24cdf0e10cSrcweirOption Explicit 25cdf0e10cSrcweir 26cdf0e10cSrcweir 27cdf0e10cSrcweirFunction LoadNewStyles(oDocument as Object, oDialogModel as Object, CurIndex as Integer, SourceFile as String, Styles() as String, TextureDir as String) as Boolean 28cdf0e10cSrcweirDim BackGroundURL as String 29cdf0e10cSrcweirDim oBackGraph as Object 30cdf0e10cSrcweirDim i, BackColor as Long 31cdf0e10cSrcweirDim bLocWithBackGraphic as Boolean 32cdf0e10cSrcweirDim oFamilies as Object, oFamily as Object', oStyle as Object 33cdf0e10cSrcweirDim StylesOptions(0) as New com.sun.star.beans.PropertyValue 34cdf0e10cSrcweir 35cdf0e10cSrcweir If SourceFile <> "" Then 36cdf0e10cSrcweir StylesOptions(0).Name = "OverwriteStyles" 37cdf0e10cSrcweir StylesOptions(0).Value = True 38cdf0e10cSrcweir oDocument.StyleFamilies.LoadStylesFromURL(SourceFile, StylesOptions()) 39cdf0e10cSrcweir End If 40cdf0e10cSrcweir 41cdf0e10cSrcweir ' Read array fields for background, bullet & graphics 42cdf0e10cSrcweir BackgroundURL = Styles(CurIndex, 7) 43cdf0e10cSrcweir If Left(BackgroundURL, 1) <> "#" Then 44cdf0e10cSrcweir BackgroundURL = TextureDir + BackgroundURL 45cdf0e10cSrcweir bLocWithBackGraphic = True 46cdf0e10cSrcweir Else 47cdf0e10cSrcweir BackColor = clng("&H" & Right(BackgroundURL, Len(BackgroundURL)-1)) 48cdf0e10cSrcweir bLocWithBackGraphic = False 49cdf0e10cSrcweir End If 50cdf0e10cSrcweir oFamilies = oDocument.StyleFamilies 51cdf0e10cSrcweir oFamily = oFamilies.GetbyName("PageStyles") 52cdf0e10cSrcweir For i = 0 To oFamily.Count - 1 53cdf0e10cSrcweir If oFamily.GetByIndex(i).IsInUse Then 54cdf0e10cSrcweir oStyle = oFamily.GetbyIndex(i) 55cdf0e10cSrcweir If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then 56cdf0e10cSrcweir If Left(BackgroundURL, 1) = "#" Then 57cdf0e10cSrcweir oStyle.BackGraphicURL = "" 58cdf0e10cSrcweir oStyle.BackColor = BackColor 59cdf0e10cSrcweir oStyle.BackTransparent = False 60cdf0e10cSrcweir Else 61cdf0e10cSrcweir oStyle.BackGraphicUrl = BackGroundURL 62cdf0e10cSrcweir SetTileBackgroundorNot(oDialogModel, oStyle) 63cdf0e10cSrcweir End If 64cdf0e10cSrcweir Exit For 65cdf0e10cSrcweir End If 66cdf0e10cSrcweir End If 67cdf0e10cSrcweir Next i 68cdf0e10cSrcweir LoadNewStyles() = bLocWithBackGraphic 69cdf0e10cSrcweirErrorOcurred: 70cdf0e10cSrcweir If Err <> 0 Then 71cdf0e10cSrcweir MsgBox (WebWiz_gErrWhileLoadStyles$, 16, WebWiz_gWizardName$) 72cdf0e10cSrcweir RESUME EXITSUB 73cdf0e10cSrcweirEXITSUB: 74cdf0e10cSrcweir End If 75cdf0e10cSrcweirEnd Function 76cdf0e10cSrcweir 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweirSub ChangeBackGraphicUrl(SavePath as String) 80cdf0e10cSrcweirDim oPageFamily as Object 81cdf0e10cSrcweirDim i as Integer 82cdf0e10cSrcweir oPageFamily = oBaseDocument.StyleFamilies.GetbyName("PageStyles") 83cdf0e10cSrcweir For i = 0 To oPageFamily.Count - 1 84cdf0e10cSrcweir If oPageFamily.GetByIndex(i).IsInUse Then 85cdf0e10cSrcweir oStyle = oPageFamily.GetbyIndex(i) 86cdf0e10cSrcweir If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then 87cdf0e10cSrcweir If oStyle.BackGraphicUrl <> "" Then 88cdf0e10cSrcweir oStyle.BackGraphicUrl = CopyFile(oStyle.BackGraphicUrl, SavePath) 89cdf0e10cSrcweir Exit Sub 90cdf0e10cSrcweir End If 91cdf0e10cSrcweir End If 92cdf0e10cSrcweir End If 93cdf0e10cSrcweir Next i 94cdf0e10cSrcweirEnd Sub 95cdf0e10cSrcweir 96cdf0e10cSrcweir 97cdf0e10cSrcweirSub SetBackGraphicStyle(oEvent as Object) 98cdf0e10cSrcweirDim oFamilies as Object 99cdf0e10cSrcweirDim oFamily as Object 100cdf0e10cSrcweirDim i as Integer 101cdf0e10cSrcweirDim oOptModel as Object 102cdf0e10cSrcweirDim iBackgroundValue as Integer 103cdf0e10cSrcweirDim oLocDocument as Object 104cdf0e10cSrcweir ooptModel = oEvent.Source.Model 105cdf0e10cSrcweir iBackgroundValue = Val(ooptModel.Tag) 106cdf0e10cSrcweir oLocDocument = StarDesktop.ActiveFrame.Controller.Model 107cdf0e10cSrcweir oLocDocument.LockControllers 108cdf0e10cSrcweir oFamilies = oLocDocument.StyleFamilies 109cdf0e10cSrcweir oFamily = oFamilies.GetbyName("PageStyles") 110cdf0e10cSrcweir For i = 0 To oFamily.Count - 1 111cdf0e10cSrcweir If oFamily.GetByIndex(i).IsInUse Then 112cdf0e10cSrcweir oStyle = oFamily.GetbyIndex(i) 113cdf0e10cSrcweir If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then 114cdf0e10cSrcweir oStyle.BackGraphicLocation = iBackgroundValue 115cdf0e10cSrcweir End If 116cdf0e10cSrcweir End If 117cdf0e10cSrcweir Next i 118cdf0e10cSrcweir oLocDocument.UnlockControllers 119cdf0e10cSrcweirEnd Sub 120cdf0e10cSrcweir 121cdf0e10cSrcweir 122cdf0e10cSrcweirSub SetTileBackgroundorNot(DialogModel as Object, oStyle as Object) 123cdf0e10cSrcweir If Not IsNull(DialogModel) Then 124cdf0e10cSrcweir If DialogModel.optTiled.State = 1 Then 125cdf0e10cSrcweir oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.TILED 126cdf0e10cSrcweir Else 127cdf0e10cSrcweir oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.AREA 128cdf0e10cSrcweir End If 129cdf0e10cSrcweir End If 130cdf0e10cSrcweirEnd Sub 131cdf0e10cSrcweir 132cdf0e10cSrcweir 133cdf0e10cSrcweirSub ToggleOptionButtons(DialogModel as Object, bDoEnable as Integer) 134cdf0e10cSrcweir If Not IsNull(DialogModel) Then 135cdf0e10cSrcweir DialogModel.optTiled.Enabled = bDoEnable 136cdf0e10cSrcweir DialogModel.optArea.Enabled = bDoEnable 137cdf0e10cSrcweir DialogModel.hlnBackground.Enabled = bDoEnable 138cdf0e10cSrcweir End If 139cdf0e10cSrcweirEnd Sub 140cdf0e10cSrcweir 141cdf0e10cSrcweir 142cdf0e10cSrcweirFunction GetCurIndex(oListbox as Object, sList() as String, FileIndex as Integer) 143cdf0e10cSrcweirDim i as Integer 144cdf0e10cSrcweirDim n as Integer 145cdf0e10cSrcweirDim SelValue as String 146cdf0e10cSrcweirDim MaxIndex as Integer 147cdf0e10cSrcweir If IsNull(oListBox) Then 148cdf0e10cSrcweir ' Startup for WebWizard 149cdf0e10cSrcweir SelValue = sList(0,1) 150cdf0e10cSrcweir Else 151cdf0e10cSrcweir n = oListbox.SelectedItems(0) 152cdf0e10cSrcweir SelValue = oListbox.StringItemList(n) 153cdf0e10cSrcweir End If 154cdf0e10cSrcweir ' Find field index for chosen list entry 155cdf0e10cSrcweir MaxIndex = Ubound(sList) 156cdf0e10cSrcweir For i = 0 To MaxIndex 157cdf0e10cSrcweir If sList(i,1) = SelValue Then 158cdf0e10cSrcweir FileStr = sList(i, FileIndex) 159cdf0e10cSrcweir Exit For 160cdf0e10cSrcweir End If 161cdf0e10cSrcweir Next 162cdf0e10cSrcweir GetCurIndex = i 163cdf0e10cSrcweirEnd Function 164cdf0e10cSrcweir 165*3e02b54dSAndrew Rist</script:module> 166