Search/replace page style

Is there a way to search for and replace a page style?

If I import a Word document with multiple sections (e.g., chapters), LO creates individual page styles called “Convert#”. I’d like to search for those styles and replace them with my own style. I can select and delete all the ‘convert’ styles, which drops them to the Default style, but that doesn’t really solve the replace problem.

I note that the search and replace dialog offers an Attributes|Page style option, but I haven’t been able to make it do anything (e.g., by typing ‘default’ or ‘Default style’ in the box). Any suggestions?

Hi

You’re right, search Page Style attribute seems not to work. FYI the Altsearch extension allow to find manual page breaks but would not replace a page style by another (AFAIK).

You can use the following macro to replace your styles:

  • Replace Foo1 and Foo2 by a style name to be replaced and his replacement.
  • Execute ReplaceStylePage

Code:

Sub ReplaceStylePage

const sOldStyle = "Foo1"
const sNewStyle = "Foo2"

dim oViewCurseur as object

oViewCurseur = ThisComponent.CurrentController.getViewCursor()
oViewCurseur.gotoStart(false)

DoReplaceStylePage(oViewCurseur, sOldStyle, sNewStyle)

do while oViewCurseur.jumpToNextPage(false)
	DoReplaceStylePage(oViewCurseur, sOldStyle, sNewStyle)
loop

msgbox "Done", 64, "Replace style"

End Sub

sub DoReplaceStylePage(oViewCurseur, sOldStyle, sNewStyle)

if isempty(oViewCurseur.TextTable) then
	if oViewCurseur.PageDescName = sOldStyle then
		oViewCurseur.PageDescName = sNewStyle
	end if
else
	if oViewCurseur.TextTable.PageDescName = sOldStyle then
		oViewCurseur.TextTable.PageDescName = sNewStyle
	end if
end if

end sub

Regards

Hi Evil Overlord

I’ve been able to use find/replace with character styles, but for find only. To Replace I’ve had to do it manually.