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="Bullets" script:language="StarBasic">REM  *****  BASIC  *****
24cdf0e10cSrcweirOption Explicit
25cdf0e10cSrcweir
26cdf0e10cSrcweir
27cdf0e10cSrcweirSub	SetBulletGraphics(sBulletUrl as String)
28cdf0e10cSrcweirDim i as Integer
29cdf0e10cSrcweirDim oBookMarkCursor as Object
30cdf0e10cSrcweir	oBookmarks = oBaseDocument.BookMarks
31cdf0e10cSrcweir	For i = 0 To oBookmarks.Count - 1
32cdf0e10cSrcweir		oBookMark = oBookmarks.GetbyIndex(i)
33cdf0e10cSrcweir		oBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
34cdf0e10cSrcweir		If oBookMarkCursor.PropertySetInfo.HasPropertybyName(&quot;NumberingRules&quot;) Then
35cdf0e10cSrcweir			ChangeBulletURL(sBulletUrl, oBookMarkCursor)
36cdf0e10cSrcweir		End If
37cdf0e10cSrcweir	Next i
38cdf0e10cSrcweirEnd Sub
39cdf0e10cSrcweir
40cdf0e10cSrcweir
41cdf0e10cSrcweirSub	ChangeBulletURL(sBulletUrl as String, oBookMarkCursor as Object)
42cdf0e10cSrcweirDim n, m as Integer
43cdf0e10cSrcweirDim oLevel()
44cdf0e10cSrcweirDim oRules
45cdf0e10cSrcweirDim bDoReplace as Boolean
46cdf0e10cSrcweirDim oSize as New com.sun.star.awt.Size
47cdf0e10cSrcweirDim oNumberingBuffer(0) as New com.sun.star.beans.PropertyValue
48cdf0e10cSrcweirDim oNewBuffer(0) as New com.sun.star.beans.PropertyValue
49cdf0e10cSrcweir	oRules = oBookMarkCursor.NumberingRules
50cdf0e10cSrcweir	If Vartype(oRules()) = 9 Then
51cdf0e10cSrcweir		oNumberingBuffer(0).Name = &quot;NumberingType&quot;
52cdf0e10cSrcweir		oNumberingBuffer(0).Value = com.sun.star.style.NumberingType.BITMAP
53cdf0e10cSrcweir		For n = 0 To oRules.Count - 1
54cdf0e10cSrcweir			oLevel() = oRules.GetByIndex(n)
55cdf0e10cSrcweir			bDoReplace = ModifyPropertyValue(oLevel(), oNumberingBuffer())
56cdf0e10cSrcweir			If bDoReplace Then
57cdf0e10cSrcweir				oRules.ReplaceByIndex(n, oNumberingBuffer())
58cdf0e10cSrcweir			End If
59cdf0e10cSrcweir		Next n
60cdf0e10cSrcweir		oBookmarkCursor.NumberingRules = oRules
61cdf0e10cSrcweir		oNewBuffer(0).Name = &quot;GraphicURL&quot;
62cdf0e10cSrcweir		oNewBuffer(0).Value = sBulletUrl
63cdf0e10cSrcweir		For n = 0 To oRules.Count - 1
64cdf0e10cSrcweir			oLevel() = oRules.GetByIndex(0)
65cdf0e10cSrcweir			bDoReplace = ModifyPropertyValue(oLevel(), oNewBuffer())
66cdf0e10cSrcweir			If bDoReplace Then
67cdf0e10cSrcweir				oRules.ReplaceByIndex(n, oNewBuffer())
68cdf0e10cSrcweir			End If
69cdf0e10cSrcweir		Next n
70cdf0e10cSrcweir		oBookmarkCursor.NumberingRules = oRules
71cdf0e10cSrcweir	End If
72cdf0e10cSrcweirEnd Sub
73cdf0e10cSrcweir
74cdf0e10cSrcweir
75cdf0e10cSrcweirSub	BulletUrlsToSavePath(SavePath as String)
76cdf0e10cSrcweirDim n as Integer
77cdf0e10cSrcweirDim m as Integer
78cdf0e10cSrcweirDim i as Integer
79cdf0e10cSrcweirDim sNewBulletUrl as String
80cdf0e10cSrcweirDim oLevel()
81cdf0e10cSrcweirDim oRules
82cdf0e10cSrcweirDim bIsFirstRun as Boolean
83cdf0e10cSrcweirDim oNewBuffer()&apos; as New com.sun.star.beans.PropertyValue
84cdf0e10cSrcweirDim bDoReplace as Boolean
85cdf0e10cSrcweirDim oBookmarkCursor as Object
86cdf0e10cSrcweir	bIsFirstRun = True
87cdf0e10cSrcweir	oBookmarks = oBaseDocument.BookMarks
88cdf0e10cSrcweir	For i = 0 To oBookmarks.Count - 1
89cdf0e10cSrcweir		oBookMark = oBookmarks.GetbyIndex(i)
90cdf0e10cSrcweir		oBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
91cdf0e10cSrcweir		If oBookMarkCursor.PropertySetInfo.HasPropertybyName(&quot;NumberingRules&quot;) Then
92cdf0e10cSrcweir			oRules = oBookMarkCursor.NumberingRules
93cdf0e10cSrcweir			If Vartype(oRules()) = 9 Then
94cdf0e10cSrcweir				For n = 0 To oRules.Count - 1
95cdf0e10cSrcweir					oLevel() = oRules.GetByIndex(n)
96cdf0e10cSrcweir					oNewBuffer() = ChangeBulletUrlToSavePath(SavePath, oLevel(), bIsFirstRun, bDoReplace)
97cdf0e10cSrcweir					If bDoReplace Then
98cdf0e10cSrcweir						bIsFirstRun = False
99cdf0e10cSrcweir						oRules.ReplaceByIndex(n, oNewBuffer())
100cdf0e10cSrcweir					End If
101cdf0e10cSrcweir				Next n
102cdf0e10cSrcweir				oBookmarkCursor.NumberingRules = oRules
103cdf0e10cSrcweir			End If
104cdf0e10cSrcweir		End If
105cdf0e10cSrcweir	Next i
106cdf0e10cSrcweirEnd Sub
107cdf0e10cSrcweir
108cdf0e10cSrcweir
109cdf0e10cSrcweirFunction ChangeBulletUrlToSavePath(SavePath as String, oLevel(), bIsFirstRun as Boolean, bDoReplace as Boolean)
110cdf0e10cSrcweirDim MaxIndex as Integer
111cdf0e10cSrcweirDim i as Integer
112cdf0e10cSrcweirDim BulletName as String
113cdf0e10cSrcweirDim oSize as New com.sun.star.awt.Size
114cdf0e10cSrcweir	MaxIndex = Ubound(oLevel())
115cdf0e10cSrcweir	Dim oNewBuffer(MaxIndex) as New com.sun.star.beans.PropertyValue
116cdf0e10cSrcweir	For i = 0 To MaxIndex
117cdf0e10cSrcweir		oNewBuffer(i).Name = oLevel(i).Name
118cdf0e10cSrcweir		If oLevel(i).Name = &quot;GraphicURL&quot; Then
119cdf0e10cSrcweir			bDoReplace = True
120cdf0e10cSrcweir			BulletName = FileNameoutofPath(oLevel(i).Value)
121cdf0e10cSrcweir			If bIsFirstRun Then
122cdf0e10cSrcweir				If oUcb.exists(SavePath &amp; Bulletname) Then
123cdf0e10cSrcweir					FileCopy(oLevel(i).Value, SavePath &amp; BulletName)
124cdf0e10cSrcweir				End If
125cdf0e10cSrcweir			End If
126cdf0e10cSrcweir			oNewBuffer(i).Value = BulletName
127cdf0e10cSrcweir&apos;		ElseIf oLevel(i).Name = &quot;GraphicSize&quot; Then
128cdf0e10cSrcweir&apos;&apos; Todo: Get the original Size of the Bullet (see Bug #86196)
129cdf0e10cSrcweir&apos;			oSize.Height = 300
130cdf0e10cSrcweir&apos;			oSize.Width = 300
131cdf0e10cSrcweir&apos;			oNewBuffer(i).Value = oSize
132cdf0e10cSrcweir		Else
133cdf0e10cSrcweir			oNewBuffer(i).Value = oLevel(i).Value
134cdf0e10cSrcweir		End If
135cdf0e10cSrcweir	Next i
136cdf0e10cSrcweir	ChangeBulletUrlToSavePath() = oNewBuffer()
137*3e02b54dSAndrew RistEnd Function</script:module>
138