HERE IS A HEADING:
To a level 2 heading.
I started out by trying to record a macro. I have one that searches for the right text with attributes and then applies the "Header 2" style. But I don't know the proper way to make this loop through the document. I expect this is very simple but I've never done any coding in OO nor do I know any of the macro languages in OO (If it matters, I'm actually using StartSuite 8 on Windows xp)
Basically I want:
- LOOP
search for desired attribute
if not found, break out of loop
else apply format
END of LOOP
Code: Select all
sub ApplyLevel2Head
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(18) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.StyleFamily"
args1(0).Value = 2
args1(1).Name = "SearchItem.CellType"
args1(1).Value = 0
args1(2).Name = "SearchItem.RowDirection"
args1(2).Value = true
args1(3).Name = "SearchItem.AllTables"
args1(3).Value = false
args1(4).Name = "SearchItem.Backward"
args1(4).Value = false
args1(5).Name = "SearchItem.Pattern"
args1(5).Value = false
args1(6).Name = "SearchItem.Content"
args1(6).Value = false
args1(7).Name = "SearchItem.AsianOptions"
args1(7).Value = false
args1(8).Name = "SearchItem.AlgorithmType"
args1(8).Value = 0
args1(9).Name = "SearchItem.SearchFlags"
args1(9).Value = 65536
args1(10).Name = "SearchItem.SearchString"
args1(10).Value = ":"
args1(11).Name = "SearchItem.ReplaceString"
args1(11).Value = ""
args1(12).Name = "SearchItem.Locale"
args1(12).Value = 255
args1(13).Name = "SearchItem.ChangedChars"
args1(13).Value = 2
args1(14).Name = "SearchItem.DeletedChars"
args1(14).Value = 2
args1(15).Name = "SearchItem.InsertedChars"
args1(15).Value = 2
args1(16).Name = "SearchItem.TransliterateFlags"
args1(16).Value = 1280
args1(17).Name = "SearchItem.Command"
args1(17).Value = 0
args1(18).Name = "Quiet"
args1(18).Value = true
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Template"
args2(0).Value = "Heading 2"
args2(1).Name = "Family"
args2(1).Value = 2
dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args2())
rem ----------------------------------------------------------------------
end sub
[Note: if I get this far, I also would like to create a loop to search for all blank paragraphs - which where used to provide vertical spacing - and delete them. I think if I get the basic iteration down I can generalize to different search and replace options as well as applying styles.]
I'm sure this pretty trivial but I couldn't find anything that explained it here, and I would greatly appreciate some enlightenment.
Thanks!