1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?> 2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*b1cdbd2cSJim Jagielski<!--*********************************************************** 4*b1cdbd2cSJim Jagielski * 5*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 6*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 7*b1cdbd2cSJim Jagielski * distributed with this work for additional information 8*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 9*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 10*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 11*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 14*b1cdbd2cSJim Jagielski * 15*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 16*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 17*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 19*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 20*b1cdbd2cSJim Jagielski * under the License. 21*b1cdbd2cSJim Jagielski * 22*b1cdbd2cSJim Jagielski ***********************************************************--> 23*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="HtmlAutoPilotBasic" script:language="StarBasic">' Variables must be declared 24*b1cdbd2cSJim JagielskiOption Explicit 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim JagielskiPublic CurDocIndex as Integer 27*b1cdbd2cSJim JagielskiPublic CurWebPageIndex as Integer 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim JagielskiPublic bWithBackGraphic as Boolean 31*b1cdbd2cSJim JagielskiPublic oStyle as Object 32*b1cdbd2cSJim Jagielski' Maximum number of content templates, style templates and bullets 33*b1cdbd2cSJim JagielskiConst MaxLayouts = 50 34*b1cdbd2cSJim JagielskiConst MaxStyles = 100 35*b1cdbd2cSJim JagielskiConst MaxBullets = 10 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielski'Public NumberOfLayouts%, NumberOfStyles% 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski' Filled with title, previous, next, home, top, bullet, background, file name 40*b1cdbd2cSJim JagielskiPublic Style(MaxStyles, 8) as String 41*b1cdbd2cSJim Jagielski 42*b1cdbd2cSJim JagielskiPublic Layout$(MaxLayouts, 2) 43*b1cdbd2cSJim Jagielski 44*b1cdbd2cSJim JagielskiPublic TextureDir$, BulletDir$, GraphicsDir$, GalleryDir$, PhotosDir$ 45*b1cdbd2cSJim JagielskiPublic SOBitmapPath as String 46*b1cdbd2cSJim JagielskiPublic CurrentBullet$, CurrentPrev$, CurrentNext$, CurrentHome$, CurrentTop$ 47*b1cdbd2cSJim JagielskiPublic FileStr as String 48*b1cdbd2cSJim Jagielski 49*b1cdbd2cSJim JagielskiPublic WebWiz_gWizardName$, WebWiz_gErrContentNotFound$, WebWiz_gErrStyleNotFound$ 50*b1cdbd2cSJim JagielskiPublic WebWiz_gErrMainTemplateError$, WebWiz_gErrWhileReloading$ 51*b1cdbd2cSJim JagielskiPublic WebWiz_gErrWhileLoadStyles$, WebWiz_gErrMsg$, WebWiz_gErrMainDocumentError$ 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim JagielskiPublic ProgressBar as Object 54*b1cdbd2cSJim JagielskiPublic ProgressValue As Long 55*b1cdbd2cSJim JagielskiPublic oBaseDocument as Object 56*b1cdbd2cSJim JagielskiPublic oViewCursor as Object 57*b1cdbd2cSJim JagielskiPublic oViewSettings as Object 58*b1cdbd2cSJim JagielskiPublic NoArgs() as New com.sun.star.beans.PropertyValue 59*b1cdbd2cSJim Jagielski 60*b1cdbd2cSJim JagielskiPublic oCursor as Object 61*b1cdbd2cSJim JagielskiPublic oBookmarks as Object 62*b1cdbd2cSJim JagielskiPublic oBookMark as Object 63*b1cdbd2cSJim Jagielski 64*b1cdbd2cSJim JagielskiPublic oUcb as Object 65*b1cdbd2cSJim JagielskiPublic MainDialog as Object 66*b1cdbd2cSJim JagielskiPublic DialogModel as Object 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski 69*b1cdbd2cSJim JagielskiSub Main 70*b1cdbd2cSJim JagielskiDim RetValue 71*b1cdbd2cSJim JagielskiOn Local Error Goto GlobalErrorHandler 72*b1cdbd2cSJim Jagielski BasicLibraries.LoadLibrary("Tools") 73*b1cdbd2cSJim Jagielski oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") 74*b1cdbd2cSJim Jagielski oBaseDocument = StarDesktop.LoadComponentFromURL("private:factory/swriter/web", "_default", 0, NoArgs()) 75*b1cdbd2cSJim Jagielski oViewSettings = oBaseDocument.CurrentController.ViewSettings 76*b1cdbd2cSJim Jagielski oViewCursor = oBaseDocument.GetCurrentController.ViewCursor 77*b1cdbd2cSJim Jagielski CurWebPageIndex = -1 78*b1cdbd2cSJim Jagielski ProgressBar = oBaseDocument.GetCurrentController.GetFrame.CreateStatusIndicator 79*b1cdbd2cSJim Jagielski ProgressBar.Start("", 100) 80*b1cdbd2cSJim Jagielski SetProgressValue(2) 81*b1cdbd2cSJim Jagielski oBaseDocument.LockControllers 82*b1cdbd2cSJim Jagielski oViewSettings.ShowTableBoundaries = False 83*b1cdbd2cSJim Jagielski If Not GetWebWizardPaths() Then 84*b1cdbd2cSJim Jagielski Exit Sub 85*b1cdbd2cSJim Jagielski End If 86*b1cdbd2cSJim Jagielski LoadLanguage 87*b1cdbd2cSJim Jagielski SetProgressValue(10) 88*b1cdbd2cSJim Jagielski Layout() = getListBoxArrays(oUcb, "/cnt") 89*b1cdbd2cSJim Jagielski GetCurIndex(DialogModel, Layout(),2) 90*b1cdbd2cSJim Jagielski SetProgressValue(30) 91*b1cdbd2cSJim Jagielski oCursor = oBasedocument.Text.CreateTextCursor 92*b1cdbd2cSJim Jagielski oCursor.InsertDocumentfromURL(FileStr, NoArgs()) 93*b1cdbd2cSJim Jagielski SetProgressValue(50) 94*b1cdbd2cSJim Jagielski Style() = getListBoxArrays(oUcb, "/stl") 95*b1cdbd2cSJim Jagielski SetProgressValue(70) 96*b1cdbd2cSJim Jagielski LoadWebPageStyles(oBaseDocument) 97*b1cdbd2cSJim Jagielski SetProgressValue(90) 98*b1cdbd2cSJim Jagielski oBaseDocument.UnlockControllers 99*b1cdbd2cSJim Jagielski OpenWebDialog() 100*b1cdbd2cSJim Jagielski SetProgressValue(98) 101*b1cdbd2cSJim Jagielski SetProgressValue(0) 102*b1cdbd2cSJim Jagielski MainDialog.Model.ImagePreview.BackGroundColor = RGB(0, 60,126) 103*b1cdbd2cSJim Jagielski RetValue = MainDialog.Execute 104*b1cdbd2cSJim Jagielski Select Case RetValue 105*b1cdbd2cSJim Jagielski Case 0 106*b1cdbd2cSJim Jagielski MainDialog.Dispose() 107*b1cdbd2cSJim Jagielski DisposeDocument(oBaseDocument) 108*b1cdbd2cSJim Jagielski Case 1 109*b1cdbd2cSJim Jagielski EndDialog() 110*b1cdbd2cSJim Jagielski MainDialog.Dispose() 111*b1cdbd2cSJim Jagielski End Select 112*b1cdbd2cSJim JagielskiGLOBALERRORHANDLER: 113*b1cdbd2cSJim Jagielski If Err <> 0 Then 114*b1cdbd2cSJim Jagielski MsgBox (WebWiz_gErrMsg$, 16, WebWiz_gWizardName$) 115*b1cdbd2cSJim Jagielski DisposeDocument(oBaseDocument) 116*b1cdbd2cSJim Jagielski RESUME EXITWIZARD 117*b1cdbd2cSJim JagielskiEXITWIZARD: 118*b1cdbd2cSJim Jagielski End If 119*b1cdbd2cSJim JagielskiEnd Sub 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim JagielskiFunction SetProgressValue(iValue as Integer) 123*b1cdbd2cSJim Jagielski If iValue = 0 Then 124*b1cdbd2cSJim Jagielski ProgressBar.End 125*b1cdbd2cSJim Jagielski End If 126*b1cdbd2cSJim Jagielski ProgressValue = iValue 127*b1cdbd2cSJim Jagielski ProgressBar.Value = iValue 128*b1cdbd2cSJim JagielskiEnd Function 129*b1cdbd2cSJim Jagielski 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim JagielskiSub ReloadCurrentDocument() 132*b1cdbd2cSJim JagielskiDim OldDocIndex as Integer 133*b1cdbd2cSJim JagielskiOn Local Error Goto ErrorOcurred 134*b1cdbd2cSJim Jagielski OldDocIndex = CurDocIndex 135*b1cdbd2cSJim Jagielski CurDocIndex = GetCurIndex(DialogModel.lbTemplate, Layout(), 2) 136*b1cdbd2cSJim Jagielski If OldDocIndex <> CurDocIndex Then 137*b1cdbd2cSJim Jagielski oBaseDocument.LockControllers 138*b1cdbd2cSJim Jagielski ToggleDialogControls(False) 139*b1cdbd2cSJim Jagielski oCursor = oBaseDocument.Text.CreateTextCursor() 140*b1cdbd2cSJim Jagielski oCursor.GotoStart(False) 141*b1cdbd2cSJim Jagielski oCursor.GotoEnd(True) 142*b1cdbd2cSJim Jagielski oCursor.SetAllPropertiesToDefault() 143*b1cdbd2cSJim Jagielski oCursor.InsertDocumentfromURL(FileStr, NoArgs()) 144*b1cdbd2cSJim Jagielski SetBulletAndGraphics 145*b1cdbd2cSJim Jagielski CheckControls(oBaseDocument.DrawPage) 146*b1cdbd2cSJim Jagielski ErrorOcurred: 147*b1cdbd2cSJim Jagielski If Err <> 0 Then 148*b1cdbd2cSJim Jagielski MsgBox(WebWiz_gErrWhileReloading$, 16, WebWiz_gWizardName$) 149*b1cdbd2cSJim Jagielski End If 150*b1cdbd2cSJim Jagielski oBaseDocument.UnlockControllers 151*b1cdbd2cSJim Jagielski oViewCursor.GotoStart(False) 152*b1cdbd2cSJim Jagielski ToggleDialogControls(True, "lbTemplate") 153*b1cdbd2cSJim Jagielski End If 154*b1cdbd2cSJim JagielskiEnd Sub 155*b1cdbd2cSJim Jagielski 156*b1cdbd2cSJim Jagielski 157*b1cdbd2cSJim Jagielski 158*b1cdbd2cSJim Jagielski 159*b1cdbd2cSJim JagielskiSub LoadWebPageStyles(aEvent as Object, Optional bStartUp as Boolean) 160*b1cdbd2cSJim JagielskiDim OldWebPageIndex as Integer 161*b1cdbd2cSJim Jagielski OldWebPageIndex = CurWebPageIndex 162*b1cdbd2cSJim Jagielski If IsNull(DialogModel) Then 163*b1cdbd2cSJim Jagielski CurWebPageIndex = GetCurIndex(DialogModel, Style(), 8) 164*b1cdbd2cSJim Jagielski Else 165*b1cdbd2cSJim Jagielski CurWebPageIndex = GetCurIndex(DialogModel.lbStyles, Style(), 8) 166*b1cdbd2cSJim Jagielski End If 167*b1cdbd2cSJim Jagielski If OldWebPageIndex <> CurWebPageIndex Then 168*b1cdbd2cSJim Jagielski ToggleDialogControls(False) 169*b1cdbd2cSJim Jagielski oBaseDocument.LockControllers 170*b1cdbd2cSJim Jagielski bWithBackGraphic = LoadNewStyles(oBaseDocument, DialogModel, CurWebPageIndex, FileStr, Style(), TextureDir) 171*b1cdbd2cSJim Jagielski CurrentBullet$ = BulletDir + Style(CurWebPageIndex, 6) 172*b1cdbd2cSJim Jagielski CurrentPrev$ = GraphicsDir + Style(CurWebPageIndex, 2) 173*b1cdbd2cSJim Jagielski CurrentNext$ = GraphicsDir + Style(CurWebPageIndex, 3) 174*b1cdbd2cSJim Jagielski CurrentHome$ = GraphicsDir + Style(CurWebPageIndex, 4) 175*b1cdbd2cSJim Jagielski CurrentTop$ = GraphicsDir + Style(CurWebPageIndex, 5) 176*b1cdbd2cSJim Jagielski With oBaseDocument.DocumentProperties.UserDefinedProperties 177*b1cdbd2cSJim Jagielski .AutoPilotName1 = ExtractGraphicNames(CurWebPageIndex,2) 178*b1cdbd2cSJim Jagielski .AutoPilotName2 = ExtractGraphicNames(CurWebPageIndex, 4) 179*b1cdbd2cSJim Jagielski .AutoPilotBullet = Style(CurWebPageIndex, 6) 180*b1cdbd2cSJim Jagielski .AutoPilotBackground = Style(CurWebPageIndex, 7) 181*b1cdbd2cSJim Jagielski End With 182*b1cdbd2cSJim Jagielski SetBulletAndGraphics() 183*b1cdbd2cSJim Jagielski CheckControls(oBaseDocument.DrawPage) 184*b1cdbd2cSJim Jagielski oViewCursor.GotoStart(False) 185*b1cdbd2cSJim Jagielski oBaseDocument.UnlockControllers 186*b1cdbd2cSJim Jagielski ToggleDialogControls(True, "lbStyles") 187*b1cdbd2cSJim Jagielski End If 188*b1cdbd2cSJim JagielskiEnd Sub 189*b1cdbd2cSJim Jagielski 190*b1cdbd2cSJim Jagielski 191*b1cdbd2cSJim JagielskiFunction ExtractGraphicNames(CurIndex as Integer, i as Integer) as String 192*b1cdbd2cSJim JagielskiDim FieldValue as String 193*b1cdbd2cSJim Jagielski FieldValue = GetFileNameWithoutExtension(Style(CurIndex, i)) 194*b1cdbd2cSJim Jagielski FieldValue = FieldValue & " " & GetFileNameWithoutExtension(Style(CurIndex, i+1)) 195*b1cdbd2cSJim Jagielski ExtractGraphicNames = FieldValue 196*b1cdbd2cSJim JagielskiEnd Function 197*b1cdbd2cSJim Jagielski 198*b1cdbd2cSJim Jagielski 199*b1cdbd2cSJim JagielskiSub SetBulletAndGraphics 200*b1cdbd2cSJim Jagielski SetGraphic("Prev", CurrentPrev) 201*b1cdbd2cSJim Jagielski SetGraphic("Next", CurrentNext) 202*b1cdbd2cSJim Jagielski SetGraphic("Home", CurrentHome) 203*b1cdbd2cSJim Jagielski SetGraphic("Top", CurrentTop) 204*b1cdbd2cSJim Jagielski SetBulletGraphics(CurrentBullet) 205*b1cdbd2cSJim Jagielski SetGraphicsToOriginalSize() 206*b1cdbd2cSJim JagielskiEnd Sub 207*b1cdbd2cSJim Jagielski 208*b1cdbd2cSJim Jagielski 209*b1cdbd2cSJim JagielskiSub SetGraphicsToOriginalSize() 210*b1cdbd2cSJim JagielskiDim oGraphics as Object 211*b1cdbd2cSJim JagielskiDim oGraphic as Object 212*b1cdbd2cSJim JagielskiDim i as Integer 213*b1cdbd2cSJim JagielskiDim aActSize as New com.sun.star.awt.Size 214*b1cdbd2cSJim Jagielski oGraphics = oBaseDocument.GraphicObjects 215*b1cdbd2cSJim Jagielski For i = 0 To oGraphics.Count-1 216*b1cdbd2cSJim Jagielski oGraphic = oGraphics.GetByIndex(i) 217*b1cdbd2cSJim Jagielski aActSize = oGraphic.ActualSize 218*b1cdbd2cSJim Jagielski If aActSize.Height > 0 And aActSize.Width > 0 Then 219*b1cdbd2cSJim Jagielski oGraphic.SetSize(aActSize) 220*b1cdbd2cSJim Jagielski End If 221*b1cdbd2cSJim Jagielski Next i 222*b1cdbd2cSJim JagielskiEnd Sub 223*b1cdbd2cSJim Jagielski 224*b1cdbd2cSJim Jagielski 225*b1cdbd2cSJim JagielskiSub EndDialog() 226*b1cdbd2cSJim Jagielski If DialogModel.chkSaveasTemplate.State = 1 Then 227*b1cdbd2cSJim Jagielski ' Generating template? Set events later! 228*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oBaseDocument,"OnNew", "WebWizard.HtmlAutoPilotBasic.SetEvent()") 229*b1cdbd2cSJim Jagielski ' Call the Store template dialog 230*b1cdbd2cSJim Jagielski DispatchSlot(5538) 231*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oBaseDocument,"OnNew", "") 232*b1cdbd2cSJim Jagielski End If 233*b1cdbd2cSJim Jagielski SetEvent() 234*b1cdbd2cSJim JagielskiEnd Sub 235*b1cdbd2cSJim Jagielski 236*b1cdbd2cSJim Jagielski 237*b1cdbd2cSJim JagielskiSub SetEvent() 238*b1cdbd2cSJim JagielskiDim oDocument as Object 239*b1cdbd2cSJim Jagielski' This sub links the events OnSaveDone and OnSaveAsDone to the procedure 240*b1cdbd2cSJim Jagielski' CopyGraphics. It is invoked when a document is created, either directly 241*b1cdbd2cSJim Jagielski' from the AutoPilot or from a template. It is not possible to set these 242*b1cdbd2cSJim Jagielski' links for the template created by the AutoPilot because then it is not 243*b1cdbd2cSJim Jagielski' possible to modify the template. 244*b1cdbd2cSJim Jagielski BasicLibraries.LoadLibrary("Tools") 245*b1cdbd2cSJim Jagielski oDocument = ThisComponent 246*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oDocument,"OnSaveDone", "WebWizard.HtmlAutoPilotBasic.CopyGraphics()") 247*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oDocument,"OnSaveAsDone", "WebWizard.HtmlAutoPilotBasic.CopyGraphics()") 248*b1cdbd2cSJim JagielskiEnd Sub 249*b1cdbd2cSJim Jagielski 250*b1cdbd2cSJim Jagielski 251*b1cdbd2cSJim Jagielski 252*b1cdbd2cSJim JagielskiSub CopyGraphics 253*b1cdbd2cSJim Jagielski' This sub copies all the graphics used in the document to the same directory the 254*b1cdbd2cSJim Jagielski' document has been copied into and changes the graphics links in the document. 255*b1cdbd2cSJim JagielskiDim oGraphicObjects as Object 256*b1cdbd2cSJim JagielskiDim oGraphic as Object 257*b1cdbd2cSJim JagielskiDim i as Integer 258*b1cdbd2cSJim JagielskiDim udProps as Object 259*b1cdbd2cSJim JagielskiDim SavePath as String 260*b1cdbd2cSJim Jagielski BasicLibraries.LoadLibrary("Tools") 261*b1cdbd2cSJim Jagielski oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") 262*b1cdbd2cSJim Jagielski GetWebWizardPaths() 263*b1cdbd2cSJim Jagielski oBaseDocument = ThisComponent 264*b1cdbd2cSJim Jagielski' oBaseDocument.LockControllers() 265*b1cdbd2cSJim Jagielski 266*b1cdbd2cSJim Jagielski ' Note: The sub DirectoryNameoutofPath should be change, so that the last character is a slash 267*b1cdbd2cSJim Jagielski SavePath = DirectoryNameoutofPath(oBaseDocument.Url, "/") & "/" 268*b1cdbd2cSJim Jagielski 269*b1cdbd2cSJim Jagielski oGraphicObjects = oBaseDocument.GraphicObjects 270*b1cdbd2cSJim Jagielski For i = 0 to oGraphicObjects.Count-1 271*b1cdbd2cSJim Jagielski oGraphic = oGraphicObjects.GetbyIndex(i) 272*b1cdbd2cSJim Jagielski oGraphic.GraphicUrl = CopyFile(oGraphic.GraphicURL, SavePath) 273*b1cdbd2cSJim Jagielski Next i 274*b1cdbd2cSJim Jagielski 275*b1cdbd2cSJim Jagielski ChangeBackGraphicUrl(SavePath) 276*b1cdbd2cSJim Jagielski 277*b1cdbd2cSJim Jagielski BulletUrlsToSavePath(SavePath) 278*b1cdbd2cSJim Jagielski 279*b1cdbd2cSJim Jagielski udProps = oBaseDocument.DocumentProperties.UserDefinedProperties 280*b1cdbd2cSJim Jagielski udProps.addProperty("AutoPilotName1", 0, "") 281*b1cdbd2cSJim Jagielski udProps.addProperty("AutoPilotName2", 0, "") 282*b1cdbd2cSJim Jagielski udProps.addProperty("AutoPilotBullet", 0, "") 283*b1cdbd2cSJim Jagielski udProps.addProperty("AutoPilotBackground", 0, "") 284*b1cdbd2cSJim Jagielski 285*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oBaseDocument,"OnSaveDone", "") 286*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oBaseDocument,"OnSaveAsDone", "") 287*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oBaseDocument,"OnNew", "") 288*b1cdbd2cSJim Jagielski oBaseDocument.Store 289*b1cdbd2cSJim Jagielski' oBaseDocument.UnlockControllers() 290*b1cdbd2cSJim JagielskiEnd Sub 291*b1cdbd2cSJim Jagielski 292*b1cdbd2cSJim Jagielski 293*b1cdbd2cSJim JagielskiFunction CopyFile(ByVal SourceUrl as String, TargetDir as String) 294*b1cdbd2cSJim JagielskiDim sFileName as String 295*b1cdbd2cSJim JagielskiDim sNewFileUrl as String 296*b1cdbd2cSJim Jagielski If oUcb.Exists(TargetDir) Then 297*b1cdbd2cSJim Jagielski If Len(TargetDir) > 2 Then 298*b1cdbd2cSJim Jagielski sFileName = FileNameoutofPath(SourceUrl) 299*b1cdbd2cSJim Jagielski sNewFileUrl = TargetDir & sFileName 300*b1cdbd2cSJim Jagielski oUcb.Copy(SourceUrl, sNewFileUrl) 301*b1cdbd2cSJim Jagielski CopyFile() = sNewFileUrl 302*b1cdbd2cSJim Jagielski End If 303*b1cdbd2cSJim Jagielski End If 304*b1cdbd2cSJim JagielskiEnd Function 305*b1cdbd2cSJim Jagielski 306*b1cdbd2cSJim Jagielski 307*b1cdbd2cSJim JagielskiFunction getListBoxArrays(oUcb as Object, sFileFilter as String) 308*b1cdbd2cSJim JagielskiDim oDocProps as Object 309*b1cdbd2cSJim JagielskiDim oListboxControl as Object 310*b1cdbd2cSJim JagielskiDim Description as String 311*b1cdbd2cSJim JagielskiDim sField as String 312*b1cdbd2cSJim JagielskiDim sFieldList() as String 313*b1cdbd2cSJim JagielskiDim bItemFound as Boolean 314*b1cdbd2cSJim JagielskiDim MaxIndex as Integer 315*b1cdbd2cSJim JagielskiDim DirContent() as String 316*b1cdbd2cSJim JagielskiDim FileName as String 317*b1cdbd2cSJim JagielskiDim TemplatePath as String 318*b1cdbd2cSJim JagielskiDim FilterLen as Integer 319*b1cdbd2cSJim JagielskiDim i as Integer 320*b1cdbd2cSJim JagielskiDim m as Integer 321*b1cdbd2cSJim JagielskiDim n as Integer 322*b1cdbd2cSJim JagielskiDim s as Integer 323*b1cdbd2cSJim JagielskiDim a as Integer 324*b1cdbd2cSJim JagielskiDim LocMaxIndex as Integer 325*b1cdbd2cSJim JagielskiDim Properties() 326*b1cdbd2cSJim JagielskiDim DimCount as Integer 327*b1cdbd2cSJim JagielskiDim sExtension as String 328*b1cdbd2cSJim Jagielski oDocProps = CreateUnoService("com.sun.star.document.DocumentProperties") 329*b1cdbd2cSJim Jagielski FilterLen = Len(sFileFilter) 330*b1cdbd2cSJim Jagielski bItemFound = False 331*b1cdbd2cSJim Jagielski ' It has to be made sure that the TemplatePath <> "" 332*b1cdbd2cSJim Jagielski TemplatePath = GetOfficeSubPath("Template", "wizard/web/") 333*b1cdbd2cSJim Jagielski If TemplatePath = "" Then 334*b1cdbd2cSJim Jagielski Dim NullList() 335*b1cdbd2cSJim Jagielski getListBoxArrays() = NullList() 336*b1cdbd2cSJim Jagielski Exit Function 337*b1cdbd2cSJim Jagielski End If 338*b1cdbd2cSJim Jagielski DirContent() = oUcb.GetFolderContents(TemplatePath,True) 339*b1cdbd2cSJim Jagielski If sFileFilter = "/cnt" Then 340*b1cdbd2cSJim Jagielski DimCount = 2 341*b1cdbd2cSJim Jagielski Else 342*b1cdbd2cSJim Jagielski DimCount = 8 343*b1cdbd2cSJim Jagielski End If 344*b1cdbd2cSJim Jagielski LocMaxIndex = Ubound(DirContent()) 345*b1cdbd2cSJim Jagielski Dim List(LocMaxIndex, DimCount) as String 346*b1cdbd2cSJim Jagielski Dim SortList(LocMaxIndex,1) 347*b1cdbd2cSJim Jagielski For i = 0 to LocMaxIndex 348*b1cdbd2cSJim Jagielski SortList(i,0) = DirContent(i) 349*b1cdbd2cSJim Jagielski SortList(i,1) = RetrieveDocTitle(oDocProps, DirContent(i)) 350*b1cdbd2cSJim Jagielski Next i 351*b1cdbd2cSJim Jagielski SortList() = BubbleSortList(SortList(),True) 352*b1cdbd2cSJim Jagielski For i = 0 to LocMaxIndex 353*b1cdbd2cSJim Jagielski DirContent(i) = SortList(i,0) 354*b1cdbd2cSJim Jagielski Next i 355*b1cdbd2cSJim Jagielski a = 0 356*b1cdbd2cSJim Jagielski For i = 0 To LocMaxIndex 357*b1cdbd2cSJim Jagielski FileName = DirContent(i) 358*b1cdbd2cSJim Jagielski sExtension = Ucase(GetFileNameExtension(FileName)) 359*b1cdbd2cSJim Jagielski If Instr(1,Filename, sFileFilter) And sExtension = "STW" Then 360*b1cdbd2cSJim Jagielski bItemFound = True 361*b1cdbd2cSJim Jagielski Description = RetrieveDocTitle(oDocProps, FileName) 362*b1cdbd2cSJim Jagielski Properties = oDocProps.UserDefinedProperties.PropertyValues 363*b1cdbd2cSJim Jagielski List(a,1) = Description 364*b1cdbd2cSJim Jagielski If sFileFilter = "/cnt" Then 365*b1cdbd2cSJim Jagielski List(a,2) = Filename 366*b1cdbd2cSJim Jagielski Else 367*b1cdbd2cSJim Jagielski m = 2 368*b1cdbd2cSJim Jagielski For n = 0 To 3 369*b1cdbd2cSJim Jagielski sField = Properties(n).Value 370*b1cdbd2cSJim Jagielski sFieldList() = ArrayoutofString(sField, " ", MaxIndex) 371*b1cdbd2cSJim Jagielski For s = 0 To MaxIndex 372*b1cdbd2cSJim Jagielski If m < 6 Then 373*b1cdbd2cSJim Jagielski List(a,m) = sFieldList(s) & ".gif" 374*b1cdbd2cSJim Jagielski Else 375*b1cdbd2cSJim Jagielski List(a,m) = sFieldList(s) 376*b1cdbd2cSJim Jagielski End If 377*b1cdbd2cSJim Jagielski m = m + 1 378*b1cdbd2cSJim Jagielski Next s 379*b1cdbd2cSJim Jagielski Next n 380*b1cdbd2cSJim Jagielski List(a,8) = FileName 381*b1cdbd2cSJim Jagielski End If 382*b1cdbd2cSJim Jagielski a = a + 1 383*b1cdbd2cSJim Jagielski End If 384*b1cdbd2cSJim Jagielski Next i 385*b1cdbd2cSJim Jagielski If sFileFilter = "/cnt" Then 386*b1cdbd2cSJim Jagielski ReDim Preserve List(a-1,2) as String 387*b1cdbd2cSJim Jagielski Else 388*b1cdbd2cSJim Jagielski ReDim Preserve List(a-1,8) as String 389*b1cdbd2cSJim Jagielski End If 390*b1cdbd2cSJim Jagielski If Not bItemfound Then 391*b1cdbd2cSJim Jagielski MsgBox(WebWiz_gErrContentNotFound$, 16, WebWiz_gWizardName$) 392*b1cdbd2cSJim Jagielski DisposeDocument(oBaseDocument) 393*b1cdbd2cSJim Jagielski Stop 394*b1cdbd2cSJim Jagielski End If 395*b1cdbd2cSJim Jagielski getListBoxArrays = List() 396*b1cdbd2cSJim JagielskiEnd Function 397*b1cdbd2cSJim Jagielski 398*b1cdbd2cSJim Jagielski 399*b1cdbd2cSJim JagielskiSub SetGraphic(sWhich, sGraphicText as String) 400*b1cdbd2cSJim JagielskiDim oLocCursor as Object 401*b1cdbd2cSJim JagielskiDim oGraphic as Object 402*b1cdbd2cSJim JagielskiDim bGetGraphic as Boolean 403*b1cdbd2cSJim Jagielski oBookmarks = oBaseDocument.BookMarks 404*b1cdbd2cSJim Jagielski If oBookmarks.HasbyName(sWhich)Then 405*b1cdbd2cSJim Jagielski oBookMark = oBookmarks.GetbyName(sWhich) 406*b1cdbd2cSJim Jagielski oLocCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor) 407*b1cdbd2cSJim Jagielski oGraphic = oBaseDocument.CreateInstance("com.sun.star.text.GraphicObject") 408*b1cdbd2cSJim Jagielski oLocCursor.GoRight(3,True) 409*b1cdbd2cSJim Jagielski oGraphic.AnchorType = 1 410*b1cdbd2cSJim Jagielski oGraphic.GraphicURL = ConverttoURL(sGraphicText) 411*b1cdbd2cSJim Jagielski oLocCursor.Text.InsertTextContent(oLocCursor, oGraphic, True) 412*b1cdbd2cSJim Jagielski oGraphic.Name = sWhich 413*b1cdbd2cSJim Jagielski ElseIf oBaseDocument.GraphicObjects.HasbyName(sWhich) Then 414*b1cdbd2cSJim Jagielski oGraphic = oBaseDocument.GraphicObjects.GetByName(sWhich) 415*b1cdbd2cSJim Jagielski oGraphic.GraphicUrl = sGraphicText 416*b1cdbd2cSJim Jagielski End If 417*b1cdbd2cSJim JagielskiEnd Sub 418*b1cdbd2cSJim Jagielski 419*b1cdbd2cSJim Jagielski 420*b1cdbd2cSJim JagielskiSub CheckControls(oDrawPage as Object) 421*b1cdbd2cSJim JagielskiDim aForm as Object 422*b1cdbd2cSJim JagielskiDim m,n as integer 423*b1cdbd2cSJim JagielskiDim lColor as Long 424*b1cdbd2cSJim JagielskiDim oControl as Object 425*b1cdbd2cSJim Jagielski lColor = oBaseDocument.StyleFamilies.GetbyName("ParagraphStyles").GetByName("Standard").CharColor 426*b1cdbd2cSJim Jagielski 'SearchFor all possible Controls 427*b1cdbd2cSJim Jagielski For n = 0 to oDrawPage.Forms.Count - 1 428*b1cdbd2cSJim Jagielski aForm = oDrawPage.Forms(n) 429*b1cdbd2cSJim Jagielski For m = 0 to aForm.Count-1 430*b1cdbd2cSJim Jagielski oControl = aForm.GetbyIndex(m) 431*b1cdbd2cSJim Jagielski oControl.TextColor = lColor 432*b1cdbd2cSJim Jagielski Next 433*b1cdbd2cSJim Jagielski Next 434*b1cdbd2cSJim JagielskiEnd Sub 435*b1cdbd2cSJim Jagielski 436*b1cdbd2cSJim Jagielski 437*b1cdbd2cSJim JagielskiSub RepaintHeaderPreview() 438*b1cdbd2cSJim JagielskiDim Bitmap As Object 439*b1cdbd2cSJim JagielskiDim sBitmapPath as String 440*b1cdbd2cSJim Jagielski sBitmapPath = SOBitmapPath & "webwizard.bmp" 441*b1cdbd2cSJim Jagielski WebWzrd.ImagePreview.ImageURL = sBitmapPath 442*b1cdbd2cSJim JagielskiEnd Sub 443*b1cdbd2cSJim Jagielski 444*b1cdbd2cSJim Jagielski 445*b1cdbd2cSJim JagielskiSub ToggleDialogControls(ByVal bDoEnable as Boolean, Optional FocusControlName as String) 446*b1cdbd2cSJim Jagielski If Not IsNull(DialogModel) Then 447*b1cdbd2cSJim Jagielski DialogModel.Enabled = bDoEnable 448*b1cdbd2cSJim Jagielski If bDoEnable Then 449*b1cdbd2cSJim Jagielski ' Enable Controls referring to Background graphic only when this Property is set 450*b1cdbd2cSJim Jagielski bDoEnable = bWithBackGraphic 451*b1cdbd2cSJim Jagielski ToggleOptionButtons(DialogModel, bDoEnable) 452*b1cdbd2cSJim Jagielski MainDialog.GetControl(FocusControlName).SetFocus() 453*b1cdbd2cSJim Jagielski End If 454*b1cdbd2cSJim Jagielski End If 455*b1cdbd2cSJim JagielskiEnd Sub 456*b1cdbd2cSJim Jagielski</script:module> 457