1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2*cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Bullets" script:language="StarBasic">REM  *****  BASIC  *****
4*cdf0e10cSrcweirOption Explicit
5*cdf0e10cSrcweir
6*cdf0e10cSrcweir
7*cdf0e10cSrcweirSub	SetBulletGraphics(sBulletUrl as String)
8*cdf0e10cSrcweirDim i as Integer
9*cdf0e10cSrcweirDim oBookMarkCursor as Object
10*cdf0e10cSrcweir	oBookmarks = oBaseDocument.BookMarks
11*cdf0e10cSrcweir	For i = 0 To oBookmarks.Count - 1
12*cdf0e10cSrcweir		oBookMark = oBookmarks.GetbyIndex(i)
13*cdf0e10cSrcweir		oBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
14*cdf0e10cSrcweir		If oBookMarkCursor.PropertySetInfo.HasPropertybyName(&quot;NumberingRules&quot;) Then
15*cdf0e10cSrcweir			ChangeBulletURL(sBulletUrl, oBookMarkCursor)
16*cdf0e10cSrcweir		End If
17*cdf0e10cSrcweir	Next i
18*cdf0e10cSrcweirEnd Sub
19*cdf0e10cSrcweir
20*cdf0e10cSrcweir
21*cdf0e10cSrcweirSub	ChangeBulletURL(sBulletUrl as String, oBookMarkCursor as Object)
22*cdf0e10cSrcweirDim n, m as Integer
23*cdf0e10cSrcweirDim oLevel()
24*cdf0e10cSrcweirDim oRules
25*cdf0e10cSrcweirDim bDoReplace as Boolean
26*cdf0e10cSrcweirDim oSize as New com.sun.star.awt.Size
27*cdf0e10cSrcweirDim oNumberingBuffer(0) as New com.sun.star.beans.PropertyValue
28*cdf0e10cSrcweirDim oNewBuffer(0) as New com.sun.star.beans.PropertyValue
29*cdf0e10cSrcweir	oRules = oBookMarkCursor.NumberingRules
30*cdf0e10cSrcweir	If Vartype(oRules()) = 9 Then
31*cdf0e10cSrcweir		oNumberingBuffer(0).Name = &quot;NumberingType&quot;
32*cdf0e10cSrcweir		oNumberingBuffer(0).Value = com.sun.star.style.NumberingType.BITMAP
33*cdf0e10cSrcweir		For n = 0 To oRules.Count - 1
34*cdf0e10cSrcweir			oLevel() = oRules.GetByIndex(n)
35*cdf0e10cSrcweir			bDoReplace = ModifyPropertyValue(oLevel(), oNumberingBuffer())
36*cdf0e10cSrcweir			If bDoReplace Then
37*cdf0e10cSrcweir				oRules.ReplaceByIndex(n, oNumberingBuffer())
38*cdf0e10cSrcweir			End If
39*cdf0e10cSrcweir		Next n
40*cdf0e10cSrcweir		oBookmarkCursor.NumberingRules = oRules
41*cdf0e10cSrcweir		oNewBuffer(0).Name = &quot;GraphicURL&quot;
42*cdf0e10cSrcweir		oNewBuffer(0).Value = sBulletUrl
43*cdf0e10cSrcweir		For n = 0 To oRules.Count - 1
44*cdf0e10cSrcweir			oLevel() = oRules.GetByIndex(0)
45*cdf0e10cSrcweir			bDoReplace = ModifyPropertyValue(oLevel(), oNewBuffer())
46*cdf0e10cSrcweir			If bDoReplace Then
47*cdf0e10cSrcweir				oRules.ReplaceByIndex(n, oNewBuffer())
48*cdf0e10cSrcweir			End If
49*cdf0e10cSrcweir		Next n
50*cdf0e10cSrcweir		oBookmarkCursor.NumberingRules = oRules
51*cdf0e10cSrcweir	End If
52*cdf0e10cSrcweirEnd Sub
53*cdf0e10cSrcweir
54*cdf0e10cSrcweir
55*cdf0e10cSrcweirSub	BulletUrlsToSavePath(SavePath as String)
56*cdf0e10cSrcweirDim n as Integer
57*cdf0e10cSrcweirDim m as Integer
58*cdf0e10cSrcweirDim i as Integer
59*cdf0e10cSrcweirDim sNewBulletUrl as String
60*cdf0e10cSrcweirDim oLevel()
61*cdf0e10cSrcweirDim oRules
62*cdf0e10cSrcweirDim bIsFirstRun as Boolean
63*cdf0e10cSrcweirDim oNewBuffer()&apos; as New com.sun.star.beans.PropertyValue
64*cdf0e10cSrcweirDim bDoReplace as Boolean
65*cdf0e10cSrcweirDim oBookmarkCursor as Object
66*cdf0e10cSrcweir	bIsFirstRun = True
67*cdf0e10cSrcweir	oBookmarks = oBaseDocument.BookMarks
68*cdf0e10cSrcweir	For i = 0 To oBookmarks.Count - 1
69*cdf0e10cSrcweir		oBookMark = oBookmarks.GetbyIndex(i)
70*cdf0e10cSrcweir		oBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
71*cdf0e10cSrcweir		If oBookMarkCursor.PropertySetInfo.HasPropertybyName(&quot;NumberingRules&quot;) Then
72*cdf0e10cSrcweir			oRules = oBookMarkCursor.NumberingRules
73*cdf0e10cSrcweir			If Vartype(oRules()) = 9 Then
74*cdf0e10cSrcweir				For n = 0 To oRules.Count - 1
75*cdf0e10cSrcweir					oLevel() = oRules.GetByIndex(n)
76*cdf0e10cSrcweir					oNewBuffer() = ChangeBulletUrlToSavePath(SavePath, oLevel(), bIsFirstRun, bDoReplace)
77*cdf0e10cSrcweir					If bDoReplace Then
78*cdf0e10cSrcweir						bIsFirstRun = False
79*cdf0e10cSrcweir						oRules.ReplaceByIndex(n, oNewBuffer())
80*cdf0e10cSrcweir					End If
81*cdf0e10cSrcweir				Next n
82*cdf0e10cSrcweir				oBookmarkCursor.NumberingRules = oRules
83*cdf0e10cSrcweir			End If
84*cdf0e10cSrcweir		End If
85*cdf0e10cSrcweir	Next i
86*cdf0e10cSrcweirEnd Sub
87*cdf0e10cSrcweir
88*cdf0e10cSrcweir
89*cdf0e10cSrcweirFunction ChangeBulletUrlToSavePath(SavePath as String, oLevel(), bIsFirstRun as Boolean, bDoReplace as Boolean)
90*cdf0e10cSrcweirDim MaxIndex as Integer
91*cdf0e10cSrcweirDim i as Integer
92*cdf0e10cSrcweirDim BulletName as String
93*cdf0e10cSrcweirDim oSize as New com.sun.star.awt.Size
94*cdf0e10cSrcweir	MaxIndex = Ubound(oLevel())
95*cdf0e10cSrcweir	Dim oNewBuffer(MaxIndex) as New com.sun.star.beans.PropertyValue
96*cdf0e10cSrcweir	For i = 0 To MaxIndex
97*cdf0e10cSrcweir		oNewBuffer(i).Name = oLevel(i).Name
98*cdf0e10cSrcweir		If oLevel(i).Name = &quot;GraphicURL&quot; Then
99*cdf0e10cSrcweir			bDoReplace = True
100*cdf0e10cSrcweir			BulletName = FileNameoutofPath(oLevel(i).Value)
101*cdf0e10cSrcweir			If bIsFirstRun Then
102*cdf0e10cSrcweir				If oUcb.exists(SavePath &amp; Bulletname) Then
103*cdf0e10cSrcweir					FileCopy(oLevel(i).Value, SavePath &amp; BulletName)
104*cdf0e10cSrcweir				End If
105*cdf0e10cSrcweir			End If
106*cdf0e10cSrcweir			oNewBuffer(i).Value = BulletName
107*cdf0e10cSrcweir&apos;		ElseIf oLevel(i).Name = &quot;GraphicSize&quot; Then
108*cdf0e10cSrcweir&apos;&apos; Todo: Get the original Size of the Bullet (see Bug #86196)
109*cdf0e10cSrcweir&apos;			oSize.Height = 300
110*cdf0e10cSrcweir&apos;			oSize.Width = 300
111*cdf0e10cSrcweir&apos;			oNewBuffer(i).Value = oSize
112*cdf0e10cSrcweir		Else
113*cdf0e10cSrcweir			oNewBuffer(i).Value = oLevel(i).Value
114*cdf0e10cSrcweir		End If
115*cdf0e10cSrcweir	Next i
116*cdf0e10cSrcweir	ChangeBulletUrlToSavePath() = oNewBuffer()
117*cdf0e10cSrcweirEnd Function</script:module>