diff options
-rw-r--r-- | wizards/source/webwizard/Common.xba | 47 | ||||
-rw-r--r-- | wizards/source/webwizard/HtmlAutoPilotBasic.xba | 116 | ||||
-rw-r--r-- | wizards/source/webwizard/Language.xba | 51 | ||||
-rw-r--r-- | wizards/source/webwizard/script.xlb | 2 |
4 files changed, 130 insertions, 86 deletions
diff --git a/wizards/source/webwizard/Common.xba b/wizards/source/webwizard/Common.xba index b4c53942b270..d5dcab8bc3c3 100644 --- a/wizards/source/webwizard/Common.xba +++ b/wizards/source/webwizard/Common.xba @@ -3,6 +3,7 @@ <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Common" script:language="StarBasic">REM ***** BASIC ***** Option Explicit + Function LoadNewStyles(oDocument as Object, oDialogModel as Object, CurIndex as Integer, SourceFile as String, Styles() as String, TextureDir as String) as Boolean Dim BackGroundURL as String Dim oBackGraph as Object @@ -18,7 +19,7 @@ Dim StylesOptions(0) as New com.sun.star.beans.PropertyValue End If ' Read array fields for background, bullet & graphics - BackgroundURL = Styles(7, CurIndex) + BackgroundURL = Styles(CurIndex, 7) If Left(BackgroundURL, 1) <> "#" Then BackgroundURL = TextureDir + BackgroundURL bLocWithBackGraphic = True @@ -40,6 +41,7 @@ Dim StylesOptions(0) as New com.sun.star.beans.PropertyValue oStyle.BackGraphicUrl = BackGroundURL SetTileBackgroundorNot(oDialogModel, oStyle) End If + Exit For End If End If Next i @@ -47,7 +49,7 @@ Dim StylesOptions(0) as New com.sun.star.beans.PropertyValue ErrorOcurred: If Err <> 0 Then MsgBox (WebWiz_gErrWhileLoadStyles$, 16, WebWiz_gWizardName$) - CancelHTMLWizard() +' CancelHTMLWizard() End If End Function @@ -62,7 +64,7 @@ Dim i as Integer oStyle = oPageFamily.GetbyIndex(i) If oStyle.PropertySetInfo.HasPropertybyName("BackGraphicURL") Then If oStyle.BackGraphicUrl <> "" Then - oStyleBack.GraphicUrl = CopyFile(oStyle.BackGraphicUrl, SavePath) + oStyle.BackGraphicUrl = CopyFile(oStyle.BackGraphicUrl, SavePath) Exit Sub End If End If @@ -97,31 +99,42 @@ End Sub Sub SetTileBackgroundorNot(DialogModel as Object, oStyle as Object) - If DialogModel.optTiled.State = 1 Then - oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.TILED - Else - oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.AREA + If Not IsNull(DialogModel) Then + If DialogModel.optTiled.State = 1 Then + oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.TILED + Else + oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.AREA + End If End If End Sub Sub ToggleOptionButtons(DialogModel as Object, bDoEnable as Integer) - DialogModel.optTiled.Enabled = bDoEnable - DialogModel.optArea.Enabled = bDoEnable - DialogModel.hlnBackground.Enabled = bDoEnable + If Not IsNull(DialogModel) Then + DialogModel.optTiled.Enabled = bDoEnable + DialogModel.optArea.Enabled = bDoEnable + DialogModel.hlnBackground.Enabled = bDoEnable + End If End Sub -Function GetCurIndex(oListbox as Object, sList() as String, MaxIndex as Integer, FileIndex as Integer) -Dim i, n as Integer +Function GetCurIndex(oListbox as Object, sList() as String, FileIndex as Integer) +Dim i as Integer +Dim n as Integer Dim SelValue as String - ' Get selected list entry - n = oListbox.SelectedItems(0) - SelValue = oListbox.StringItemList(n) +Dim MaxIndex as Integer + If IsNull(oListBox) Then + ' Startup for WebWizard + SelValue = sList(0,1) + Else + n = oListbox.SelectedItems(0) + SelValue = oListbox.StringItemList(n) + End If ' Find field index for chosen list entry + MaxIndex = Ubound(sList) For i = 0 To MaxIndex - If sList(1, i) = SelValue Then - FileStr = sList(FileIndex, i) + If sList(i,1) = SelValue Then + FileStr = sList(i, FileIndex) Exit For End If Next diff --git a/wizards/source/webwizard/HtmlAutoPilotBasic.xba b/wizards/source/webwizard/HtmlAutoPilotBasic.xba index bcb6e4b40906..f6ce5316f627 100644 --- a/wizards/source/webwizard/HtmlAutoPilotBasic.xba +++ b/wizards/source/webwizard/HtmlAutoPilotBasic.xba @@ -14,12 +14,12 @@ Const MaxLayouts = 50 Const MaxStyles = 100 Const MaxBullets = 10 -Public NumberOfLayouts%, NumberOfStyles% +'Public NumberOfLayouts%, NumberOfStyles% ' Filled with title, previous, next, home, top, bullet, background, file name -Public Style(8, MaxStyles) as String +Public Style(MaxStyles, 8) as String -Public Layout$(2, MaxLayouts) +Public Layout$(MaxLayouts, 2) Public TextureDir$, BulletDir$, GraphicsDir$, GalleryDir$, PhotosDir$ Public CurrentBullet$, CurrentPrev$, CurrentNext$, CurrentHome$, CurrentTop$ @@ -47,42 +47,36 @@ Public DialogModel as Object Sub Main Dim RetValue -'On Local Error Goto GlobalErrorHandler - Dim SOBitmapPath,sBitmapPath as String +On Local Error Goto GlobalErrorHandler BasicLibraries.LoadLibrary("Tools") oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") oBaseDocument = StarDesktop.LoadComponentFromURL("private:factory/swriter/web", "_blank", 0, NoArgs()) oViewSettings = oBaseDocument.CurrentController.ViewSettings oViewCursor = oBaseDocument.GetCurrentController.ViewCursor + CurWebPageIndex = -1 ProgressBar = oBaseDocument.GetCurrentController.GetFrame.CreateStatusIndicator ProgressBar.Start("", 100) SetProgressValue(2) oBaseDocument.LockControllers oViewSettings.ShowTableBoundaries = False oViewSettings.ShowTextBoundaries = False - MainDialog = LoadDialog("WebWizard","WebWzrd") - DialogModel = MainDialog.Model LoadLanguage SetProgressValue(10) GetPaths() - NumberofLayouts = FillupWebListbox(oUcb, "/cnt", MainDialog, "lbTemplate", Layout$()) + Layout() = getListBoxArrays(oUcb, "/cnt") + GetCurIndex(DialogModel, Layout(),2) SetProgressValue(30) - GetCurIndex(DialogModel.lbTemplate, Layout(),NumberofLayouts,2) oCursor = oBasedocument.Text.CreateTextCursor oCursor.InsertDocumentfromURL(FileStr, NoArgs()) - SetProgressValue(40) - NumberofStyles = FillupWebListbox(oUcb, "/stl", MainDialog, "lbStyles", Style()) SetProgressValue(50) + Style() = getListBoxArrays(oUcb, "/stl") + SetProgressValue(70) LoadWebPageStyles(oBaseDocument) + SetProgressValue(90) + oBaseDocument.UnlockControllers + OpenWebDialog() SetProgressValue(98) SetProgressValue(0) - oBaseDocument.UnlockControllers - SOBitmapPath = GetOfficeSubPath("Template", "wizard/bitmap") - sBitmapPath = SOBitmapPath & "webwizard.bmp" - DialogModel.ImagePreview.ImageURL = sBitmapPath - ToggleOptionButtons(DialogModel, bWithBackGraphic) - MainDialog.GetControl("lbTemplate").SetFocus() - DialogModel.cbGoOn.DefaultButton = True RetValue = MainDialog.Execute Select Case RetValue Case 0 @@ -95,7 +89,7 @@ Dim RetValue GLOBALERRORHANDLER: If Err <> 0 Then MsgBox (WebWiz_gErrMsg$, 16, WebWiz_gWizardName$) - CancelHTMLWizard() +' CancelHTMLWizard() End If End Sub @@ -113,7 +107,7 @@ Sub ReloadCurrentDocument() Dim OldDocIndex as Integer On Local Error Goto ErrorOcurred OldDocIndex = CurDocIndex - CurDocIndex = GetCurIndex(DialogModel.lbTemplate, Layout(), NumberofLayouts%, 2) + CurDocIndex = GetCurIndex(DialogModel.lbTemplate, Layout(), 2) If OldDocIndex <> CurDocIndex Then oBaseDocument.LockControllers ToggleDialogControls(False) @@ -136,24 +130,29 @@ End Sub -Sub LoadWebPageStyles() + +Sub LoadWebPageStyles(aEvent as Object, Optional bStartUp as Boolean) Dim OldWebPageIndex as Integer OldWebPageIndex = CurWebPageIndex - CurWebPageIndex = GetCurIndex(DialogModel.lbStyles, Style(), NumberofStyles%,8) + If IsNull(DialogModel) Then + CurWebPageIndex = GetCurIndex(DialogModel, Style(), 8) + Else + CurWebPageIndex = GetCurIndex(DialogModel.lbStyles, Style(), 8) + End If If OldWebPageIndex <> CurWebPageIndex Then ToggleDialogControls(False) oBaseDocument.LockControllers bWithBackGraphic = LoadNewStyles(oBaseDocument, DialogModel, CurWebPageIndex, FileStr, Style(), TextureDir) - CurrentBullet$ = BulletDir + Style(6, CurWebPageIndex) - CurrentPrev$ = GraphicsDir + Style(2, CurWebPageIndex) - CurrentNext$ = GraphicsDir + Style(3, CurWebPageIndex) - CurrentHome$ = GraphicsDir + Style(4, CurWebPageIndex) - CurrentTop$ = GraphicsDir + Style(5, CurWebPageIndex) + CurrentBullet$ = BulletDir + Style(CurWebPageIndex, 6) + CurrentPrev$ = GraphicsDir + Style(CurWebPageIndex, 2) + CurrentNext$ = GraphicsDir + Style(CurWebPageIndex, 3) + CurrentHome$ = GraphicsDir + Style(CurWebPageIndex, 4) + CurrentTop$ = GraphicsDir + Style(CurWebPageIndex, 5) With oBaseDocument.DocumentInfo .GetUserFieldValue(0) = ExtractGraphicNames(CurWebPageIndex,2) .GetUserFieldValue(1) = ExtractGraphicNames(CurWebPageIndex, 4) - .GetUserFieldValue(2) = Style(6, CurWebPageIndex) ' Bullet - .GetUserFieldValue(3) = Style(7, CurWebPageIndex) ' Background + .GetUserFieldValue(2) = Style(CurWebPageIndex, 6) ' Bullet + .GetUserFieldValue(3) = Style(CurWebPageIndex, 7) ' Background End With SetBulletAndGraphics() CheckControls(oBaseDocument.DrawPage) @@ -166,8 +165,8 @@ End Sub Function ExtractGraphicNames(CurIndex as Integer, i as Integer) as String Dim FieldValue as String - FieldValue = GetFileNameWithoutExtension(Style(i,CurIndex)) - FieldValue = FieldValue & " " & GetFileNameWithoutExtension(Style(i+1,CurIndex)) + FieldValue = GetFileNameWithoutExtension(Style(CurIndex, i)) + FieldValue = FieldValue & " " & GetFileNameWithoutExtension(Style(CurIndex, i+1)) ExtractGraphicNames = FieldValue End Function @@ -257,7 +256,6 @@ Dim SavePath as String .GetUserFieldValue(2) = "" .GetUserFieldValue(3) = "" End With - AttachBasicMacroToEvent(oBaseDocument,"OnSaveDone", "") AttachBasicMacroToEvent(oBaseDocument,"OnSaveAsDone", "") AttachBasicMacroToEvent(oBaseDocument,"OnNew", "") @@ -265,7 +263,7 @@ Dim SavePath as String ' oBaseDocument.UnlockControllers() End Sub - + Function CopyFile(ByVal SourceUrl as String, TargetDir as String) Dim sFileName as String Dim sNewFileUrl as String @@ -276,8 +274,7 @@ Dim sNewFileUrl as String End Function - -Function FillupWebListbox(oUcb as Object, sFileFilter as String, oDialog as Object, ListboxName as String, List() as String) +Function getListBoxArrays(oUcb as Object, sFileFilter as String) Dim oDocInfo as Object Dim oListboxControl as Object Dim Description as String @@ -294,18 +291,21 @@ Dim m as Integer Dim n as Integer Dim s as Integer Dim a as Integer -Dim SelList(0) as Integer Dim LocMaxIndex as Integer Dim InfoNames() - oListboxControl = oDialog.GetControl(ListboxName) +Dim DimCount as Integer oDocInfo = CreateUnoService("com.sun.star.document.DocumentProperties") FilterLen = Len(sFileFilter) bItemFound = False TemplatePath = GetOfficeSubPath("Template", "wizard/web/") DirContent() = oUcb.GetFolderContents(TemplatePath,True) - + If sFileFilter = "/cnt" Then + DimCount = 2 + Else + DimCount = 8 + End If LocMaxIndex = Ubound(DirContent()) - + Dim List(LocMaxIndex, DimCount) as String Dim SortList(LocMaxIndex,1) For i = 0 to LocMaxIndex SortList(i,0) = DirContent(i) @@ -323,11 +323,9 @@ Dim InfoNames() Description = RetrieveDocTitle(oDocInfo, FileName) oDocInfo.Read(FileName) InfoNames = oDocInfo.ElementNames() - oListboxControl.AddItem(Description,a) - a = a + 1 - List(1,i) = Description + List(a,1) = Description If sFileFilter = "/cnt" Then - List(2,i) = Filename + List(a,2) = Filename Else m = 2 For n = 0 To 3 @@ -335,25 +333,29 @@ Dim InfoNames() sFieldList() = ArrayoutofString(sField, " ", MaxIndex) For s = 0 To MaxIndex If m < 6 Then - List(m,i) = sFieldList(s) & ".gif" + List(a,m) = sFieldList(s) & ".gif" Else - List(m,i) = sFieldList(s) + List(a,m) = sFieldList(s) End If m = m + 1 Next s Next n - List(8,i) = FileName + List(a,8) = FileName End If + a = a + 1 End If Next i + If sFileFilter = "/cnt" Then + ReDim PreServe List(a-1,2) as String + Else + ReDim PreServe List(a-1,8) as String + End If If Not bItemfound Then - MsgBox(WebWiz_gErrContentNotFound$ , 16, WebWiz_gWizardName$) + MsgBox(WebWiz_gErrContentNotFound$, 16, WebWiz_gWizardName$) oBaseDocument.Dispose() Stop End If - SelList(0) = 0 - oListboxControl.Model.SelectedItems() = SelList() - FillupWebListbox = i + getListBoxArrays = List() End Function @@ -404,11 +406,13 @@ End Sub Sub ToggleDialogControls(ByVal bDoEnable as Boolean, Optional FocusControlName as String) - DialogModel.Enabled = bDoEnable - If bDoEnable Then - ' Enable Controls referring to Background graphic only when this Property is set - bDoEnable = bWithBackGraphic - ToggleOptionButtons(DialogModel, bDoEnable) - MainDialog.GetControl(FocusControlName).SetFocus() + If Not IsNull(DialogModel) Then + DialogModel.Enabled = bDoEnable + If bDoEnable Then + ' Enable Controls referring to Background graphic only when this Property is set + bDoEnable = bWithBackGraphic + ToggleOptionButtons(DialogModel, bDoEnable) + MainDialog.GetControl(FocusControlName).SetFocus() + End If End If End Sub</script:module>
\ No newline at end of file diff --git a/wizards/source/webwizard/Language.xba b/wizards/source/webwizard/Language.xba index f78e27f4ffe7..a3c8bc66fdb0 100644 --- a/wizards/source/webwizard/Language.xba +++ b/wizards/source/webwizard/Language.xba @@ -5,18 +5,6 @@ Sub LoadLanguage() If InitResources("WebWizard","wwz") Then - With DialogModel - .cbHelp.Label = GetResText(1000) - .Title = GetResText(1001) - .cbCancel.Label = GetResText(1002) - .cbGoOn.Label = GetResText(1003) - .lblTemplate.Label = GetResText(1004) - .lblStyle.Label = GetResText(1005) - .hlnBackground.Label = GetResText(1006) - .optTiled.Label = GetRestext(1007) - .optArea.Label = GetResText(1008) - .chkSaveasTemplate.Label = GetResText(1010) - End With WebWiz_gErrContentNotFound = GetResText(1101) WebWiz_gErrStyleNotFound = GetResText(1102) WebWiz_gErrMainTemplateError = GetResText(1103) @@ -33,4 +21,43 @@ Sub GetPaths GraphicsDir = GetOfficeSubPath("Gallery", "www-graf/") BulletDir = GetOfficeSubPath("Gallery", "bullets/") PhotosDir = GetPathSettings("Gallery", False, 1) +End Sub + + +Sub OpenWebDialog() + Dim SOBitmapPath,sBitmapPath as String + Dim BufferNames() as String + Dim SelList(0) as Integer + SelList(0) = 0 + MainDialog = LoadDialog("WebWizard","WebWzrd") + DialogModel = MainDialog.Model + With DialogModel + .cbHelp.Label = GetResText(1000) + .Title = GetResText(1001) + .cbCancel.Label = GetResText(1002) + .cbGoOn.Label = GetResText(1003) + .lblTemplate.Label = GetResText(1004) + .lblStyle.Label = GetResText(1005) + .hlnBackground.Label = GetResText(1006) + .optTiled.Label = GetRestext(1007) + .optArea.Label = GetResText(1008) + .chkSaveasTemplate.Label = GetResText(1010) + End With + + BufferNames() = ArrayfromMultiArray(Layout, 1) + DialogModel.lbTemplate.StringItemList() = BufferNames() + DialogModel.lbTemplate.SelectedItems() = SelList() + + + BufferNames() = ArrayfromMultiArray(Style, 1) + DialogModel.lbStyles.StringItemList() = BufferNames() + DialogModel.lbStyles.SelectedItems() = SelList() + + SOBitmapPath = GetOfficeSubPath("Template", "wizard/bitmap") + sBitmapPath = SOBitmapPath & "webwizard.bmp" + + DialogModel.ImagePreview.ImageURL = sBitmapPath + ToggleOptionButtons(DialogModel, bWithBackGraphic) + MainDialog.GetControl("lbTemplate").SetFocus() + DialogModel.cbGoOn.DefaultButton = True End Sub</script:module>
\ No newline at end of file diff --git a/wizards/source/webwizard/script.xlb b/wizards/source/webwizard/script.xlb index 1045820b7002..d2ade7377e0f 100644 --- a/wizards/source/webwizard/script.xlb +++ b/wizards/source/webwizard/script.xlb @@ -5,4 +5,4 @@ <library:element library:name="Language"/> <library:element library:name="Bullets"/> <library:element library:name="Common"/> -</library:library> +</library:library>
\ No newline at end of file |