Ask Your Question
1

Search/replace page style

asked 2015-06-24 16:22:47 +0200

Evil Overlord gravatar image

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?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2015-06-27 10:37:35 +0200

pierre-yves samyn gravatar image

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

edit flag offensive delete link more
0

answered 2015-06-24 19:43:09 +0200

Alex Kemp gravatar image

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-06-24 16:22:47 +0200

Seen: 102 times

Last updated: Jun 27 '15