xref: /AOO41X/main/wizards/source/webwizard/Bullets.xba (revision 711fced44833292f9bb8ce33bc20bc17437f6f7d)
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<!--***********************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *   http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22 ***********************************************************-->
23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Bullets" script:language="StarBasic">REM  *****  BASIC  *****
24Option Explicit
25
26
27Sub SetBulletGraphics(sBulletUrl as String)
28Dim i as Integer
29Dim oBookMarkCursor as Object
30    oBookmarks = oBaseDocument.BookMarks
31    For i = 0 To oBookmarks.Count - 1
32        oBookMark = oBookmarks.GetbyIndex(i)
33        oBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
34        If oBookMarkCursor.PropertySetInfo.HasPropertybyName(&quot;NumberingRules&quot;) Then
35            ChangeBulletURL(sBulletUrl, oBookMarkCursor)
36        End If
37    Next i
38End Sub
39
40
41Sub ChangeBulletURL(sBulletUrl as String, oBookMarkCursor as Object)
42Dim n, m as Integer
43Dim oLevel()
44Dim oRules
45Dim bDoReplace as Boolean
46Dim oSize as New com.sun.star.awt.Size
47Dim oNumberingBuffer(0) as New com.sun.star.beans.PropertyValue
48Dim oNewBuffer(0) as New com.sun.star.beans.PropertyValue
49    oRules = oBookMarkCursor.NumberingRules
50    If Vartype(oRules()) = 9 Then
51        oNumberingBuffer(0).Name = &quot;NumberingType&quot;
52        oNumberingBuffer(0).Value = com.sun.star.style.NumberingType.BITMAP
53        For n = 0 To oRules.Count - 1
54            oLevel() = oRules.GetByIndex(n)
55            bDoReplace = ModifyPropertyValue(oLevel(), oNumberingBuffer())
56            If bDoReplace Then
57                oRules.ReplaceByIndex(n, oNumberingBuffer())
58            End If
59        Next n
60        oBookmarkCursor.NumberingRules = oRules
61        oNewBuffer(0).Name = &quot;GraphicURL&quot;
62        oNewBuffer(0).Value = sBulletUrl
63        For n = 0 To oRules.Count - 1
64            oLevel() = oRules.GetByIndex(0)
65            bDoReplace = ModifyPropertyValue(oLevel(), oNewBuffer())
66            If bDoReplace Then
67                oRules.ReplaceByIndex(n, oNewBuffer())
68            End If
69        Next n
70        oBookmarkCursor.NumberingRules = oRules
71    End If
72End Sub
73
74
75Sub BulletUrlsToSavePath(SavePath as String)
76Dim n as Integer
77Dim m as Integer
78Dim i as Integer
79Dim sNewBulletUrl as String
80Dim oLevel()
81Dim oRules
82Dim bIsFirstRun as Boolean
83Dim oNewBuffer()&apos; as New com.sun.star.beans.PropertyValue
84Dim bDoReplace as Boolean
85Dim oBookmarkCursor as Object
86    bIsFirstRun = True
87    oBookmarks = oBaseDocument.BookMarks
88    For i = 0 To oBookmarks.Count - 1
89        oBookMark = oBookmarks.GetbyIndex(i)
90        oBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
91        If oBookMarkCursor.PropertySetInfo.HasPropertybyName(&quot;NumberingRules&quot;) Then
92            oRules = oBookMarkCursor.NumberingRules
93            If Vartype(oRules()) = 9 Then
94                For n = 0 To oRules.Count - 1
95                    oLevel() = oRules.GetByIndex(n)
96                    oNewBuffer() = ChangeBulletUrlToSavePath(SavePath, oLevel(), bIsFirstRun, bDoReplace)
97                    If bDoReplace Then
98                        bIsFirstRun = False
99                        oRules.ReplaceByIndex(n, oNewBuffer())
100                    End If
101                Next n
102                oBookmarkCursor.NumberingRules = oRules
103            End If
104        End If
105    Next i
106End Sub
107
108
109Function ChangeBulletUrlToSavePath(SavePath as String, oLevel(), bIsFirstRun as Boolean, bDoReplace as Boolean)
110Dim MaxIndex as Integer
111Dim i as Integer
112Dim BulletName as String
113Dim oSize as New com.sun.star.awt.Size
114    MaxIndex = Ubound(oLevel())
115    Dim oNewBuffer(MaxIndex) as New com.sun.star.beans.PropertyValue
116    For i = 0 To MaxIndex
117        oNewBuffer(i).Name = oLevel(i).Name
118        If oLevel(i).Name = &quot;GraphicURL&quot; Then
119            bDoReplace = True
120            BulletName = FileNameoutofPath(oLevel(i).Value)
121            If bIsFirstRun Then
122                If oUcb.exists(SavePath &amp; Bulletname) Then
123                    FileCopy(oLevel(i).Value, SavePath &amp; BulletName)
124                End If
125            End If
126            oNewBuffer(i).Value = BulletName
127&apos;      ElseIf oLevel(i).Name = &quot;GraphicSize&quot; Then
128&apos;&apos; Todo: Get the original Size of the Bullet (see Bug #86196)
129&apos;          oSize.Height = 300
130&apos;          oSize.Width = 300
131&apos;          oNewBuffer(i).Value = oSize
132        Else
133            oNewBuffer(i).Value = oLevel(i).Value
134        End If
135    Next i
136    ChangeBulletUrlToSavePath() = oNewBuffer()
137End Function</script:module>
138