home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / CHIP_CD_2004-12.iso / bonus / oo / OOo_1.1.3_ru_RU_infra_WinIntel_install.exe / $PLUGINSDIR / f_0106 / Common.xba < prev    next >
Extensible Markup Language  |  2002-11-06  |  5KB  |  145 lines

  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  *****
  4. Option Explicit
  5.  
  6.  
  7. Function LoadNewStyles(oDocument as Object, oDialogModel as Object, CurIndex as Integer, SourceFile as String, Styles() as String, TextureDir as String) as Boolean
  8. Dim BackGroundURL as String
  9. Dim oBackGraph as Object
  10. Dim i, BackColor as Long
  11. Dim bLocWithBackGraphic as Boolean
  12. Dim oFamilies as Object, oFamily as Object', oStyle as Object
  13. Dim 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
  49. ErrorOcurred:
  50.     If Err <> 0 Then
  51.         MsgBox (WebWiz_gErrWhileLoadStyles$, 16, WebWiz_gWizardName$)
  52.         RESUME EXITSUB
  53. EXITSUB:        
  54.     End If
  55. End Function
  56.  
  57.  
  58.  
  59. Sub ChangeBackGraphicUrl(SavePath as String)
  60. Dim oPageFamily as Object
  61. Dim 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
  74. End Sub
  75.  
  76.  
  77. Sub SetBackGraphicStyle(oEvent as Object)
  78. Dim oFamilies as Object
  79. Dim oFamily as Object
  80. Dim i as Integer
  81. Dim oOptModel as Object
  82. Dim iBackgroundValue as Integer
  83. Dim 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
  99. End Sub
  100.  
  101.  
  102. Sub 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
  110. End Sub
  111.  
  112.  
  113. Sub    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
  119. End Sub
  120.  
  121.  
  122. Function GetCurIndex(oListbox as Object, sList() as String, FileIndex as Integer)
  123. Dim i as Integer
  124. Dim n as Integer
  125. Dim SelValue as String
  126. Dim 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
  143. End Function
  144.  
  145. </script:module>